The Gaudi Framework  v32r0 (3325bb39)
ApplicationMgr.h
Go to the documentation of this file.
1 #ifndef GAUDI_APPLICATIONMGR_H
2 #define GAUDI_APPLICATIONMGR_H
3 
12 #include <GaudiKernel/IProperty.h>
13 #include <GaudiKernel/IStateful.h>
15 #include <GaudiKernel/Kernel.h>
17 #include <GaudiKernel/Service.h>
18 #include <vector>
19 
20 // Forward declarations
21 class ISvcLocator;
22 class ServiceManager;
23 class AlgorithmManager;
24 class DLLClassManager;
25 
26 class IMessageSvc;
27 class IIncidentSvc;
28 class IRunable;
29 class IDataManagerSvc;
30 class IConversionSvc;
31 class IJobOptionsSvc;
32 
46  : public PropertyHolder<CommonMessaging<implements<IAppMgrUI, Gaudi::Interfaces::IAsyncEventProcessor, IService,
47  IStateful, INamedInterface, IProperty>>> {
48 public:
49  // default creator
50  ApplicationMgr( IInterface* = nullptr );
51 
52  // implementation of IInterface::queryInterface
53  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
54 
55  // implementation of IAppMgrUI::run
56  StatusCode run() override;
57  // implementation of IAppMgrUI::configure
58  StatusCode configure() override;
59  // implementation of IAppMgrUI::terminate
60  StatusCode terminate() override;
61  // implementation of IAppMgrUI::initialize
62  StatusCode initialize() override;
63  // implementation of IAppMgrUI::start
64  StatusCode start() override;
65  // implementation of IAppMgrUI::stop
66  StatusCode stop() override;
67  // implementation of IAppMgrUI::finalize
68  StatusCode finalize() override;
69  // implementation of IAppMgrUI::nextEvent
70  StatusCode nextEvent( int maxevt ) override;
71  // implementation of IAppMgrUI::name
72  const std::string& name() const override;
76  StatusCode executeEvent( EventContext&& ctx ) override;
78  StatusCode executeRun( int evtmax ) override;
80  StatusCode stopRun() override;
81 
82  // implementation of IStateful::state
83  Gaudi::StateMachine::State FSMState() const override;
84  // implementation of IStateful::targetState
86  // implementation of IStateful::reinitialize
87  StatusCode reinitialize() override;
88  // implementation of IStateful::reinitialize
89  StatusCode restart() override;
90  // implementation of IService::sysItinitilaize
92  // implementation of IService::sysStart
93  StatusCode sysStart() override { return StatusCode::SUCCESS; }
94  // implementation of IService::sysStop
95  StatusCode sysStop() override { return StatusCode::SUCCESS; }
96  // implementation of IService::sysFinalize
98  // implementation of IService::sysReinitialize
100  // implementation of IService::sysRestart
102 
104 
106 
116 
117  template <class I>
119  return m_managers[I::interfaceID().id()];
120  }
121 
123  // Cache the casted pointer to ISvcManager
124  if ( !m_svcManager ) { m_svcManager = getManager<IService>(); }
125  return m_svcManager;
126  }
127 
129  // Cache the casted pointer to IAlgManager
130  if ( !m_algManager ) { m_algManager = getManager<IAlgorithm>(); }
131  return m_algManager;
132  }
133 
135  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
136 
138  void outputLevelUpdate() override;
139 
141  void printAlgsSequences();
142 
143 protected:
144  // implementation of IService::setServiceManager
145  void setServiceManager( ISvcManager* ) override {}
146 
149 
154  StatusCode GoToState( Gaudi::StateMachine::State state, bool ignoreFailures = false );
155 
162  ManagersMap m_managers;
165 
168 
171 
172  // data members
176 
178  [this]( auto& ) {
179  // Re-initialize everything
180  this->reinitialize().ignore();
181  // Execute a number of events
182  this->executeRun( m_evtMax ).ignore();
183  },
184  "For SI's \"Go\" command via callback"};
186  [this]( auto& ) {
187  finalize().ignore();
188  terminate().ignore();
189  ::exit( 0 );
190  },
191  "For SI's \"Exit\" command via callback"};
193  this, "TopAlg", {}, &ApplicationMgr::evtLoopPropertyHandler, "List of top level algorithms names"};
195  this, "OutStream", {}, &ApplicationMgr::evtLoopPropertyHandler, "List of output stream names"};
196  Gaudi::Property<std::string> m_outStreamType{this, "OutStreamType", "OutputStream",
198  "[[deprecated]] Output stream type"};
199  Gaudi::Property<std::string> m_messageSvcType{this, "MessageSvcType", "MessageSvc", "MessageSvc type"};
200  Gaudi::Property<std::string> m_jobOptionsSvcType{this, "JobOptionsSvcType", "JobOptionsSvc", "JobOptionsSvc type"};
201 
202  std::string m_name = "ApplicationMgr";
205 
206  Gaudi::Property<std::vector<std::string>> m_svcMapping{this, "SvcMapping", {}, "Default mapping of services"};
208  this, "SvcOptMapping", {}, "Default mapping of optional services"};
209 
214 
216  //
217  // The public ApplicationMgr properties
218  //
219 
220  Gaudi::Property<int> m_evtMax{this, "EvtMax", -1, "Number of events to be processed (-1 means all events)"};
221  Gaudi::Property<std::vector<std::string>> m_extSvcNameList{this, "ExtSvc", {}, "List of external services names"};
222  Gaudi::Property<bool> m_extSvcCreates{this, "ExtSvcCreates", true,
223  "LHCb (default) or ATLAS definition of \"ExtSvc\""};
224 
225  Gaudi::Property<std::vector<std::string>> m_dllNameList{this, "Dlls", {}, "List of DDL's names"};
226  Gaudi::Property<std::string> m_jobOptionsType{this, "JobOptionsType", "FILE", "Source type (e.g. dbase, file...)"};
227  Gaudi::Property<std::string> m_jobOptionsPath{this, "JobOptionsPath", {}, "The \"file\" to look for properties"};
229  this, "JobOptionsPostAction", {}, "additional command to run on config"};
231  this, "JobOptionsPreAction", {}, "additional command to run on config"};
232  Gaudi::Property<std::string> m_runableType{this, "Runable", "AppMgrRunable", "Runable type"};
233  Gaudi::Property<std::string> m_eventLoopMgr{this, "EventLoop", "EventLoopMgr", "Processing manager type"};
234  Gaudi::Property<std::string> m_evtsel{this, "EvtSel", {}, "Event selection"};
235  Gaudi::Property<std::string> m_histPersName{this, "HistogramPersistency", "NONE", "Name of the Hist Pers Svc"};
236  Gaudi::Property<int> m_outputLevel{this, "OutputLevel", MSG::INFO, "Message output level"};
237  Gaudi::Property<std::string> m_appName{this, "AppName", "ApplicationMgr", "The name of the application"};
238  Gaudi::Property<std::string> m_appVersion{this, "AppVersion", {}, "The version of the application"};
239  Gaudi::Property<bool> m_actHistory{this, "ActivateHistory", false, "Activate HistorySvc"};
240  Gaudi::Property<bool> m_codeCheck{this, "StatusCodeCheck", false, "Activate StatusCode checking"};
242  this, "PluginDebugLevel", 0,
243  [this]( auto& ) {
244  // Setup debug level for the plugin system
245  MsgStream log( m_messageSvc, this->name() );
246  log << MSG::INFO << "Updating Gaudi::PluginService::SetDebug(level) to level=" << m_pluginDebugLevel << endmsg;
248  },
249  "Debug level for the plugin system"};
250 
252  this, "CreateSvc", {}, "List of extra services to be created"};
253 
255  Gaudi::Property<bool> m_auditTools{this, "AuditTools", false};
256  Gaudi::Property<bool> m_auditSvcs{this, "AuditServices", false};
257  Gaudi::Property<bool> m_auditAlgs{this, "AuditAlgorithms", false};
258 
260  this, "Environment", {}, "Environment variables to set"};
261 
262  Gaudi::Property<bool> m_loopCheck{this, "InitializationLoopCheck", true,
263  [this]( auto& ) { this->svcManager()->setLoopCheckEnabled( m_loopCheck ); },
264  "For ServiceMgr initialization loop checking"};
265 
269  this, "StopOnSignal", false, "Flag to enable/disable the signal handler that schedule a stop of the event loop"};
270 
274  this, "StalledEventMonitoring", false, "Flag to enable/disable the monitoring and reporting of stalled events"};
275 
276  Gaudi::Property<bool> m_propertiesPrint{this, "PropertiesPrint", false,
277  "Flag to activate the printout of properties"};
278 
281  "Return code of the application. Set internally in case of error conditions."};
282 
283  Gaudi::Property<bool> m_printAlgsSequence{this, "PrintAlgsSequence", false,
284  "Print the sequence of algorithms that have been loaded."};
285 
286  // For concurrency
288 
289 private:
291 };
292 #endif // GAUDI_APPLICATIONMGR_H
The ServiceManager class is in charge of the creation of concrete instances of Services.
Gaudi::StateMachine::State m_targetState
Internal State.
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
StatusCode initialize() override
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi::Property< bool > m_propertiesPrint
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
StatusCode decodeDllNameList()
Gaudi::Property< bool > m_printAlgsSequence
Gaudi::Property< int > m_returnCode
Property to record the error conditions occurring during the running.
Gaudi::Property< bool > m_stopOnSignal
Property to enable/disable the "stop on signal" service.
Gaudi::Property< bool > m_auditSvcs
Gaudi::Property< bool > m_codeCheck
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 ...
Gaudi::Property< int > m_evtMax
SmartIF< IRunable > m_runable
Reference to the runable object.
Implementation of property with value of concrete type.
Definition: Property.h:352
The ISvcManager is the interface implemented by the Service Factory in the Application Manager to sup...
Definition: ISvcManager.h:28
ManagersMap m_managers
Map of known component managers.
StatusCode sysStart() override
Gaudi::Property< std::string > m_outStreamType
Gaudi::Property< std::string > m_jobOptionsType
const std::string & name() const override
Gaudi::Property< int > m_SIGo
Gaudi::Property< std::map< std::string, std::string > > m_environment
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
Gaudi::Property< bool > m_auditAlgs
Gaudi::Property< std::string > m_appVersion
std::vector< std::string > m_okDlls
names of successfully loaded dlls
StatusCode sysRestart() override
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
Definition: StateMachine.h:12
StatusCode sysFinalize() override
StatusCode nextEvent(int maxevt) override
SmartIF< IJobOptionsSvc > m_jobOptionsSvc
Reference to JobOption service.
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
void createSvcNameListHandler(Gaudi::Details::PropertyBase &)
STL class.
Gaudi::Property< std::vector< std::string > > m_outStreamNameList
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
StatusCode terminate() override
SmartIF< ISvcManager > & svcManager()
SmartIF< IComponentManager > & getManager()
Gaudi::Property< std::string > m_eventLoopMgr
STL class.
Gaudi::Property< std::string > m_evtsel
StatusCode sysReinitialize() override
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
Interface ID class.
Definition: IInterface.h:29
Gaudi::Property< int > m_outputLevel
Main interface for the JobOptions service.
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
Gaudi::Property< std::vector< std::string > > m_topAlgNameList
Gaudi::StateMachine::State targetFSMState() const override
void extSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
SmartIF< ISvcLocator > m_svcLocator
Reference to its own service locator (must be instantiated prior to any service!) ...
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Definition of the basic interface.
Definition: IInterface.h:244
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void*)
Gaudi::Property< std::string > m_runableType
Gaudi::Property< std::vector< std::string > > m_declaredManagers
Property to declare the list of known managers.
std::future< std::tuple< StatusCode, EventContext > > asyncExecuteEvent(EventContext &&ctx) override
StatusCode sysStop() override
Gaudi::Property< int > m_SIExit
SmartIF< IAsyncEventProcessor > m_asyncProcessor
Reference to an asynchronous processing manager object.
Gaudi::Property< bool > m_stalledEventMonitoring
Property to enable/disable the monitoring and reporting of stalled events.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
SmartIF< ISvcManager > m_svcManager
Cached pointer to the manager of services.
StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures=false)
Reach a state from current state (whichever it is) going through the correct transitions.
StatusCode finalize() override
Gaudi::Property< std::vector< std::string > > m_svcOptMapping
Gaudi::Property< std::string > m_jobOptionsPreAction
Gaudi::Property< std::vector< std::string > > m_svcMapping
Gaudi::Property< std::vector< std::string > > m_dllNameList
The Application Manager class.
Gaudi::Property< bool > m_actHistory
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
StatusCode decodeExtSvcNameList()
Gaudi::Property< bool > m_extSvcCreates
Gaudi::Property< bool > m_auditTools
Defaults for auditors.
SmartIF< DLLClassManager > m_classManager
Reference to the class manager.
Gaudi::Property< std::string > m_jobOptionsSvcType
StatusCode start() override
Gaudi::Property< std::vector< std::string > > m_createSvcNameList
StatusCode restart() override
StatusCode configure() override
ApplicationMgr(IInterface *=nullptr)
void pluginDebugPropertyHandler(Gaudi::Details::PropertyBase &theProp)
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
StatusCode decodeCreateSvcNameList()
void printAlgsSequences()
Print the sequence of algorithms that have been loaded.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
Gaudi::Property< std::string > m_jobOptionsPostAction
Runable interface definition.
Definition: IRunable.h:18
Helper class to implement the IProperty interface.
SmartIF< IAlgManager > m_algManager
Cached pointer to the manager of algorithms.
StatusCode i_startup()
Internal startup routine.
StatusCode stop() override
std::string m_name
Name.
Gaudi::Property< std::string > m_messageSvcType
StatusCode reinitialize() override
Gaudi::StateMachine::State m_state
Internal State.
Gaudi::Property< std::string > m_appName
Gaudi::StateMachine::State FSMState() const override
Gaudi::Property< std::string > m_histPersName
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
virtual void setLoopCheckEnabled(bool en=true)=0
Set the value of the initialization loop check flag.
constexpr int Success
Definition: AppReturnCode.h:16
StatusCode run() override
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
SmartIF< IAlgManager > & algManager()
void setServiceManager(ISvcManager *) override
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
StatusCode sysInitialize() override
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Property< int > m_pluginDebugLevel
Gaudi::Property< std::string > m_jobOptionsPath
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
bool m_useHiveAlgorithmManager
Gaudi::Property< bool > m_loopCheck