17 #define ON_DEBUG if (msgLevel(MSG::DEBUG))
18 #define ON_VERBOSE if (msgLevel(MSG::VERBOSE))
20 #define DEBMSG ON_DEBUG debug()
21 #define VERMSG ON_VERBOSE verbose()
42 it->service->setServiceManager(0);
61 const std::string &
name = typeName.name();
62 std::string
type = typeName.type();
63 if (!typeName.haveType()) {
72 std::string::size_type ip;
73 if ( (ip = type.find(
"__")) != std::string::npos) {
74 type.erase(ip,type.length());
77 IService*
service = Service::Factory::create(type, name, static_cast<ISvcLocator*>(
this));
83 fatal() <<
"Incompatible interface IService version for " << type <<
endmsg;
89 fatal() <<
"No Service factory for " << type <<
" available." <<
endmsg;
98 ListSvc::iterator it =
find(svc);
113 ListSvc::iterator it =
find(typeName.name());
122 sc = svc->sysInitialize();
124 sc = svc->sysStart();
128 error() <<
"Unable to initialize service \"" << typeName.name() <<
"\""
157 const std::string &
name = typeName.name();
162 ListSvc::iterator it =
find(name);
168 <<
"Initialization loop detected when creating service \"" << name
177 if( name ==
"ApplicationMgr" ||
181 }
else if ( createIf ){
184 return find(name)->service;
197 m_listOfPtrs.push_back(const_cast<IService*>(it->service.get()));
206 return find(name) != m_listsvc.end();
213 ListSvc::iterator it =
find(svc);
225 ListSvc::iterator it =
find(name);
235 const std::string& svctype )
238 std::pair<MapType::iterator, bool> p =
m_maptype.
insert(std::make_pair(svcname, svctype));
239 if( p.second ==
false) {
258 for (ListSvc::iterator it = tmpList.begin(); it != tmpList.end(); ++it ) {
259 if (!it->active)
continue;
260 const std::string&
name = it->service->name();
261 switch (it->service->FSMState()) {
263 DEBMSG <<
"Service " << name <<
" already initialized" <<
endmsg;
267 sc = it->service->sysInitialize();
269 error() <<
"Unable to initialize Service: " << name <<
endmsg;
273 error() <<
"Service " << name
274 <<
" not in the correct state to be initialized ("
275 << it->service->FSMState() <<
")" <<
endmsg;
293 for (ListSvc::iterator it = tmpList.begin(); it != tmpList.end(); ++it ) {
294 if (!it->active)
continue;
295 const std::string&
name = it->service->name();
296 switch (it->service->FSMState()) {
298 DEBMSG <<
"Service " << name
299 <<
" already started" <<
endmsg;
303 sc = it->service->sysStart();
305 error() <<
"Unable to start Service: " << name <<
endmsg;
309 error() <<
"Service " << name
310 <<
" not in the correct state to be started ("
311 << it->service->FSMState() <<
")" <<
endmsg;
329 ListSvc::reverse_iterator it;
331 for (it = tmpList.rbegin(); it != tmpList.rend(); ++it ) {
332 if (!it->active)
continue;
333 const std::string&
name = it->service->name();
334 switch (it->service->FSMState()) {
336 DEBMSG <<
"Service " << name <<
" already stopped" <<
endmsg;
340 sc = it->service->sysStop();
342 error() <<
"Unable to stop Service: " << name <<
endmsg;
346 DEBMSG <<
"Service " << name
347 <<
" not in the correct state to be stopped ("
348 << it->service->FSMState() <<
")" <<
endmsg;
365 ListSvc::iterator it;
367 for ( it = tmpList.begin(); it != tmpList.end(); ++it ) {
368 if (!it->active)
continue;
369 sc = it->service->sysReinitialize();
371 error() <<
"Unable to re-initialize Service: " << it->service->name() <<
endmsg;
388 ListSvc::iterator it;
390 for ( it = tmpList.begin(); it != tmpList.end(); ++it ) {
391 if (!it->active)
continue;
392 sc = it->service->sysRestart();
394 error() <<
"Unable to re-start Service: " << it->service->name() <<
endmsg;
422 std::vector<IIncidentListener*> postFinList;
443 ListSvc::reverse_iterator rit;
444 for (rit = tmpList.rbegin(); rit != tmpList.rend(); ++rit ) {
445 if (!rit->active)
continue;
446 const std::string&
name = rit->service->name();
450 if ( !(rit->service->sysFinalize()).isSuccess() ) {
451 warning() <<
"Finalization of service " << name <<
" failed" <<
endmsg;
458 if (!postFinList.empty()) {
459 DEBMSG <<
"Will call SvcPostFinalize for " << postFinList.size() <<
" clients"
462 std::vector<IIncidentListener*>::iterator itr;
463 for (itr = postFinList.begin(); itr != postFinList.end(); ++itr) {
470 DEBMSG <<
"Looping over all active services..." <<
endmsg;
471 ListSvc::iterator it =
m_listsvc.begin();
473 DEBMSG <<
"---- " << it->service->name()
474 <<
" (refCount = " << it->service->refCount() <<
")"
476 if (it->service->refCount() < 1) {
477 warning() <<
"Too low reference count for " << it->service->name()
478 <<
" (should not go below 1 at this point)" <<
endmsg;
479 it->service->addRef();
496 ListSvc::const_iterator it =
find(name);
497 return (it !=
m_listsvc.end()) ? it->priority: 0;
504 ListSvc::iterator it =
find(name);
534 <<
"===================== listing all services ===================\n"
535 <<
" prior ref name active\n";
537 ListSvc::const_iterator it;
541 log.
flags(std::ios_base::right);
542 log << it->priority <<
" ";
544 log << it->service->refCount() <<
" ";
546 log.
flags(std::ios_base::left);
547 log << it->service->name() <<
" ";
549 log << it->active << std::endl;
553 log <<
"=================================================================\n";