Gaudi Framework, version v21r9

Home   Generated: 3 May 2010

ApplicationMgr Class Reference

The Application Manager class. More...

#include <ApplicationMgr.h>

Inheritance diagram for ApplicationMgr:

Inheritance graph
[legend]
Collaboration diagram for ApplicationMgr:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list< std::pair
< IService *, int > > 
ListSvc
typedef std::list< std::stringListName
typedef std::vector< std::stringVectorName

Public Member Functions

 ApplicationMgr (IInterface *=0)
virtual ~ApplicationMgr ()
virtual StatusCode queryInterface (const InterfaceID &iid, void **pinterface)
virtual StatusCode run ()
virtual StatusCode configure ()
virtual StatusCode terminate ()
virtual StatusCode initialize ()
virtual StatusCode start ()
virtual StatusCode stop ()
virtual StatusCode finalize ()
virtual StatusCode nextEvent (int maxevt)
virtual const std::stringname () const
 This is needed to avoid ambiguous calls to name().
virtual StatusCode executeEvent (void *par)
 implementation of IEventProcessor::executeEvent(void*)
virtual StatusCode executeRun (int evtmax)
 implementation of IEventProcessor::executeRun(int)
virtual StatusCode stopRun ()
 implementation of IEventProcessor::stopRun()
virtual Gaudi::StateMachine::State FSMState () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual StatusCode reinitialize ()
virtual StatusCode restart ()
virtual StatusCode sysInitialize ()
virtual StatusCode sysStart ()
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()
void SIGoHandler (Property &theProp)
void SIExitHandler (Property &theProp)
template<class I>
SmartIF< IComponentManager > & getManager ()
SmartIF< ISvcManager > & svcManager ()
SmartIF< IAlgManager > & algManager ()
virtual SmartIF< ISvcLocator > & serviceLocator () const
 Needed to locate the message service.
Property handlers
void evtLoopPropertyHandler (Property &theProp)
StatusCode decodeExtSvcNameList ()
StatusCode decodeCreateSvcNameList ()
void createSvcNameListHandler (Property &)
void extSvcNameListHandler (Property &theProp)
StatusCode decodeMultiThreadSvcNameList ()
void multiThreadSvcNameListHandler (Property &theProp)
StatusCode decodeDllNameList ()
void dllNameListHandler (Property &theProp)
void reflexDebugPropertyHandler (Property &theProp)
void initLoopCheckHndlr (Property &)

Protected Types

typedef std::map< unsigned
long, SmartIF
< IComponentManager > > 
ManagersMap
 Typedef for the map of component managers, the key is the "id" field of the basic InterfaceID of the managed components.

Protected Member Functions

StatusCode declareMultiSvcType (const std::string &name, const std::string &type)
 declare one or more copies of svc type/name as determined by NoOfThreads
StatusCode addMultiSvc (const Gaudi::Utils::TypeNameString &typeName, int prio)
 add one or more copies of svc type/name as determined by NoOfThreads
void setServiceManager (ISvcManager *)
StatusCode i_startup ()
 Internal startup routine.
StatusCode GoToState (Gaudi::StateMachine::State state, bool ignoreFailures=false)
 Reach a state from current state (whichever it is) going through the correct transitions.

Protected Attributes

ManagersMap m_managers
 Map of known component managers.
StringArrayProperty m_declaredManagers
 Property to declare the list of known managers.
SmartIF< ISvcManagerm_svcManager
 Cached pointer to the manager of services.
SmartIF< IAlgManagerm_algManager
 Cached pointer to the manager of algorithms.
DLLClassManagerm_classManager
 Reference to the class manager.
SmartIF< ISvcLocatorm_svcLocator
 Reference to its own service locator.
IntegerProperty m_SIGo
 For SI's "Go" command via callback.
IntegerProperty m_SIExit
 For SI's "Exit" command via callback.
StringArrayProperty m_topAlgNameList
 List of top level algorithms names.
StringArrayProperty m_outStreamNameList
 List of output stream names.
StringProperty m_outStreamType
 Output stream type (obsolete?).
StringProperty m_messageSvcType
 MessageSvc type.
StringProperty m_jobOptionsSvcType
 JobOptionsSvc type.
ListSvc m_topSvcList
 List of top level services.
ListName m_topSvcNameList
 List of top level services names.
std::string m_name
 Name.
Gaudi::StateMachine::State m_state
 Internal State.
Gaudi::StateMachine::State m_targetState
 Internal State.
VectorName m_defServices
 Vector default services names.
VectorName m_svcMapping
 Default mapping of services.
VectorName m_svcOptMapping
 Default mapping of services.
PropertyMgrm_propertyMgr
 Reference to Property Manager.
SmartIF< IMessageSvcm_messageSvc
 Reference to the message service.
SmartIF< IRunablem_runable
 Reference to the runable object.
SmartIF< IEventProcessorm_processingMgr
 Reference to processing manager object.
SmartIF< IJobOptionsSvcm_jobOptionsSvc
 Reference to JobOption service.
int m_evtMax
 Number of events to be processed.
StringArrayProperty m_extSvcNameList
 List of external services names.
BooleanProperty m_extSvcCreates
 LHCb or ATLAS defn of "ExtSvc".
StringArrayProperty m_multiThreadSvcNameList
 List of external services names for which we want a copy per evt thread.
int m_noOfEvtThreads
 no of multiThreadSvc copies
StringArrayProperty m_dllNameList
 List of DDL's names.
std::string m_jobOptionsType
 Source type (e.g. dbase, file...).
std::string m_jobOptionsPath
 The "file" to look for properties.
std::string m_runableType
 Runable type.
std::string m_eventLoopMgr
 Processing manager type.
std::string m_evtsel
 Event selection.
std::string m_histPersName
 CGL: Name of the Hist Pers Svc.
int m_outputLevel
 Message output level.
std::string m_appName
 The name of the application.
std::string m_appVersion
 The version of the application.
bool m_actHistory
 Activate HistorySvc.
bool m_codeCheck
 Activate StatusCode checking.
IntegerProperty m_reflexDebugLevel
 Debug level for the reflex plugin system.
StringArrayProperty m_createSvcNameList
BooleanProperty m_auditTools
 Defaults for auditors.
BooleanProperty m_auditSvcs
BooleanProperty m_auditAlgs
std::map< std::string,
std::string
m_environment
 Environment variables to set.
BooleanProperty m_loopCheck
 For ServiceMgr initialization loop checking.
BooleanProperty m_stopOnSignal
 Property to enable/disable the "stop on signal" service (enabled by default).
BooleanProperty m_stalledEventMonitoring
 Property to enable/disable the monitoring and reporting of stalled events (enabled by default).
bool m_propertiesPrint
 flag to activate the printout of properties
IntegerProperty m_returnCode
 Property to record the error conditions occurring during the running.

Private Types

typedef CommonMessaging
< implements4< IAppMgrUI,
IEventProcessor, IService,
IStateful > > 
base_class
 Typedef to this class.

Private Attributes

std::vector< std::stringm_okDlls
 names of successfully loaded dlls


Detailed Description

The Application Manager class.

The main purpose of the Application Manager is to steer any data processing application. This includes all data processing applications for LHCb data in all stages: simulation, reconstruction, analysis, high level triggers, etc. Specific implementations of the ApplicationMgr will be developed to cope with the different environments (on-line, off-line, interactive, batch, etc.).

Author:
Pere Mato

Definition at line 47 of file ApplicationMgr.h.


Member Typedef Documentation

Typedef to this class.

Reimplemented from CommonMessaging< implements4< IAppMgrUI, IEventProcessor, IService, IStateful > >.

Definition at line 54 of file ApplicationMgr.h.

Definition at line 56 of file ApplicationMgr.h.

Definition at line 57 of file ApplicationMgr.h.

Definition at line 58 of file ApplicationMgr.h.

Typedef for the map of component managers, the key is the "id" field of the basic InterfaceID of the managed components.

Definition at line 184 of file ApplicationMgr.h.


Constructor & Destructor Documentation

ApplicationMgr::ApplicationMgr ( IInterface = 0  ) 

Definition at line 44 of file ApplicationMgr.cpp.

00044                                          : base_class() {
00045   // IInterface initialization
00046   addRef(); // Initial count set to 1
00047 
00048   // Initialize two basic services: messagesvc & joboptions
00049   m_messageSvc        = 0;
00050   m_jobOptionsSvc     = 0;
00051 
00052   // Instantiate component managers
00053   m_managers[IService::interfaceID().id()] = new ServiceManager(this);
00054   m_managers[IAlgorithm::interfaceID().id()] = new AlgorithmManager(this);
00055 
00056   m_svcLocator = svcManager();
00057 
00058   // Instantiate internal services
00059   // SvcLocator/Factory HAS to be already instantiated
00060   m_classManager = new DLLClassManager(this);
00061   m_propertyMgr  = new PropertyMgr(this);
00062 
00063   m_name  = "ApplicationMgr";
00064   m_state = Gaudi::StateMachine::OFFLINE;
00065   m_targetState = Gaudi::StateMachine::OFFLINE;
00066 
00067   m_propertyMgr->declareProperty("Go",            m_SIGo = 0 );
00068   m_propertyMgr->declareProperty("Exit",          m_SIExit = 0 );
00069   m_propertyMgr->declareProperty("Dlls",          m_dllNameList );
00070   m_propertyMgr->declareProperty("ExtSvc",        m_extSvcNameList );
00071   m_propertyMgr->declareProperty("CreateSvc",     m_createSvcNameList );
00072   m_propertyMgr->declareProperty("ExtSvcCreates", m_extSvcCreates=true );
00073 
00074   m_propertyMgr->declareProperty("SvcMapping",    m_svcMapping );
00075   m_propertyMgr->declareProperty("SvcOptMapping", m_svcOptMapping );
00076 
00077   m_propertyMgr->declareProperty("TopAlg",        m_topAlgNameList );
00078   m_propertyMgr->declareProperty("OutStream",     m_outStreamNameList );
00079   m_propertyMgr->declareProperty("OutStreamType", m_outStreamType = "OutputStream" );
00080   m_propertyMgr->declareProperty("MessageSvcType",m_messageSvcType= "MessageSvc" );
00081   m_propertyMgr->declareProperty("JobOptionsSvcType",
00082                                  m_jobOptionsSvcType = "JobOptionsSvc" );
00083   m_propertyMgr->declareProperty( s_runable,      m_runableType   = "AppMgrRunable");
00084   m_propertyMgr->declareProperty( s_eventloop,    m_eventLoopMgr  = "EventLoopMgr");
00085 
00086   m_propertyMgr->declareProperty("HistogramPersistency", m_histPersName="NONE");
00087 
00088   // Declare Job Options Service properties and set default
00089   m_propertyMgr->declareProperty("JobOptionsType", m_jobOptionsType = "FILE");
00090   m_propertyMgr->declareProperty("JobOptionsPath", m_jobOptionsPath = "");
00091   m_propertyMgr->declareProperty("EvtMax",         m_evtMax = -1);
00092   m_propertyMgr->declareProperty("EvtSel",         m_evtsel );
00093   m_propertyMgr->declareProperty("OutputLevel",    m_outputLevel = MSG::INFO);
00094 
00095   m_propertyMgr->declareProperty("MultiThreadExtSvc", m_multiThreadSvcNameList);
00096   m_propertyMgr->declareProperty("NoOfThreads",    m_noOfEvtThreads = 0);
00097   m_propertyMgr->declareProperty("AppName",        m_appName = "ApplicationMgr");
00098   m_propertyMgr->declareProperty("AppVersion",     m_appVersion = "");
00099 
00100   m_propertyMgr->declareProperty("AuditTools",      m_auditTools = false);
00101   m_propertyMgr->declareProperty("AuditServices",   m_auditSvcs = false);
00102   m_propertyMgr->declareProperty("AuditAlgorithms", m_auditAlgs = false);
00103 
00104   m_propertyMgr->declareProperty("ActivateHistory", m_actHistory = false);
00105   m_propertyMgr->declareProperty("StatusCodeCheck", m_codeCheck = false);
00106 
00107   m_propertyMgr->declareProperty("Environment",    m_environment);
00108 
00109   // ServiceMgr Initialization loop checking
00110   m_propertyMgr->declareProperty("InitializationLoopCheck", m_loopCheck = true)
00111     ->declareUpdateHandler(&ApplicationMgr::initLoopCheckHndlr, this);
00112   svcManager()->setLoopCheckEnabled(m_loopCheck);
00113 
00114   // Flag to activate the printout of properties
00115   m_propertyMgr->declareProperty
00116     ( "PropertiesPrint",
00117       m_propertiesPrint = false,
00118       "Flag to activate the printout of properties" );
00119 
00120   m_propertyMgr->declareProperty("ReflexPluginDebugLevel", m_reflexDebugLevel = 0 );
00121 
00122   m_propertyMgr->declareProperty("StopOnSignal", m_stopOnSignal = false,
00123       "Flag to enable/disable the signal handler that schedule a stop of the event loop");
00124 
00125   m_propertyMgr->declareProperty("StalledEventMonitoring", m_stalledEventMonitoring = false,
00126       "Flag to enable/disable the monitoring and reporting of stalled events");
00127 
00128   m_propertyMgr->declareProperty("ReturnCode", m_returnCode = 0,
00129       "Return code of the application. Set internally in case of error conditions.");
00130 
00131   // Add action handlers to the appropriate properties
00132   m_SIGo.declareUpdateHandler  ( &ApplicationMgr::SIGoHandler         , this );
00133   m_SIExit.declareUpdateHandler( &ApplicationMgr::SIExitHandler       , this );
00134   m_topAlgNameList.declareUpdateHandler(&ApplicationMgr::evtLoopPropertyHandler, this);
00135   m_outStreamNameList.declareUpdateHandler(&ApplicationMgr::evtLoopPropertyHandler, this);
00136   m_outStreamType.declareUpdateHandler(&ApplicationMgr::evtLoopPropertyHandler, this);
00137   m_reflexDebugLevel.declareUpdateHandler(&ApplicationMgr::reflexDebugPropertyHandler, this);
00138   m_svcMapping.push_back("EvtDataSvc/EventDataSvc");
00139   m_svcMapping.push_back("DetDataSvc/DetectorDataSvc");
00140   m_svcMapping.push_back("HistogramSvc/HistogramDataSvc");
00141   m_svcMapping.push_back("HbookCnv::PersSvc/HbookHistSvc");
00142   m_svcMapping.push_back("RootHistCnv::PersSvc/RootHistSvc");
00143   m_svcMapping.push_back("EvtPersistencySvc/EventPersistencySvc");
00144   m_svcMapping.push_back("DetPersistencySvc/DetectorPersistencySvc");
00145   m_svcMapping.push_back("HistogramPersistencySvc/HistogramPersistencySvc");
00146 }

ApplicationMgr::~ApplicationMgr (  )  [virtual]

Definition at line 151 of file ApplicationMgr.cpp.

00151                                 {
00152   if( m_classManager ) m_classManager->release();
00153   if( m_propertyMgr ) m_propertyMgr->release();
00154   if( m_messageSvc ) m_messageSvc->release();
00155   if( m_jobOptionsSvc ) m_jobOptionsSvc->release();
00156 }


Member Function Documentation

StatusCode ApplicationMgr::queryInterface ( const InterfaceID iid,
void **  pinterface 
) [virtual]

Definition at line 162 of file ApplicationMgr.cpp.

00164 {
00165   if ( 0 == ppvi ) { return StatusCode::FAILURE ; }
00166 
00167   // try to find own/direct interfaces:
00168   StatusCode sc = base_class::queryInterface(iid,ppvi);
00169   if (sc.isSuccess()) return sc;
00170 
00171   // find indirect interfaces :
00172   if      ( ISvcLocator     ::interfaceID() . versionMatch ( iid ) )
00173   { return serviceLocator()-> queryInterface ( iid , ppvi ) ; }
00174   else if ( ISvcManager     ::interfaceID() . versionMatch ( iid ) )
00175   { return svcManager()    -> queryInterface ( iid , ppvi ) ; }
00176   else if ( IAlgManager     ::interfaceID() . versionMatch ( iid ) )
00177   { return algManager()    -> queryInterface ( iid , ppvi ) ; }
00178   else if ( IClassManager   ::interfaceID() . versionMatch ( iid ) )
00179   { return m_classManager  -> queryInterface ( iid , ppvi ) ; }
00180   else if ( IProperty       ::interfaceID() . versionMatch ( iid ) )
00181   { return m_propertyMgr   -> queryInterface ( iid , ppvi ) ; }
00182   else if ( IMessageSvc     ::interfaceID() . versionMatch ( iid ) )
00183   {
00184     *ppvi = reinterpret_cast<void*>(m_messageSvc.get());
00185     if (m_messageSvc) {
00186       m_messageSvc->addRef();
00187     }
00188     // Note that 0 can be a valid IMessageSvc pointer value (when used for
00189     // MsgStream).
00190     return StatusCode::SUCCESS;
00191   }
00192   *ppvi = 0;
00193   return StatusCode::FAILURE;
00194 }

StatusCode ApplicationMgr::run (  )  [virtual]

Definition at line 817 of file ApplicationMgr.cpp.

00817                                {
00818   StatusCode sc = StatusCode::SUCCESS;
00819 
00820   sc = GoToState(Gaudi::StateMachine::RUNNING);
00821   if ( sc.isSuccess() ) {
00822     MsgStream log(m_messageSvc, name());
00823     if ( m_runable != 0 ) { // loop over the events
00824       sc = m_runable->run();
00825       if ( !sc.isSuccess() ) {
00826         log << MSG::FATAL << "Application execution failed. Ending the job."
00827             << endmsg;
00828       }
00829     } else {
00830       log << MSG::FATAL << "Application has no runable object. Check option:"
00831           << s_runable << endmsg;
00832     }
00833   }
00834   if (sc.isSuccess()) { // try to close cleanly
00835     sc = GoToState(Gaudi::StateMachine::OFFLINE);
00836   }
00837   // either the runable failed of the stut-down
00838   if (sc.isFailure()) { // try to close anyway (but keep the StatusCode unchanged)
00839     GoToState(Gaudi::StateMachine::OFFLINE,true).ignore();
00840   }
00841   return sc;
00842 }

StatusCode ApplicationMgr::configure (  )  [virtual]

Definition at line 293 of file ApplicationMgr.cpp.

00293                                      {
00294   // Check if the state is compatible with the transition
00295   MsgStream tlog( m_messageSvc, name() );
00296   if( Gaudi::StateMachine::CONFIGURED == m_state ) {
00297     tlog << MSG::INFO << "Already Configured" << endmsg;
00298     return StatusCode::SUCCESS;
00299   }
00300   else if( Gaudi::StateMachine::OFFLINE != m_state ) {
00301     tlog << MSG::FATAL
00302          << "configure: Invalid state \""  << m_state << "\"" << endmsg;
00303     return StatusCode::FAILURE;
00304   }
00305   m_targetState = Gaudi::StateMachine::CONFIGURED;
00306 
00307   StatusCode  sc;
00308   sc = i_startup();
00309   if ( !sc.isSuccess() )    {
00310     return sc;
00311   }
00312 
00313   MsgStream log( m_messageSvc, name() );
00314 
00315   // Get my own options using the Job options service
00316   log << MSG::DEBUG << "Getting my own properties" << endmsg;
00317   sc = m_jobOptionsSvc->setMyProperties( name(), m_propertyMgr );
00318   if( !sc.isSuccess() ) {
00319     log << MSG::WARNING << "Problems getting my properties from JobOptionsSvc"
00320         << endmsg;
00321     return sc;
00322   }
00323 
00324   // Check current outputLevel to eventually inform the MessageSvc
00325   if( m_outputLevel != MSG::NIL && !m_appName.empty() ) {
00326     assert(m_messageSvc != 0);
00327     m_messageSvc->setOutputLevel( name(), m_outputLevel );
00328     // Print a welcome message
00329     log << MSG::ALWAYS
00330         << std::endl
00331         << "=================================================================="
00332         << "=================================================================="
00333         << std::endl
00334         << "                                "
00335         << "                   Welcome to " << m_appName;
00336 
00337     if( "" != m_appVersion ) {
00338       log << MSG::ALWAYS << " version " << m_appVersion;
00339     }
00340     else {
00341       log << MSG::ALWAYS << " $Revision: 1.77 $";
00342     }
00343 
00344     // Add the host name and current time to the message
00345     time_t t;
00346     std::time( &t );
00347     tm* localt = std::localtime( &t );
00348 
00349     log << MSG::ALWAYS
00350         << std::endl
00351         << "                                "
00352         << "          running on " << System::hostName()
00353         << " on " << std::asctime( localt )
00354         << "=================================================================="
00355         << "=================================================================="
00356         << endmsg;
00357   }
00358 
00359   // print all own properties if the options "PropertiesPrint" is set to true
00360   if ( m_propertiesPrint )
00361   {
00362     typedef std::vector<Property*> Properties;
00363     const Properties& properties = m_propertyMgr->getProperties() ;
00364     log << MSG::ALWAYS
00365         << "List of ALL properties of "
00366         << System::typeinfoName ( typeid( *this ) ) << "/" << this->name()
00367         << "  #properties = " << properties.size() << endmsg ;
00368     for ( Properties::const_iterator property = properties.begin() ;
00369           properties.end() != property ; ++property )
00370     { log << "Property ['Name': Value] = " << ( **property) << endmsg ; }
00371   }
00372 
00373   // Check if StatusCode need to be checked
00374   if (m_codeCheck) {
00375     StatusCode::enableChecking();
00376     sc = addMultiSvc("StatusCodeSvc", -9999);
00377     if ( sc.isFailure() ) {
00378       log << MSG::FATAL << "Error adding StatusCodeSvc for multiple threads" << endmsg;
00379       return StatusCode::FAILURE;
00380     }
00381   } else {
00382     StatusCode::disableChecking();
00383   }
00384 
00385   // set the requested environment variables
00386   std::map<std::string,std::string>::iterator var;
00387   for ( var = m_environment.begin(); var != m_environment.end(); ++var ) {
00388     const std::string &name  = var->first;
00389     const std::string &value = var->second;
00390     std::string old = System::getEnv(name.c_str());
00391     if ( !old.empty() && (old != "UNKNOWN" )) {
00392       log << MSG::WARNING;
00393     }
00394     else {
00395       log << MSG::DEBUG;
00396     }
00397     log << "Setting " << name << " = " << value << endmsg;
00398     System::setEnv(name,value);
00399   }
00400 
00401   //Declare Service Types
00402   VectorName::const_iterator j;
00403   for(j=m_svcMapping.begin(); j != m_svcMapping.end(); ++j)  {
00404     Gaudi::Utils::TypeNameString itm(*j);
00405     if ( declareMultiSvcType(itm.name(), itm.type()).isFailure() )  {
00406       log << MSG::ERROR << "configure: declaring svc type:'" << *j << "' failed." << endmsg;
00407       return StatusCode::FAILURE;
00408     }
00409   }
00410   for(j=m_svcOptMapping.begin(); j != m_svcOptMapping.end(); ++j)  {
00411     Gaudi::Utils::TypeNameString itm(*j);
00412     if ( declareMultiSvcType(itm.name(), itm.type()).isFailure() )  {
00413       log << MSG::ERROR << "configure: declaring svc type:'" << *j << "' failed." << endmsg;
00414       return StatusCode::FAILURE;
00415     }
00416   }
00417 
00418   //--------------------------------------------------------------------------
00419   // Declare other Services and Algorithms by loading DLL's
00420   sc = decodeDllNameList( );
00421   if ( sc.isFailure( ) ) {
00422     log << MSG::ERROR << "Failure loading declared DLL's" << endmsg;
00423     return sc;
00424   }
00425 
00426   //--------------------------------------------------------------------------
00427   // Deal with the services explicitely declared by the user.
00428   sc = decodeExtSvcNameList();
00429   if ( sc.isFailure( ) ) {
00430     log << MSG::ERROR << "Failure during external service association" << endmsg;
00431     return sc;
00432   }
00433 
00434   sc = decodeMultiThreadSvcNameList( );
00435   if ( sc.isFailure( ) ) {
00436     log << MSG::ERROR << "Failure during multi thread service creation"
00437         << endmsg;
00438     return sc;
00439   }
00440 
00441   sc = decodeCreateSvcNameList();
00442   if ( sc.isFailure( ) ) {
00443     log << MSG::ERROR << "Failure during external service creation" << endmsg;
00444     return sc;
00445   }
00446 
00447 
00448   //--------------------------------------------------------------------------
00449   // Retrieve intrinsic services. If needed configure them.
00450   //--------------------------------------------------------------------------
00451   Gaudi::Utils::TypeNameString evtloop_item(m_eventLoopMgr);
00452   sc = addMultiSvc(evtloop_item, 100);
00453   if( !sc.isSuccess() )  {
00454     log << MSG::FATAL << "Error adding :" << m_eventLoopMgr << endmsg;
00455     return sc;
00456   }
00457 
00458   if (m_noOfEvtThreads == 0) {
00459     m_runable = m_svcLocator->service(m_runableType);
00460     if( !m_runable.isValid() )  {
00461       log << MSG::FATAL
00462           << "Error retrieving Runable:" << m_runableType
00463           << "\n Check option ApplicationMgr." << s_runable << endmsg;
00464       return sc;
00465     }
00466     m_processingMgr = m_svcLocator->service(evtloop_item);
00467     if( !m_processingMgr.isValid() )  {
00468       log << MSG::FATAL
00469           << "Error retrieving Processing manager:" << m_eventLoopMgr
00470           << "\n Check option ApplicationMgr." << s_eventloop
00471           << "\n No events will be processed." << endmsg;
00472       return sc;
00473     }
00474   }
00475 
00476   // Establish Update Handlers for ExtSvc and DLLs Properties
00477   m_extSvcNameList.declareUpdateHandler (&ApplicationMgr::extSvcNameListHandler,
00478                                          this);
00479   m_createSvcNameList.declareUpdateHandler (&ApplicationMgr::createSvcNameListHandler,
00480                                          this);
00481   m_multiThreadSvcNameList.declareUpdateHandler
00482     (&ApplicationMgr::multiThreadSvcNameListHandler, this);
00483   m_dllNameList.declareUpdateHandler (&ApplicationMgr::dllNameListHandler,
00484                                       this );
00485 
00486   if (m_actHistory) {
00487     // Create HistorySvc with a priority to ensure it's initialized last, finalized first
00488     sc = svcManager()->addService("HistorySvc",std::numeric_limits<int>::max());
00489     if ( sc.isFailure() ) {
00490       log << MSG::FATAL << "Error adding HistorySvc" << endmsg;
00491       return StatusCode::FAILURE;
00492     }
00493 
00494     if (m_noOfEvtThreads > 0) {
00495       sc = addMultiSvc("HistorySvc",std::numeric_limits<int>::max());
00496       if ( sc.isFailure() ) {
00497         log << MSG::FATAL << "Error adding HistorySvc for multiple threads"
00498             << endmsg;
00499         return StatusCode::FAILURE;
00500       }
00501     }
00502   }
00503 
00504   log << MSG::INFO << "Application Manager Configured successfully" << endmsg;
00505   m_state = m_targetState;
00506   return StatusCode::SUCCESS;
00507 }

StatusCode ApplicationMgr::terminate (  )  [virtual]

Definition at line 696 of file ApplicationMgr.cpp.

00696                                      {
00697   MsgStream log( m_messageSvc, name() );
00698 
00699   if( m_state == Gaudi::StateMachine::OFFLINE ) {
00700     log << MSG::INFO << "Already Offline" << endmsg;
00701     return StatusCode::SUCCESS;
00702   }
00703   else if( m_state != Gaudi::StateMachine::CONFIGURED ) {
00704     log << MSG::FATAL << "terminate: Invalid state \"" << m_state << "\""
00705         << endmsg;
00706     return StatusCode::FAILURE;
00707   }
00708   // release all Services
00709   m_targetState = Gaudi::StateMachine::OFFLINE;
00710 
00711 
00712   log << MSG::INFO << "Application Manager Terminated successfully" << endmsg;
00713 
00714   { // Force a disable the auditing of finalize for MessageSvc
00715     SmartIF<IProperty> prop(m_messageSvc);
00716     if (prop.isValid()) {
00717       prop->setProperty(BooleanProperty("AuditFinalize", false));
00718     }
00719   }
00720   { // Force a disable the auditing of finalize for JobOptionsSvc
00721     SmartIF<IProperty> prop(m_jobOptionsSvc);
00722     if (prop.isValid()) {
00723       prop->setProperty(BooleanProperty("AuditFinalize", false));
00724     }
00725   }
00726 
00727   // finalize MessageSvc
00728   SmartIF<IService> svc(m_messageSvc);
00729   if ( !svc.isValid() ) {
00730     log << MSG::ERROR << "Could not get the IService interface of the MessageSvc" << endmsg;
00731   } else {
00732     svc->sysFinalize().ignore();
00733   }
00734 
00735   // finalize JobOptionsSvc
00736   svc = m_jobOptionsSvc;
00737   if ( !svc.isValid() ) {
00738     log << MSG::ERROR << "Could not get the IService interface of the JobOptionsSvc" << endmsg;
00739   } else {
00740     svc->sysFinalize().ignore();
00741   }
00742 
00743   m_state = m_targetState;
00744   return StatusCode::SUCCESS;
00745 }

StatusCode ApplicationMgr::initialize (  )  [virtual]

Definition at line 512 of file ApplicationMgr.cpp.

00512                                       {
00513 
00514   MsgStream log( m_messageSvc, name() );
00515   StatusCode sc;
00516 
00517   // I cannot add these services in configure() because they are coming from GaudiUtils
00518   // and it messes up genconf when rebuilding it.
00519   if (m_stopOnSignal) {
00520     // Instantiate the service that schedules a stop when a signal is received
00521     std::string svcname("Gaudi::Utils::StopSignalHandler");
00522     sc = svcManager()->addService(svcname);
00523     if ( sc.isFailure() ) {
00524       log << MSG::INFO << "Cannot instantiate " << svcname << "signals will be ignored" << endmsg;
00525     }
00526   }
00527 
00528   if (m_stalledEventMonitoring) {
00529     // Instantiate the service that schedules a stop when a signal is received
00530     std::string svcname("StalledEventMonitor");
00531     sc = svcManager()->addService(svcname);
00532     if ( sc.isFailure() ) {
00533       log << MSG::INFO << "Cannot instantiate " << svcname << "signals will be ignored" << endmsg;
00534     }
00535   }
00536 
00537   if( m_state == Gaudi::StateMachine::INITIALIZED ) {
00538     log << MSG::INFO << "Already Initialized!" << endmsg;
00539     return StatusCode::SUCCESS;
00540   }
00541   else if( m_state != Gaudi::StateMachine::CONFIGURED ) {
00542     log << MSG::FATAL
00543          << "initialize: Invalid state \""  << m_state << "\"" << endmsg;
00544     return StatusCode::FAILURE;
00545   }
00546   m_targetState = Gaudi::StateMachine::INITIALIZED;
00547 
00548   //--------------------------------------------------------------------------
00549   // Initialize the list of top Services
00550   //--------------------------------------------------------------------------
00551   sc = svcManager()->initialize();
00552   if( !sc.isSuccess() ) return sc;
00553 
00554   //--------------------------------------------------------------------------
00555   // Final steps: Inform user and change internal state
00556   //--------------------------------------------------------------------------
00557   log << MSG::INFO << "Application Manager Initialized successfully"  << endmsg;
00558   m_state = m_targetState;
00559 
00560   return sc;
00561 }

StatusCode ApplicationMgr::start (  )  [virtual]

Definition at line 566 of file ApplicationMgr.cpp.

00566                                  {
00567 
00568   MsgStream log( m_messageSvc, name() );
00569   StatusCode sc;
00570 
00571   if( m_state == Gaudi::StateMachine::RUNNING ) {
00572     log << MSG::INFO << "Already Initialized!" << endmsg;
00573     return StatusCode::SUCCESS;
00574   }
00575   else if( m_state != Gaudi::StateMachine::INITIALIZED ) {
00576     log << MSG::FATAL
00577          << "start: Invalid state \""  << m_state << "\"" << endmsg;
00578     return StatusCode::FAILURE;
00579   }
00580   m_targetState = Gaudi::StateMachine::RUNNING;
00581 
00582   //--------------------------------------------------------------------------
00583   // Initialize the list of top Services
00584   //--------------------------------------------------------------------------
00585   sc = svcManager()->start();
00586   if( !sc.isSuccess() ) return sc;
00587 
00588   //--------------------------------------------------------------------------
00589   // Final steps: Inform user and change internal state
00590   //--------------------------------------------------------------------------
00591   log << MSG::INFO << "Application Manager Started successfully"  << endmsg;
00592   m_state = m_targetState;
00593 
00594   return sc;
00595 }

StatusCode ApplicationMgr::stop (  )  [virtual]

Definition at line 619 of file ApplicationMgr.cpp.

00619                                 {
00620 
00621   MsgStream log( m_messageSvc, name() );
00622   StatusCode sc;
00623 
00624   if( m_state == Gaudi::StateMachine::INITIALIZED ) {
00625     log << MSG::INFO << "Already Initialized!" << endmsg;
00626     return StatusCode::SUCCESS;
00627   }
00628   else if( m_state != Gaudi::StateMachine::RUNNING ) {
00629     log << MSG::FATAL
00630          << "stop: Invalid state \""  << m_state << "\"" << endmsg;
00631     return StatusCode::FAILURE;
00632   }
00633   m_targetState = Gaudi::StateMachine::INITIALIZED;
00634 
00635   // Stop independently managed Algorithms
00636   sc = algManager()->stop();
00637   if( !sc.isSuccess() ) return sc;
00638 
00639   //--------------------------------------------------------------------------
00640   // Stop the list of top Services
00641   //--------------------------------------------------------------------------
00642   sc = svcManager()->stop();
00643   if( !sc.isSuccess() ) return sc;
00644 
00645   //--------------------------------------------------------------------------
00646   // Final steps: Inform user and change internal state
00647   //--------------------------------------------------------------------------
00648   log << MSG::INFO << "Application Manager Stopped successfully"  << endmsg;
00649   m_state = m_targetState;
00650 
00651   return sc;
00652 }

StatusCode ApplicationMgr::finalize ( void   )  [virtual]

Definition at line 657 of file ApplicationMgr.cpp.

00657                                     {
00658   MsgStream log( m_messageSvc, name() );
00659   if( m_state == Gaudi::StateMachine::CONFIGURED ) {
00660     log << MSG::INFO << "Already Finalized" << endmsg;
00661     return StatusCode::SUCCESS;
00662   }
00663   else if( m_state != Gaudi::StateMachine::INITIALIZED ) {
00664     log << MSG::FATAL << "finalize: Invalid state \"" << m_state << "\""
00665         << endmsg;
00666     return StatusCode::FAILURE;
00667   }
00668   m_targetState = Gaudi::StateMachine::CONFIGURED;
00669 
00670   // disable message suppression in finalize
00671   m_svcLocator->service<IProperty>("MessageSvc")->setProperty(BooleanProperty("enableSuppression", false)).ignore();
00672 
00673   // Finalize independently managed Algorithms
00674   StatusCode sc = algManager()->finalize();
00675 
00676 
00677   // Finalize all Services
00678   sc = svcManager()->finalize();
00679 
00680   //svcManager()->removeService( (IService*) m_processingMgr.get() );
00681   //svcManager()->removeService( (IService*) m_runable.get() );
00682 
00683   if (m_codeCheck) {
00684     StatusCode::disableChecking();
00685   }
00686 
00687   log << MSG::INFO << "Application Manager Finalized successfully" << endmsg;
00688 
00689   m_state = m_targetState;
00690   return sc;
00691 }

StatusCode ApplicationMgr::nextEvent ( int  maxevt  )  [virtual]

Definition at line 600 of file ApplicationMgr.cpp.

00600                                                   {
00601   if( m_state != Gaudi::StateMachine::RUNNING ) {
00602     MsgStream log( m_messageSvc, name() );
00603     log << MSG::FATAL << "nextEvent: Invalid state \"" << m_state << "\""
00604         << endmsg;
00605     return StatusCode::FAILURE;
00606   }
00607   if (!m_processingMgr.isValid())   {
00608     MsgStream log( m_messageSvc, name() );
00609     log << MSG::FATAL << "No event processing manager specified. Check option:"
00610         << s_eventloop << endmsg;
00611     return StatusCode::FAILURE;
00612   }
00613   return m_processingMgr->nextEvent(maxevt);
00614 }

const std::string & ApplicationMgr::name (  )  const [virtual]

This is needed to avoid ambiguous calls to name().

Implements CommonMessaging< implements4< IAppMgrUI, IEventProcessor, IService, IStateful > >.

Definition at line 893 of file ApplicationMgr.cpp.

00893                                             {
00894   return m_name;
00895 }

StatusCode ApplicationMgr::executeEvent ( void *  par  )  [virtual]

implementation of IEventProcessor::executeEvent(void*)

Definition at line 847 of file ApplicationMgr.cpp.

00847                                                     {
00848   MsgStream log( m_messageSvc, name() );
00849   if( m_state == Gaudi::StateMachine::RUNNING ) {
00850     if ( m_processingMgr.isValid() )    {
00851       return m_processingMgr->executeEvent(par);
00852     }
00853   }
00854   log << MSG::FATAL << "executeEvent: Invalid state \"" << FSMState() << "\""
00855       <<endmsg;
00856   return StatusCode::FAILURE;
00857 }

StatusCode ApplicationMgr::executeRun ( int  evtmax  )  [virtual]

implementation of IEventProcessor::executeRun(int)

Definition at line 862 of file ApplicationMgr.cpp.

00862                                                    {
00863   MsgStream log( m_messageSvc, name() );
00864   if( m_state == Gaudi::StateMachine::RUNNING ) {
00865     if ( m_processingMgr.isValid() )    {
00866       return m_processingMgr->executeRun(evtmax);
00867     }
00868     log << MSG::WARNING << "No EventLoop Manager specified " << endmsg;
00869     return StatusCode::SUCCESS;
00870   }
00871   log << MSG::FATAL << "executeRun: Invalid state \"" << FSMState() << "\""
00872       << endmsg;
00873   return StatusCode::FAILURE;
00874 }

StatusCode ApplicationMgr::stopRun (  )  [virtual]

implementation of IEventProcessor::stopRun()

Definition at line 879 of file ApplicationMgr.cpp.

00879                                       {
00880   MsgStream log( m_messageSvc, name() );
00881   if( m_state == Gaudi::StateMachine::RUNNING ) {
00882     if ( m_processingMgr.isValid() )    {
00883       return m_processingMgr->stopRun();
00884     }
00885     log << MSG::WARNING << "No EventLoop Manager specified " << endmsg;
00886     return StatusCode::SUCCESS;
00887   }
00888   log << MSG::FATAL << "stopRun: Invalid state \"" << FSMState() << "\""
00889       << endmsg;
00890   return StatusCode::FAILURE;
00891 }

Gaudi::StateMachine::State ApplicationMgr::FSMState (  )  const [virtual]

Definition at line 898 of file ApplicationMgr.cpp.

00898                                                        {
00899   return m_state;
00900 }

Gaudi::StateMachine::State ApplicationMgr::targetFSMState (  )  const [virtual]

Definition at line 902 of file ApplicationMgr.cpp.

00902                                                              {
00903   return m_targetState;
00904 }

StatusCode ApplicationMgr::reinitialize (  )  [virtual]

Definition at line 910 of file ApplicationMgr.cpp.

00910                                         {
00911   StatusCode retval = StatusCode::SUCCESS;
00912   StatusCode sc;
00913   if ( m_state < Gaudi::StateMachine::INITIALIZED ) {
00914     throw GaudiException("Cannot reinitialize application if not INITIALIZED or RUNNING",
00915                          "ApplicationMgr::reinitialize", StatusCode::FAILURE);
00916   }
00917   if ( m_state == Gaudi::StateMachine::RUNNING ) {
00918     retval = GoToState(Gaudi::StateMachine::INITIALIZED);
00919   }
00920   sc = svcManager()->reinitialize();
00921   if (sc.isFailure()) retval = sc;
00922   sc = algManager()->reinitialize();
00923   if (sc.isFailure()) retval = sc;
00924   return retval;
00925 }

StatusCode ApplicationMgr::restart (  )  [virtual]

Definition at line 930 of file ApplicationMgr.cpp.

00930                                    {
00931   StatusCode retval = StatusCode::SUCCESS;
00932   StatusCode sc;
00933   if ( m_state != Gaudi::StateMachine::RUNNING ) {
00934     throw GaudiException("Cannot restart application if not RUNNING",
00935                          "ApplicationMgr::restart", StatusCode::FAILURE);
00936   }
00937   sc = svcManager()->restart();
00938   if (sc.isFailure()) retval = sc;
00939   sc = algManager()->restart();
00940   if (sc.isFailure()) retval = sc;
00941   return retval;
00942 }

virtual StatusCode ApplicationMgr::sysInitialize (  )  [inline, virtual]

Definition at line 104 of file ApplicationMgr.h.

00104 { return StatusCode::SUCCESS; }

virtual StatusCode ApplicationMgr::sysStart (  )  [inline, virtual]

Definition at line 106 of file ApplicationMgr.h.

00106 { return StatusCode::SUCCESS; }

virtual StatusCode ApplicationMgr::sysStop (  )  [inline, virtual]

Definition at line 108 of file ApplicationMgr.h.

00108 { return StatusCode::SUCCESS; }

virtual StatusCode ApplicationMgr::sysFinalize (  )  [inline, virtual]

Definition at line 110 of file ApplicationMgr.h.

00110 { return StatusCode::SUCCESS; }

virtual StatusCode ApplicationMgr::sysReinitialize (  )  [inline, virtual]

Definition at line 112 of file ApplicationMgr.h.

00112 { return StatusCode::SUCCESS; }

virtual StatusCode ApplicationMgr::sysRestart (  )  [inline, virtual]

Definition at line 114 of file ApplicationMgr.h.

00114 { return StatusCode::SUCCESS; }

void ApplicationMgr::SIGoHandler ( Property theProp  ) 

Definition at line 947 of file ApplicationMgr.cpp.

00947                                             {
00948 
00949   MsgStream log (m_messageSvc, name());
00950   StatusCode sc;
00951 
00952   // Re-initialize everything
00953   sc = reinitialize();
00954   // Execute a number of events
00955   executeRun(m_evtMax);
00956 
00957   return;
00958 }

void ApplicationMgr::SIExitHandler ( Property theProp  ) 

Definition at line 963 of file ApplicationMgr.cpp.

00963                                               {
00964   StatusCode status;
00965   status = finalize();
00966   status = terminate();
00967   ::exit( 0 );
00968 }

void ApplicationMgr::evtLoopPropertyHandler ( Property theProp  ) 

Definition at line 973 of file ApplicationMgr.cpp.

00973                                                          {
00974   if ( m_processingMgr.isValid() )    {
00975     SmartIF<IProperty> props(m_processingMgr);
00976     if ( props.isValid() )    {
00977       props->setProperty( p ).ignore();
00978     }
00979   }
00980 }

StatusCode ApplicationMgr::decodeExtSvcNameList (  ) 

Definition at line 1029 of file ApplicationMgr.cpp.

01029                                                  {
01030   StatusCode result = StatusCode::SUCCESS;
01031 
01032   std::vector<std::string> theNames = m_extSvcNameList.value( );
01033 
01034   VectorName::const_iterator it(theNames.begin());
01035   VectorName::const_iterator et(theNames.end());
01036   while(result.isSuccess() && it != et) {
01037     Gaudi::Utils::TypeNameString item(*it++);
01038     if (m_extSvcCreates == true) {
01039       if ( (result = svcManager()->addService(item, 10)).isFailure()) {
01040         MsgStream log( m_messageSvc, m_name );
01041         log << MSG::ERROR << "decodeExtSvcNameList: Cannot create service "
01042             << item.type() << "/" << item.name() << endmsg;
01043       }
01044     } else {
01045       if( ( result = svcManager()->declareSvcType(item.name(),
01046                                                   item.type()) ).isFailure()) {
01047         MsgStream log( m_messageSvc, m_name );
01048         log << MSG::ERROR << "decodeExtSvcNameList: Cannot declare service "
01049             << item.type() << "/" << item.name() << endmsg;
01050       }
01051     }
01052   }
01053   return result;
01054 }

StatusCode ApplicationMgr::decodeCreateSvcNameList (  ) 

Definition at line 995 of file ApplicationMgr.cpp.

00995                                                    {
00996   StatusCode result = StatusCode::SUCCESS;
00997   const std::vector<std::string>& theNames = m_createSvcNameList.value( );
00998   VectorName::const_iterator it(theNames.begin());
00999   VectorName::const_iterator et(theNames.end());
01000   while(result.isSuccess() && it != et) {
01001     Gaudi::Utils::TypeNameString item(*it++);
01002     if( (result = svcManager()->addService(item, 10) ).isFailure()) {
01003       MsgStream log( m_messageSvc, m_name );
01004       log << MSG::ERROR << "decodeCreateSvcNameList: Cannot create service "
01005           << item.type() << "/" << item.name() << endmsg;
01006     } else {
01007       MsgStream log( m_messageSvc, m_name );
01008       log << MSG::DEBUG << "decodeCreateSvcNameList: Created service "
01009           << item.type() << "/" << item.name() << endmsg;
01010     }
01011   }
01012   return result;
01013 }

void ApplicationMgr::createSvcNameListHandler ( Property  ) 

Definition at line 985 of file ApplicationMgr.cpp.

00985                                                                        {
00986   if ( !(decodeCreateSvcNameList()).isSuccess() ) {
00987     throw GaudiException("Failed to create ext services",
00988                          "MinimalEventLoopMgr::createSvcNameListHandler",
00989                          StatusCode::FAILURE);
00990   }
00991 }

void ApplicationMgr::extSvcNameListHandler ( Property theProp  ) 

Definition at line 1018 of file ApplicationMgr.cpp.

01018                                                                     {
01019   if ( !(decodeExtSvcNameList( )).isSuccess() ) {
01020     throw GaudiException("Failed to declare ext services",
01021                          "MinimalEventLoopMgr::extSvcNameListHandler",
01022                          StatusCode::FAILURE);
01023   }
01024 }

StatusCode ApplicationMgr::decodeMultiThreadSvcNameList (  ) 

Definition at line 1071 of file ApplicationMgr.cpp.

01071                                                          {
01072   StatusCode result = StatusCode::SUCCESS;
01073   const std::vector<std::string>& theNames = m_multiThreadSvcNameList.value( );
01074   for(int iCopy=0; iCopy<m_noOfEvtThreads; ++iCopy) {
01075     for (VectorName::const_iterator it = theNames.begin();
01076          it != theNames.end();
01077          ++it) {
01078       Gaudi::Utils::TypeNameString item(*it);
01079       result = addMultiSvc(item, 10);
01080       //FIXME SHOULD CLONE?
01081       if( result.isFailure() ) {
01082         MsgStream log( m_messageSvc, m_name );
01083         log << MSG::ERROR
01084             << "decodeMultiThreadSvcNameList: Cannot create service "
01085             << item.type() << "/" << item.name() << endmsg;
01086       } else {
01087         MsgStream log( m_messageSvc, m_name );
01088         log << MSG::VERBOSE
01089             << "decodeMultiThreadSvcNameList: created service "
01090             << item.type() << "/" << item.name() << endmsg;
01091       }
01092     }
01093   }
01094   return result;
01095 }

void ApplicationMgr::multiThreadSvcNameListHandler ( Property theProp  ) 

Definition at line 1059 of file ApplicationMgr.cpp.

01059                                                                             {
01060   if ( !(decodeMultiThreadSvcNameList( )).isSuccess() ) {
01061     throw GaudiException("Failed to create copies of mt services",
01062                          "MinimalEventLoopMgr::multiThreadSvcNameListHandler",
01063                          StatusCode::FAILURE);
01064   }
01065 
01066 }

StatusCode ApplicationMgr::decodeDllNameList (  ) 

Definition at line 1176 of file ApplicationMgr.cpp.

01176                                              {
01177 
01178   MsgStream log( m_messageSvc, m_name );
01179   StatusCode result = StatusCode::SUCCESS;
01180 
01181   // Clean up multiple entries from DLL list
01182   // -------------------------------------------------------------------------
01183   std::vector<std::string> newList;
01184   std::map<std::string,unsigned int> dllInList, duplicateList;
01185   {for ( std::vector<std::string>::const_iterator it = m_dllNameList.value().begin();
01186         it != m_dllNameList.value().end(); ++it ) {
01187     if ( 0 == dllInList[*it] ) {
01188       newList.push_back(*it);        // first instance of this module
01189     } else { ++duplicateList[*it]; } // module listed multiple times
01190     ++dllInList[*it];                // increment count for this module
01191   }}
01192   //m_dllNameList = newList; // update primary list to new, filtered list (do not use the
01193                              // property itself otherwise we get called again infinitely)
01194   // List modules that were in there twice..
01195   if ( !duplicateList.empty() ) {
01196     log << MSG::DEBUG << "Removed duplicate entries for modules : ";
01197     for ( std::map<std::string,unsigned int>::const_iterator it = duplicateList.begin();
01198           it != duplicateList.end(); ++it ) {
01199       log << it->first << "(" << 1+it->second << ")";
01200       if ( it != --duplicateList.end() ) log << ", ";
01201     }
01202     log << endmsg;
01203   }
01204   // -------------------------------------------------------------------------
01205 
01206   const std::vector<std::string>& theNames = newList;
01207 
01208   // only load the new dlls or previously failed dlls
01209   log << MSG::DEBUG << "Loading declared DLL's" << endmsg;
01210 
01211   std::vector<std::string> successNames, failNames;
01212   std::vector<std::string>::const_iterator it;
01213 
01214   for (it = theNames.begin(); it != theNames.end(); it++) {
01215     if (std::find (m_okDlls.rbegin(), m_okDlls.rend(), *it) == m_okDlls.rend()){
01216       // found a new module name
01217       StatusCode status = m_classManager->loadModule( (*it) );
01218       if( status.isFailure() ) {
01219         failNames.push_back(*it);
01220         result = StatusCode::FAILURE;
01221       }
01222       else {
01223         successNames.push_back(*it);
01224       }
01225     }
01226   }
01227 
01228   // report back to the user and store the names of the succesfully loaded dlls
01229   if ( !successNames.empty() ) {
01230     log << MSG::INFO << "Successfully loaded modules : ";
01231     for (it = successNames.begin(); it != successNames.end(); it++) {
01232       log<< (*it);
01233       if( (it+1) != successNames.end())  log << ", ";
01234       // save name
01235       m_okDlls.push_back( *it );
01236     }
01237     log << endmsg;
01238   }
01239 
01240   if ( result == StatusCode::FAILURE ) {
01241     log << MSG::WARNING << "Failed to load modules: ";
01242     for (it = failNames.begin(); it != failNames.end(); it++) {
01243       log<< (*it);
01244       if( (it+1) != failNames.end())  log << ", ";
01245     }
01246     log << endmsg;
01247   }
01248   return result;
01249 }

void ApplicationMgr::dllNameListHandler ( Property theProp  ) 

Definition at line 1165 of file ApplicationMgr.cpp.

01165                                                                  {
01166   if ( !(decodeDllNameList( )).isSuccess() ) {
01167     throw GaudiException("Failed to load DLLs.",
01168                          "MinimalEventLoopMgr::dllNameListHandler",
01169                          StatusCode::FAILURE);
01170   }
01171 }

void ApplicationMgr::reflexDebugPropertyHandler ( Property theProp  ) 

Definition at line 1254 of file ApplicationMgr.cpp.

01255 {
01256   // Setup debug level for Reflex plugin system
01257   MsgStream log (m_messageSvc, name());
01258   log << MSG::INFO
01259       << "Updating ROOT::Reflex::PluginService::SetDebug(level) to level="
01260       << (int)m_reflexDebugLevel
01261       << endmsg;
01262   ROOT::Reflex::PluginService::SetDebug(m_reflexDebugLevel);
01263 }

void ApplicationMgr::initLoopCheckHndlr ( Property  ) 

Definition at line 1268 of file ApplicationMgr.cpp.

01268                                                  {
01269   svcManager()->setLoopCheckEnabled(m_loopCheck);
01270 }

template<class I>
SmartIF<IComponentManager>& ApplicationMgr::getManager (  )  [inline]

Definition at line 137 of file ApplicationMgr.h.

00137                                            {
00138     return m_managers[I::interfaceID().id()];
00139   }

SmartIF<ISvcManager>& ApplicationMgr::svcManager (  )  [inline]

Definition at line 141 of file ApplicationMgr.h.

00141                                             {
00142     // Cache the casted pointer to ISvcManager
00143     if (!m_svcManager) {
00144       m_svcManager = getManager<IService>();
00145     }
00146     return m_svcManager;
00147   }

SmartIF<IAlgManager>& ApplicationMgr::algManager (  )  [inline]

Definition at line 149 of file ApplicationMgr.h.

00149                                             {
00150     // Cache the casted pointer to IAlgManager
00151     if (!m_algManager) {
00152       m_algManager = getManager<IAlgorithm>();
00153     }
00154     return m_algManager;
00155   }

virtual SmartIF<ISvcLocator>& ApplicationMgr::serviceLocator (  )  const [inline, virtual]

Needed to locate the message service.

Implements CommonMessaging< implements4< IAppMgrUI, IEventProcessor, IService, IStateful > >.

Definition at line 158 of file ApplicationMgr.h.

00158                                                        {
00159     return m_svcLocator;
00160   }

StatusCode ApplicationMgr::declareMultiSvcType ( const std::string name,
const std::string type 
) [protected]

declare one or more copies of svc type/name as determined by NoOfThreads

Definition at line 1099 of file ApplicationMgr.cpp.

01100                                                                       {
01101   StatusCode result = StatusCode::SUCCESS;
01102   MsgStream log( m_messageSvc, m_name );
01103   if (0 == m_noOfEvtThreads) {
01104     result = svcManager()->declareSvcType(name, type);
01105     if( result.isFailure() ) {
01106       log << MSG::ERROR << "declareMultiSvcType: Cannot declare service "
01107           << type << "/" << name << endmsg;
01108     } else {
01109       log << MSG::VERBOSE << "declareMultiSvcType: declared service "
01110           << type << "/" << name << endmsg;
01111     }
01112   } else {
01113     for(int iCopy=0; iCopy<m_noOfEvtThreads; ++iCopy) {
01114       std::string thrName(name + getGaudiThreadIDfromID(iCopy));
01115       result = svcManager()->declareSvcType(thrName, type);
01116       if( result.isFailure() ) {
01117         log << MSG::ERROR << "declareMultiSvcType: Cannot declare service "
01118             << type << "/" << thrName << endmsg;
01119       } else {
01120         log << MSG::VERBOSE << "declareMultiSvcType: declared service "
01121             << type << "/" << thrName << endmsg;
01122       }
01123     }
01124   }
01125   return result;
01126 }

StatusCode ApplicationMgr::addMultiSvc ( const Gaudi::Utils::TypeNameString &  typeName,
int  prio 
) [protected]

add one or more copies of svc type/name as determined by NoOfThreads

Definition at line 1130 of file ApplicationMgr.cpp.

01131                                                  {
01132   using Gaudi::Utils::TypeNameString;
01133   StatusCode result = StatusCode::SUCCESS;
01134   MsgStream log( m_messageSvc, m_name );
01135   if (0 == m_noOfEvtThreads) {
01136     result = svcManager()->addService(typeName, prio);
01137     // result = svcManager()->addService(name, type, prio); // CHECKME???
01138     if( result.isFailure() ) {
01139       log << MSG::ERROR << "addMultiSvc: Cannot add service "
01140           << typeName.type() << "/" << typeName.name() << endmsg;
01141     } else {
01142       log << MSG::VERBOSE << "addMultiSvc: added service "
01143           << typeName.type() << "/" << typeName.name() << endmsg;
01144     }
01145   } else {
01146     for(int iCopy=0; iCopy<m_noOfEvtThreads; ++iCopy) {
01147       const std::string &type = typeName.type();
01148       std::string thrName(typeName.name() + getGaudiThreadIDfromID(iCopy));
01149       result = svcManager()->addService(TypeNameString(thrName, type), prio);
01150       if( result.isFailure() ) {
01151         log << MSG::ERROR << "addMultiSvc: Cannot add service "
01152             << type << "/" << thrName << endmsg;
01153       } else {
01154         log << MSG::VERBOSE << "addMultiSvc: added service "
01155             << type << "/" << thrName << endmsg;
01156       }
01157     }
01158   }
01159   return result;
01160 }

void ApplicationMgr::setServiceManager ( ISvcManager  )  [inline, protected]

Definition at line 171 of file ApplicationMgr.h.

00171 {}

StatusCode ApplicationMgr::i_startup (  )  [protected]

Internal startup routine.

Definition at line 199 of file ApplicationMgr.cpp.

00199                                      {
00200   StatusCode  sc;
00201 
00202   // declare factories in current module
00203   m_classManager->loadModule("").ignore();
00204 
00205   // Create the Message service
00206   SmartIF<IService> msgsvc = svcManager()->createService(Gaudi::Utils::TypeNameString("MessageSvc", m_messageSvcType));
00207   if( !msgsvc.isValid() )  {
00208     fatal() << "Error creating MessageSvc of type " << m_messageSvcType << endmsg;
00209     return sc;
00210   }
00211   // Create the Job Options service
00212   SmartIF<IService> jobsvc = svcManager()->createService(Gaudi::Utils::TypeNameString("JobOptionsSvc", m_jobOptionsSvcType));
00213   if( !jobsvc.isValid() )   {
00214     fatal() << "Error creating JobOptionsSvc" << endmsg;
00215     return sc;
00216   }
00217 
00218   SmartIF<IProperty> jobOptsIProp(jobsvc);
00219   if ( !jobOptsIProp.isValid() )   {
00220     fatal() << "Error locating JobOptionsSvc" << endmsg;
00221     return sc;
00222   }
00223   sc = jobOptsIProp->setProperty( StringProperty("TYPE", m_jobOptionsType) );
00224   if( !sc.isSuccess() )   {
00225     fatal() << "Error setting TYPE option in JobOptionsSvc" << endmsg;
00226     return sc;
00227   }
00228 
00229   if ( m_jobOptionsPath != "") {         // The command line takes precedence
00230     sc = jobOptsIProp->setProperty( StringProperty("PATH", m_jobOptionsPath) );
00231     if( !sc.isSuccess() )   {
00232       fatal() << "Error setting PATH option in JobOptionsSvc" << endmsg;
00233       return sc;
00234     }
00235   }
00236   else if ( 0 != getenv("JOBOPTPATH") ) {// Otherwise the Environment JOBOPTPATH
00237     sc = jobOptsIProp->setProperty (StringProperty("PATH",
00238                                                    getenv("JOBOPTPATH")));
00239     if( !sc.isSuccess() )   {
00240       fatal()
00241            << "Error setting PATH option in JobOptionsSvc from env"
00242            << endmsg;
00243       return sc;
00244     }
00245   }
00246   else {                                   // Otherwise the default
00247     sc = jobOptsIProp->setProperty (StringProperty("PATH",
00248                                                    "../options/job.opts"));
00249     if( !sc.isSuccess() )   {
00250       fatal()
00251            << "Error setting PATH option in JobOptionsSvc to default"
00252            << endmsg;
00253       return sc;
00254     }
00255   }
00256   jobOptsIProp->release();
00257 
00258   // Sets my default the Output Level of the Message service to be
00259   // the same as this
00260   SmartIF<IProperty> msgSvcIProp(msgsvc);
00261   msgSvcIProp->setProperty( IntegerProperty("OutputLevel", m_outputLevel)).ignore();
00262   msgSvcIProp->release();
00263 
00264   sc = jobsvc->sysInitialize();
00265   if( !sc.isSuccess() )   {
00266     fatal() << "Error initializing JobOptionsSvc" << endmsg;
00267     return sc;
00268   }
00269   sc = msgsvc->sysInitialize();
00270   if( !sc.isSuccess() )  {
00271     fatal() << "Error initializing MessageSvc" << endmsg;
00272     return sc;
00273   }
00274 
00275   // Get the useful interface from Message anf JobOptions services
00276   m_messageSvc = m_svcLocator->service("MessageSvc");
00277   if( !m_messageSvc.isValid() )  {
00278     fatal() << "Error retrieving MessageSvc." << endmsg;
00279     return sc;
00280   }
00281   m_jobOptionsSvc = m_svcLocator->service("JobOptionsSvc");
00282   if( !m_jobOptionsSvc.isValid() )  {
00283     fatal() << "Error retrieving JobOptionsSvc." << endmsg;
00284     return sc;
00285   }
00286 
00287   return sc;
00288 }

StatusCode ApplicationMgr::GoToState ( Gaudi::StateMachine::State  state,
bool  ignoreFailures = false 
) [protected]

Reach a state from current state (whichever it is) going through the correct transitions.

By default, if a transition fails, the chain is interrupted, but the behavior can be changed with the parameter "gnoreFailures"

Definition at line 750 of file ApplicationMgr.cpp.

00750                                                                                       {
00751   StatusCode sc = StatusCode(StatusCode::SUCCESS,true);
00752 
00753   switch (state) {
00754 
00755   case Gaudi::StateMachine::OFFLINE:
00756     switch (m_state) {
00757     case Gaudi::StateMachine::OFFLINE    : return StatusCode::SUCCESS; break;
00758     case Gaudi::StateMachine::CONFIGURED : return terminate(); break;
00759     default: // Gaudi::StateMachine::INITIALIZED or Gaudi::StateMachine::RUNNING
00760       sc = GoToState(Gaudi::StateMachine::CONFIGURED);
00761       if (sc.isSuccess()) {
00762         return terminate();
00763       } break;
00764     } break;
00765 
00766   case Gaudi::StateMachine::CONFIGURED:
00767     switch (m_state) {
00768     case Gaudi::StateMachine::CONFIGURED  : return StatusCode::SUCCESS; break;
00769     case Gaudi::StateMachine::OFFLINE     : return configure(); break;
00770     case Gaudi::StateMachine::INITIALIZED : return finalize(); break;
00771     default: // Gaudi::StateMachine::RUNNING
00772       sc = GoToState(Gaudi::StateMachine::INITIALIZED);
00773       if (sc.isSuccess()) {
00774         return finalize();
00775       } break;
00776     } break;
00777 
00778   case Gaudi::StateMachine::INITIALIZED:
00779     switch (m_state) {
00780     case Gaudi::StateMachine::INITIALIZED : return StatusCode::SUCCESS; break;
00781     case Gaudi::StateMachine::CONFIGURED  : return initialize(); break;
00782     case Gaudi::StateMachine::RUNNING     : return stop(); break;
00783     default: // Gaudi::StateMachine::OFFLINE
00784       sc = GoToState(Gaudi::StateMachine::CONFIGURED);
00785       if (sc.isSuccess()) {
00786         return initialize();
00787       } break;
00788     } break;
00789 
00790   case Gaudi::StateMachine::RUNNING:
00791     switch (m_state) {
00792     case Gaudi::StateMachine::RUNNING     : return StatusCode::SUCCESS; break;
00793     case Gaudi::StateMachine::INITIALIZED : return start(); break;
00794     default: // Gaudi::StateMachine::OFFLINE or Gaudi::StateMachine::CONFIGURED
00795       sc = GoToState(Gaudi::StateMachine::INITIALIZED);
00796       if (sc.isSuccess()) {
00797         return start();
00798       } break;
00799     } break;
00800 
00801   }
00802 
00803   // If I get here, there has been a problem in the recursion
00804 
00805   if (ignoreFailures){
00806     // force the new state
00807     m_state = state;
00808     return StatusCode::SUCCESS;
00809   }
00810 
00811   return sc;
00812 }


Member Data Documentation

Map of known component managers.

It contains (at least) the managers for IService and IAlgorithm. IAlgTool and IAuditor are not mandatory (but a missing manager for IAlgTool will probably not allow any job to run).

Definition at line 188 of file ApplicationMgr.h.

Property to declare the list of known managers.

Definition at line 190 of file ApplicationMgr.h.

Cached pointer to the manager of services.

Definition at line 193 of file ApplicationMgr.h.

Cached pointer to the manager of algorithms.

Definition at line 196 of file ApplicationMgr.h.

Reference to the class manager.

Definition at line 200 of file ApplicationMgr.h.

Reference to its own service locator.

Definition at line 201 of file ApplicationMgr.h.

For SI's "Go" command via callback.

Definition at line 203 of file ApplicationMgr.h.

For SI's "Exit" command via callback.

Definition at line 204 of file ApplicationMgr.h.

List of top level algorithms names.

Definition at line 205 of file ApplicationMgr.h.

List of output stream names.

Definition at line 206 of file ApplicationMgr.h.

Output stream type (obsolete?).

Definition at line 207 of file ApplicationMgr.h.

MessageSvc type.

Definition at line 208 of file ApplicationMgr.h.

JobOptionsSvc type.

Definition at line 209 of file ApplicationMgr.h.

List of top level services.

Definition at line 212 of file ApplicationMgr.h.

List of top level services names.

Definition at line 213 of file ApplicationMgr.h.

Name.

Definition at line 215 of file ApplicationMgr.h.

Internal State.

Definition at line 216 of file ApplicationMgr.h.

Internal State.

Definition at line 217 of file ApplicationMgr.h.

Vector default services names.

Definition at line 219 of file ApplicationMgr.h.

Default mapping of services.

Definition at line 220 of file ApplicationMgr.h.

Default mapping of services.

Definition at line 221 of file ApplicationMgr.h.

Reference to Property Manager.

Definition at line 223 of file ApplicationMgr.h.

Reference to the message service.

Definition at line 224 of file ApplicationMgr.h.

Reference to the runable object.

Definition at line 225 of file ApplicationMgr.h.

Reference to processing manager object.

Definition at line 226 of file ApplicationMgr.h.

Reference to JobOption service.

Definition at line 227 of file ApplicationMgr.h.

int ApplicationMgr::m_evtMax [protected]

Number of events to be processed.

Definition at line 233 of file ApplicationMgr.h.

List of external services names.

Definition at line 234 of file ApplicationMgr.h.

LHCb or ATLAS defn of "ExtSvc".

Definition at line 235 of file ApplicationMgr.h.

List of external services names for which we want a copy per evt thread.

Definition at line 238 of file ApplicationMgr.h.

no of multiThreadSvc copies

Definition at line 239 of file ApplicationMgr.h.

List of DDL's names.

Definition at line 241 of file ApplicationMgr.h.

Source type (e.g. dbase, file...).

Definition at line 242 of file ApplicationMgr.h.

The "file" to look for properties.

Definition at line 243 of file ApplicationMgr.h.

Runable type.

Definition at line 244 of file ApplicationMgr.h.

Processing manager type.

Definition at line 245 of file ApplicationMgr.h.

Event selection.

Definition at line 246 of file ApplicationMgr.h.

CGL: Name of the Hist Pers Svc.

Definition at line 247 of file ApplicationMgr.h.

Message output level.

Definition at line 248 of file ApplicationMgr.h.

The name of the application.

Definition at line 249 of file ApplicationMgr.h.

The version of the application.

Definition at line 250 of file ApplicationMgr.h.

Activate HistorySvc.

Definition at line 251 of file ApplicationMgr.h.

Activate StatusCode checking.

Definition at line 252 of file ApplicationMgr.h.

Debug level for the reflex plugin system.

Definition at line 253 of file ApplicationMgr.h.

Definition at line 255 of file ApplicationMgr.h.

Defaults for auditors.

Definition at line 258 of file ApplicationMgr.h.

Definition at line 259 of file ApplicationMgr.h.

Definition at line 260 of file ApplicationMgr.h.

Environment variables to set.

Definition at line 262 of file ApplicationMgr.h.

For ServiceMgr initialization loop checking.

Definition at line 265 of file ApplicationMgr.h.

Property to enable/disable the "stop on signal" service (enabled by default).

See also:
Gaudi::Utils::StopSignalHandler

Definition at line 269 of file ApplicationMgr.h.

Property to enable/disable the monitoring and reporting of stalled events (enabled by default).

See also:
StalledEventMonitor

Definition at line 273 of file ApplicationMgr.h.

flag to activate the printout of properties

Definition at line 276 of file ApplicationMgr.h.

Property to record the error conditions occurring during the running.

Definition at line 279 of file ApplicationMgr.h.

names of successfully loaded dlls

Definition at line 282 of file ApplicationMgr.h.


The documentation for this class was generated from the following files:

Generated at Mon May 3 12:23:40 2010 for Gaudi Framework, version v21r9 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004