| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# ServiceManager.cpp

Go to the documentation of this file.

    00001 // $Id: ServiceManager.cpp,v 1.27 2008/11/10 15:29:09 marcocle Exp $
    00002
    00003 // Include files
    00004 #include "ServiceManager.h"
    00005 #include "GaudiKernel/IService.h"
    00006 #include "GaudiKernel/SvcFactory.h"
    00007 #include "GaudiKernel/MsgStream.h"
    00008 #include "GaudiKernel/ListItem.h"
    00009 #include "GaudiKernel/System.h"
    00010 #include "GaudiKernel/Service.h"
    00011
    00012 #include <iostream>
    00013 #include <cassert>
    00014
    00015 using ROOT::Reflex::PluginService;
    00016 // constructor
    00017 ServiceManager::ServiceManager(IInterface* iface):
    00018   m_statemgr(iface),
    00019   m_loopCheck(true)
    00020 {
    00021   m_refcount   = 1;
    00022   m_pOuter = iface;
    00023   m_svclocator = (ISvcLocator*)this;
    00024   m_msgsvc     = 0;
    00025 }
    00026
    00027 // destructor
    00028 ServiceManager::~ServiceManager() {
    00029   if( m_msgsvc ) m_msgsvc->release();
    00030   //-- inform the orphan services that I am gone....
    00031   for (ListSvc::const_iterator it = m_listsvc.begin(); it != m_listsvc.end(); it++ ) {
    00032     (*it)->setServiceManager(0);
    00033   }
    00034 }
    00035
    00036 // addRef
    00037 unsigned long ServiceManager::addRef() {
    00038   m_refcount++;
    00039   return m_refcount;
    00040 }
    00041
    00042 // release
    00043 unsigned long ServiceManager::release() {
    00044   unsigned long count = --m_refcount;
    00045   if( count <= 0) {
    00046     delete this;
    00047   }
    00048   return count;
    00049 }
    00050
    00051 //------------------------------------------------------------------------------
    00052 StatusCode ServiceManager::queryInterface(const InterfaceID& iid, void** pinterface)
    00053 //------------------------------------------------------------------------------
    00054 {
    00055   if( iid == IID_IInterface ) {
    00056     *pinterface = (IInterface*)this;
    00057     addRef();
    00058     return StatusCode::SUCCESS;
    00059   }
    00060   else if ( iid == IID_ISvcLocator ) {
    00061     *pinterface = (ISvcLocator*)this;
    00062     addRef();
    00063     return StatusCode::SUCCESS;
    00064   }
    00065   else if ( iid == IID_ISvcManager ) {
    00066     *pinterface = (ISvcManager*)this;
    00067     addRef();
    00068     return StatusCode::SUCCESS;
    00069   }
    00070   else {
    00071     return m_pOuter->queryInterface(iid, pinterface);
    00072   }
    00073 }
    00074
    00075 //------------------------------------------------------------------------------
    00076 StatusCode ServiceManager::getService( const std::string& name, IService*& svc)
    00077 //------------------------------------------------------------------------------
    00078 {
    00079   return getService(name, svc, true);
    00080 }
    00081 //------------------------------------------------------------------------------
    00082 StatusCode ServiceManager::getService( const std::string& name, const InterfaceID& iid,
    00083                                        IInterface*& pinterface)
    00084 //------------------------------------------------------------------------------
    00085 {
    00086   IService*  svc;
    00087   StatusCode status = getService( name, svc, false );
    00088   if( status.isSuccess() ) {
    00089     // Service found. So now get the right interface
    00090     status = svc->queryInterface( iid, (void**)&pinterface );
    00091   }
    00092   return status;
    00093 }
    00094 //------------------------------------------------------------------------------
    00095 StatusCode ServiceManager::makeService( const std::string& nam,
    00096                                         IService*& svc )
    00097 //------------------------------------------------------------------------------
    00098 {
    00099   // find out if name is registered with a type
    00100   std::string name = nam;
    00101   std::string type;
    00102   MapType::iterator it = m_maptype.find( nam );
    00103   if( it != m_maptype.end() ) {
    00104     type = (*it).second;
    00105   } else {
    00106     // otherwise parse the name to see if it is of the format "type/name"
    00107     ListItem item(name);
    00108     type = item.type();
    00109     name = item.name();
    00110   }
    00111   std::string::size_type ip;
    00112   if ( (ip = type.find("__")) != std::string::npos) {
    00113     type.erase(ip,type.length());
    00114   }
    00115   StatusCode sc = createService( type, name, svc );
    00116   if( sc.isSuccess() ) {
    00117     // Bring the created service to the same state in which the ApplicationMgr
    00118     // will be.
    00119     if (m_statemgr->targetFSMState() >= Gaudi::StateMachine::INITIALIZED) {
    00120       sc = svc->sysInitialize();
    00121       if (sc.isSuccess() && m_statemgr->targetFSMState() >= Gaudi::StateMachine::RUNNING) {
    00122         sc = svc->sysStart();
    00123       }
    00124     }
    00125
    00126     if( sc.isSuccess() ) {
    00127       sc = addService( svc, 10);
    00128     } else {
    00129       MsgStream log(msgSvc(), "ServiceManager");
    00130       log << MSG::ERROR << "Unable to initialize service \"" << name << "\""
    00131           << endreq;
    00132       removeService(svc).ignore(); //if init fails remove it from the list
    00133       delete svc;
    00134       svc = 0;
    00135     }
    00136     if (svc!= 0) svc->setServiceManager( this );
    00137   }
    00138   return sc;
    00139 }
    00140
    00141 //------------------------------------------------------------------------------
    00142 StatusCode ServiceManager::getService( const std::string& nam, IService*& svc,
    00143                                        bool createIf)
    00144 //------------------------------------------------------------------------------
    00145 {
    00146   ListItem item(nam);
    00147   const std::string& name = item.name();
    00148
    00149   StatusCode sc(StatusCode::FAILURE);
    00150   ListSvc::iterator it(m_listsvc.begin());
    00151   for (; it != m_listsvc.end(); ++it ) {
    00152     if( (*it)->name() == name ) {
    00153       svc = *it;
    00154       break;
    00155     }
    00156   }
    00157
    00158   if (it !=  m_listsvc.end()) {
    00159     if (m_loopCheck &&
    00160         (createIf && (*it)->FSMState() == Gaudi::StateMachine::CONFIGURED)) {
    00161       MsgStream log(msgSvc(), "ServiceManager");
    00162       log << MSG::ERROR
    00163           << "Initialization loop detected when creating service \"" << name
    00164           << "\""
    00165           << endreq;
    00166       sc = StatusCode::FAILURE;
    00167     } else {
    00168       sc = StatusCode::SUCCESS;
    00169     }
    00170   } else {
    00171     // Service not found. The user may be interested in one of the interfaces
    00172     // of the application manager itself
    00173     if( name == "ApplicationMgr" ||
    00174         name == "APPMGR" ||
    00175         name == "" ) {
    00176       sc = m_svclocator->queryInterface( IService::interfaceID(), (void**)&svc );
    00177       if( svc ) svc->release(); // Do not increase the reference count
    00178     } else if ( createIf ){
    00179       //last resort: we try to create the service
    00180       if ( item.name() != item.type() ) {
    00181         // if we were asked for a "ServiceType/ServiceName", we pass the string
    00182         // directly to makeService
    00183         sc = makeService(nam, svc);
    00184       } else {
    00185         // the user did not specified both type and name
    00186         sc = makeService(name, svc);
    00187       }
    00188     }
    00189   }
    00190
    00191   return sc;
    00192 }
    00193
    00194 //------------------------------------------------------------------------------
    00195 const std::list<IService*>& ServiceManager::getServices( ) const
    00196 //------------------------------------------------------------------------------
    00197 {
    00198   return m_listsvc;
    00199 }
    00200
    00201 //------------------------------------------------------------------------------
    00202 std::list<IService*> ServiceManager::getActiveServices( ) const
    00203 //------------------------------------------------------------------------------
    00204 {
    00205   std::list<IService*> asvcs;
    00206   for (PListSvc::const_iterator itr = m_activesvc.begin();
    00207        itr != m_activesvc.end(); ++itr) {
    00208     asvcs.push_back( itr->first );
    00209   }
    00210   return asvcs;
    00211 }
    00212
    00213
    00214 //------------------------------------------------------------------------------
    00215 bool ServiceManager::existsService( const std::string& name) const
    00216 //------------------------------------------------------------------------------
    00217 {
    00218   ListSvc::const_iterator it;
    00219   for (it = m_listsvc.begin(); it != m_listsvc.end(); it++ ) {
    00220     if( name == (*it)->name() ) {
    00221       return true;
    00222     }
    00223   }
    00224   return false;
    00225 }
    00226
    00227 //------------------------------------------------------------------------------
    00228 StatusCode ServiceManager::addService( IService* svc, int prio )
    00229 //------------------------------------------------------------------------------
    00230 {
    00231   PListSvc::iterator it;
    00232   // remove it if already in the list
    00233   removeActiveService( svc ).ignore();
    00234   // insert in the right place in the list
    00235   for( it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00236     if( (*it).second > prio )  break;
    00237   }
    00238   m_activesvc.insert(it, std::make_pair(svc, prio));
    00239   return StatusCode::SUCCESS;
    00240 }
    00241
    00242 //------------------------------------------------------------------------------
    00243 StatusCode ServiceManager::addService( const std::string& type,
    00244                                        const std::string& name, int prio )
    00245 //------------------------------------------------------------------------------
    00246 {
    00247   StatusCode sc;
    00248   IService* svc;
    00249   if( existsService(name) ) {
    00250     sc = getService(name, svc);
    00251   } else {
    00252     if( type.length() == 0 ) {
    00253       // find out if name is registered with a type
    00254       MapType::iterator it = m_maptype.find( name );
    00255       if( it != m_maptype.end() ) {
    00256         sc = createService( (*it).second, name, svc );
    00257       } else {
    00258         sc = createService( name, name, svc );
    00259       }
    00260     } else {
    00261       sc = createService( type, name, svc );
    00262     }
    00263
    00264     if (sc.isSuccess() && m_statemgr->targetFSMState() >= Gaudi::StateMachine::INITIALIZED) {
    00265       sc = svc->sysInitialize();
    00266       if (sc.isSuccess() && m_statemgr->targetFSMState() >= Gaudi::StateMachine::RUNNING) {
    00267         sc = svc->sysStart();
    00268       }
    00269     }
    00270
    00271   }
    00272   if( sc.isSuccess() ) {
    00273     return addService( svc, prio );
    00274   }
    00275   else {
    00276     return sc;
    00277   }
    00278 }
    00279
    00280 //------------------------------------------------------------------------------
    00281 StatusCode ServiceManager::removeService( IService* svc)
    00282 //------------------------------------------------------------------------------
    00283 {
    00284
    00285   removeActiveService(svc).ignore();
    00286   removeListService(svc).ignore();
    00287
    00288   return StatusCode(StatusCode::SUCCESS,true);
    00289 }
    00290
    00291 //------------------------------------------------------------------------------
    00292 StatusCode ServiceManager::removeActiveService( IService* svc)
    00293 //------------------------------------------------------------------------------
    00294 {
    00295   PListSvc::iterator it;
    00296   for (it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00297     if( (*it).first == svc ) {
    00298       m_activesvc.erase(it);
    00299       break;
    00300     }
    00301   }
    00302
    00303   return StatusCode::SUCCESS;
    00304 }
    00305
    00306 //------------------------------------------------------------------------------
    00307 StatusCode ServiceManager::removeListService( IService* svc)
    00308 //------------------------------------------------------------------------------
    00309 {
    00310
    00311   ListSvc::iterator ll;
    00312   for ( ll = m_listsvc.begin(); ll != m_listsvc.end(); ++ll ) {
    00313     if ( (*ll) == svc  ) {
    00314       m_listsvc.erase( ll );
    00315       break;
    00316     }
    00317   }
    00318
    00319   return StatusCode::SUCCESS;
    00320 }
    00321
    00322
    00323 //------------------------------------------------------------------------------
    00324 StatusCode ServiceManager::removeService( const std::string& nam )
    00325 //------------------------------------------------------------------------------
    00326 {
    00327   IService* svc;
    00328   if( getService(nam, svc).isSuccess() ) return removeService(svc);
    00329   else return StatusCode::FAILURE;
    00330 }
    00331
    00332 //------------------------------------------------------------------------------
    00333 StatusCode ServiceManager::declareSvcFactory( const ISvcFactory& factory,
    00334                                               const std::string& svctype )
    00335 //------------------------------------------------------------------------------
    00336 {
    00337
    00338   std::pair<MapFactory::iterator, bool> p;
    00339   p = m_mapfactory.insert(MapFactory::value_type( svctype, (ISvcFactory*)&factory) );
    00340   if( p.second == false) {
    00341     MsgStream log(msgSvc(), "ServiceManager");
    00342     log << MSG::WARNING << "Service factory for type " << svctype << " already declared" << endreq;
    00343     m_mapfactory.erase ( p.first );
    00344     p = m_mapfactory.insert(MapFactory::value_type( svctype, (ISvcFactory*)&factory) );
    00345     if( p.second == false) return StatusCode::FAILURE;
    00346   }
    00347   return StatusCode::SUCCESS;
    00348 }
    00349
    00350 //------------------------------------------------------------------------------
    00351 StatusCode ServiceManager::declareSvcType( const std::string& svcname,
    00352                                            const std::string& svctype )
    00353 //------------------------------------------------------------------------------
    00354 {
    00355   std::pair<MapType::iterator, bool> p = m_maptype.insert(std::make_pair(svcname, svctype));
    00356   if( p.second == false) {
    00357     m_maptype.erase ( p.first );
    00358     p = m_maptype.insert(std::make_pair(svcname, svctype) );
    00359     if( p.second == false) return StatusCode::FAILURE;
    00360   }
    00361   return StatusCode::SUCCESS;
    00362 }
    00363
    00364 //------------------------------------------------------------------------------
    00365 StatusCode ServiceManager::initializeServices()
    00366 //------------------------------------------------------------------------------
    00367 {
    00368   StatusCode sc;
    00369   MsgStream log(msgSvc(), "ServiceManager");
    00370
    00371   // call initialize() for all services
    00372   for (PListSvc::iterator it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00373     std::string name = (*it).first->name();
    00374     switch ((*it).first->FSMState()) {
    00375     case Gaudi::StateMachine::INITIALIZED:
    00376       log << MSG::DEBUG << "Service " << name
    00377           << " already initialized" << endreq;
    00378       break;
    00379     case Gaudi::StateMachine::OFFLINE:
    00380       log << MSG::DEBUG << "Initializing service " << name << endreq;
    00381       sc = (*it).first->sysInitialize();
    00382       if( !sc.isSuccess() ) {
    00383         log << MSG::ERROR << "Unable to initialize Service: " << (*it).first->name() << endreq;
    00384         return sc;
    00385       } break;
    00386     default:
    00387       log << MSG::ERROR << "Service " << name
    00388           << " not in the correct state to be initialized ("
    00389           << (*it).first->FSMState() << ")" << endreq;
    00390       return StatusCode::FAILURE;
    00391     }
    00392   }
    00393   return StatusCode::SUCCESS;
    00394 }
    00395
    00396 //------------------------------------------------------------------------------
    00397 StatusCode ServiceManager::startServices()
    00398 //------------------------------------------------------------------------------
    00399 {
    00400   StatusCode sc = StatusCode(StatusCode::FAILURE,true);
    00401   MsgStream log(msgSvc(), "ServiceManager");
    00402
    00403   // call initialize() for all services
    00404   for (PListSvc::iterator it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00405     std::string name = (*it).first->name();
    00406     switch ((*it).first->FSMState()) {
    00407     case Gaudi::StateMachine::RUNNING:
    00408       log << MSG::DEBUG << "Service " << name
    00409           << " already started" << endreq;
    00410       break;
    00411     case Gaudi::StateMachine::INITIALIZED:
    00412       log << MSG::DEBUG << "Starting service " << name << endreq;
    00413       sc = (*it).first->sysStart();
    00414       if( !sc.isSuccess() ) {
    00415         log << MSG::ERROR << "Unable to start Service: " << (*it).first->name() << endreq;
    00416         return sc;
    00417       } break;
    00418     default:
    00419       log << MSG::ERROR << "Service " << name
    00420           << " not in the correct state to be started ("
    00421           << (*it).first->FSMState() << ")" << endreq;
    00422       return StatusCode::FAILURE;
    00423     }
    00424   }
    00425   return StatusCode::SUCCESS;
    00426 }
    00427
    00428
    00429 //------------------------------------------------------------------------------
    00430 StatusCode ServiceManager::stopServices()
    00431 //------------------------------------------------------------------------------
    00432 {
    00433   StatusCode sc;
    00434   MsgStream log(msgSvc(), "ServiceManager");
    00435
    00436   PListSvc::reverse_iterator it;
    00437   // call stop() for all services
    00438   for ( it = m_activesvc.rbegin(); it != m_activesvc.rend(); it++ ) {
    00439     std::string name = (*it).first->name();
    00440     switch ((*it).first->FSMState()) {
    00441     case Gaudi::StateMachine::INITIALIZED:
    00442       log << MSG::DEBUG << "Service " << name
    00443           << " already stopped" << endreq;
    00444       break;
    00445     case Gaudi::StateMachine::RUNNING:
    00446       log << MSG::DEBUG << "Stopping service " << name << endreq;
    00447       sc = (*it).first->sysStop();
    00448       if( !sc.isSuccess() ) {
    00449         log << MSG::ERROR << "Unable to stop Service: " << (*it).first->name() << endreq;
    00450         return sc;
    00451       } break;
    00452     default:
    00453       log << MSG::ERROR << "Service " << name
    00454           << " not in the correct state to be stopped ("
    00455           << (*it).first->FSMState() << ")" << endreq;
    00456       return StatusCode::FAILURE;
    00457     }
    00458   }
    00459   return StatusCode::SUCCESS;
    00460 }
    00461
    00462 //------------------------------------------------------------------------------
    00463 StatusCode ServiceManager::reinitializeServices()
    00464 //------------------------------------------------------------------------------
    00465 {
    00466   StatusCode sc;
    00467
    00468   PListSvc::iterator it;
    00469   // Re-Initialize all services
    00470   for ( it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00471     sc = (*it).first->sysReinitialize();
    00472     if( !sc.isSuccess() ) {
    00473       MsgStream log(msgSvc(), "ServiceManager");
    00474       log << MSG::ERROR << "Unable to re-initialize Service: " << (*it).first->name() << endreq;
    00475       return StatusCode::FAILURE;
    00476     }
    00477   }
    00478   return StatusCode::SUCCESS;
    00479 }
    00480
    00481 //------------------------------------------------------------------------------
    00482 StatusCode ServiceManager::restartServices()
    00483 //------------------------------------------------------------------------------
    00484 {
    00485   StatusCode sc;
    00486
    00487   PListSvc::iterator it;
    00488   // Re-Start all services
    00489   for ( it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00490     sc = (*it).first->sysRestart();
    00491     if( !sc.isSuccess() ) {
    00492       MsgStream log(msgSvc(), "ServiceManager");
    00493       log << MSG::ERROR << "Unable to re-start Service: " << (*it).first->name() << endreq;
    00494       return StatusCode::FAILURE;
    00495     }
    00496   }
    00497   return StatusCode::SUCCESS;
    00498 }
    00499
    00500 //------------------------------------------------------------------------------
    00501 StatusCode ServiceManager::finalizeServices()
    00502 //------------------------------------------------------------------------------
    00503 {
    00504   MsgStream log(msgSvc(), "ServiceManager");
    00505
    00506   PListSvc::reverse_iterator its;
    00507
    00508   StatusCode sc(StatusCode::SUCCESS);
    00509
    00510   // make sure that HistogramDataSvc and THistSvc get finalized after the
    00511   // ToolSvc, and StatusCodeSvc after that
    00512   int pri_tool = getPriority("ToolSvc");
    00513   if (pri_tool != 0) {
    00514     setPriority("THistSvc",pri_tool-1).ignore();
    00515     setPriority("ChronoStatSvc",pri_tool-2).ignore();
    00516     setPriority("AuditorSvc",pri_tool-3).ignore();
    00517     setPriority("HistogramDataSvc",pri_tool-1).ignore();
    00518     // Preserve the relative ordering between HistogramDataSvc and HistogramPersistencySvc
    00519     setPriority("HistogramPersistencySvc",pri_tool-2).ignore();
    00520   }
    00521
    00522   // make sure the StatusCodeSvc gets finalized really late:
    00523   setPriority("StatusCodeSvc",-9999).ignore();
    00524
    00525   // call finalize() for all services in reverse order
    00526   for ( its = m_activesvc.rbegin(); its != m_activesvc.rend(); its++ ) {
    00527     // ignore the current state for the moment
    00528     // if( Gaudi::StateMachine::INITIALIZED == (*it).first->state() ) {
    00529     log << MSG::DEBUG << "Finalizing service " << (*its).first->name() << endreq;
    00530     if ( !((*its).first->sysFinalize()).isSuccess() ) {
    00531       log << MSG::WARNING << "Finalization of service " << (*its).first->name()
    00532       << " failed" << endreq;
    00533       sc = StatusCode::FAILURE;
    00534     }
    00535   }
    00536
    00537   // loop over all Active Services, removing them one by one.
    00538   while (m_activesvc.size() != 0) {
    00539     PListSvc::iterator its = m_activesvc.end();
    00540     its --;
    00541
    00543     //   for ( its = m_activesvc.rbegin(); its != m_activesvc.rend(); its++ ) {
    00544     // erase from m_listsvc before releasing
    00545     for ( ListSvc::iterator ll = m_listsvc.begin(); ll != m_listsvc.end(); ++ll ) {
    00546       if ( (*ll)->name() == its->first->name() ) {
    00547         m_listsvc.erase( ll );
    00548         break;
    00549       }
    00550     }
    00551
    00552     // this may destroy the service
    00553     (*its).first->release();
    00554   }
    00555
    00556   // clear the list of active services
    00557   m_activesvc.erase(m_activesvc.begin(), m_activesvc.end() );
    00558
    00559   return sc ;
    00560 }
    00561
    00562
    00563 //------------------------------------------------------------------------------
    00564 StatusCode ServiceManager::createService( const std::string& svctype,
    00565                                           const std::string& svcname,
    00566                                           IService*& service )
    00567 //------------------------------------------------------------------------------
    00568 {
    00569   // Check is the service is already existing
    00570   if( existsService( svcname ) ) {
    00571     // return an error because a service with that name already exists
    00572     return StatusCode::FAILURE;
    00573   }
    00574
    00575   StatusCode rc = StatusCode::FAILURE;
    00576   rc.setChecked(); //hack to avoid going into infinite recursion on ~StatusCode
    00577
    00578   MsgStream log(msgSvc(), "ServiceManager");
    00579
    00580   service = PluginService::Create<IService*>(svctype, svcname, m_svclocator);
    00581   if ( !service ) {
    00582     service = PluginService::CreateWithId<IService*>(svctype, svcname, m_svclocator);
    00583   }
    00584
    00585   if ( service ) {
    00586     m_listsvc.push_back( service );
    00587     // Check the compatibility of the version of the interface obtained
    00588     if( !isValidInterface(service) ) {
    00589       log << MSG::FATAL << "Incompatible interface IService version for " << svctype << endreq;
    00590       return StatusCode::FAILURE;
    00591     }
    00592     service->setServiceManager(this);
    00593     return StatusCode(StatusCode::SUCCESS,true);
    00594   }
    00595   log << MSG::FATAL << "No Service factory for " << svctype << " available." << endreq;
    00596   return StatusCode::FAILURE;
    00597 }
    00598
    00600 StatusCode
    00601 ServiceManager::getFactory(const std::string& svctype,const ISvcFactory*& factory) const
    00602 {
    00603   MapFactory::const_iterator itf = m_mapfactory.find( svctype );
    00604   factory = (itf == m_mapfactory.end()) ? 0 : (*itf).second;
    00605   return (factory==0) ? StatusCode::FAILURE : StatusCode::SUCCESS;
    00606 }
    00607
    00608 //------------------------------------------------------------------------------
    00609 IMessageSvc* ServiceManager::msgSvc()
    00610 //------------------------------------------------------------------------------
    00611 {
    00612   if( m_msgsvc == 0 ) {
    00613     IService* iSvc(0);
    00614     if ( (getService( "MessageSvc", iSvc, false)).isSuccess() )
    00615       m_msgsvc = dynamic_cast<IMessageSvc*>(iSvc);
    00616   }
    00617   return m_msgsvc;
    00618 }
    00619
    00620 //------------------------------------------------------------------------------
    00621 int
    00622 ServiceManager::getPriority(const std::string& name) const {
    00623 //------------------------------------------------------------------------------
    00624
    00625   PListSvc::const_iterator it;
    00626   for (it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00627     if ((*it).first->name() == name) {
    00628       return (*it).second;
    00629     }
    00630   }
    00631
    00632   return 0;
    00633
    00634 }
    00635
    00636 //------------------------------------------------------------------------------
    00637 StatusCode
    00638 ServiceManager::setPriority(const std::string& name, int prio) {
    00639 //------------------------------------------------------------------------------
    00640
    00641   PListSvc::const_iterator it;
    00642   for (it = m_activesvc.begin(); it != m_activesvc.end(); it++ ) {
    00643     if ((*it).first->name() == name) {
    00644       IService *svc = (*it).first;
    00645       removeActiveService( svc ).ignore();
    00646       return addService(svc,prio);
    00647     }
    00648   }
    00649
    00650   return StatusCode::FAILURE;
    00651
    00652 }
    00653
    00654 //------------------------------------------------------------------------------
    00655 // Get the value of the initialization loop check flag.
    00656 //------------------------------------------------------------------------------
    00657 bool ServiceManager::loopCheckEnabled() const {
    00658   return m_loopCheck;
    00659 }
    00660 //------------------------------------------------------------------------------
    00661 // Set the value of the initialization loop check flag.
    00662 //------------------------------------------------------------------------------
    00663 void ServiceManager::setLoopCheckEnabled(bool en) {
    00664   m_loopCheck = en;
    00665 }