The Gaudi Framework  v29r0 (ff2e7097)
ApplicationMgr.h
Go to the documentation of this file.
1 #ifndef GAUDI_APPLICATIONMGR_H
2 #define GAUDI_APPLICATIONMGR_H
3 
11 #include "GaudiKernel/IProperty.h"
12 #include "GaudiKernel/IStateful.h"
14 #include "GaudiKernel/Kernel.h"
16 #include "GaudiKernel/Service.h"
17 
18 // STL include files
19 #include <list>
20 #include <vector>
21 
22 // Forward declarations
23 class ISvcLocator;
24 class ServiceManager;
25 class AlgorithmManager;
26 class DLLClassManager;
27 
28 class IMessageSvc;
29 class IIncidentSvc;
30 class IRunable;
31 class IDataManagerSvc;
32 class IConversionSvc;
33 class IJobOptionsSvc;
34 
48  : public PropertyHolder<
49  CommonMessaging<implements<IAppMgrUI, IEventProcessor, IService, IStateful, INamedInterface, IProperty>>>
50 {
51 public:
52  // default creator
53  ApplicationMgr( IInterface* = nullptr );
54  // virtual destructor
55  ~ApplicationMgr() override = default;
56 
57  // implementation of IInterface::queryInterface
58  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
59 
60  // implementation of IAppMgrUI::run
61  StatusCode run() override;
62  // implementation of IAppMgrUI::configure
63  StatusCode configure() override;
64  // implementation of IAppMgrUI::terminate
65  StatusCode terminate() override;
66  // implementation of IAppMgrUI::initialize
67  StatusCode initialize() override;
68  // implementation of IAppMgrUI::start
69  StatusCode start() override;
70  // implementation of IAppMgrUI::stop
71  StatusCode stop() override;
72  // implementation of IAppMgrUI::finalize
73  StatusCode finalize() override;
74  // implementation of IAppMgrUI::nextEvent
75  StatusCode nextEvent( int maxevt ) override;
76  // implementation of IAppMgrUI::name
77  const std::string& name() const override;
79  StatusCode executeEvent( void* par ) override;
81  StatusCode executeRun( int evtmax ) override;
83  StatusCode stopRun() override;
84 
85  // implementation of IStateful::state
86  Gaudi::StateMachine::State FSMState() const override;
87  // implementation of IStateful::targetState
89  // implementation of IStateful::reinitialize
90  StatusCode reinitialize() override;
91  // implementation of IStateful::reinitialize
92  StatusCode restart() override;
93  // implementation of IService::sysItinitilaize
95  // implementation of IService::sysStart
96  StatusCode sysStart() override { return StatusCode::SUCCESS; }
97  // implementation of IService::sysStop
98  StatusCode sysStop() override { return StatusCode::SUCCESS; }
99  // implementation of IService::sysFinalize
101  // implementation of IService::sysReinitialize
103  // implementation of IService::sysRestart
105 
106  // SI Go Handler
107  void SIGoHandler( Gaudi::Details::PropertyBase& theProp );
108  // SI Exit handler
110 
112 
125 
126  template <class I>
128  {
129  return m_managers[I::interfaceID().id()];
130  }
131 
133  {
134  // Cache the casted pointer to ISvcManager
135  if ( !m_svcManager ) {
136  m_svcManager = getManager<IService>();
137  }
138  return m_svcManager;
139  }
140 
142  {
143  // Cache the casted pointer to IAlgManager
144  if ( !m_algManager ) {
145  m_algManager = getManager<IAlgorithm>();
146  }
147  return m_algManager;
148  }
149 
151  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
152 
153 protected:
158 
159  // implementation of IService::setServiceManager
160  void setServiceManager( ISvcManager* ) override {}
161 
164 
169  StatusCode GoToState( Gaudi::StateMachine::State state, bool ignoreFailures = false );
170 
177  ManagersMap m_managers;
180 
183 
186 
187  // data members
191 
192  Gaudi::Property<int> m_SIGo{this, "Go", 0, "For SI's \"Go\" command via callback"};
193  Gaudi::Property<int> m_SIExit{this, "Exit", 0, "For SI's \"Exit\" command via callback"};
194  Gaudi::Property<std::vector<std::string>> m_topAlgNameList{this, "TopAlg", {}, "List of top level algorithms names"};
195  Gaudi::Property<std::vector<std::string>> m_outStreamNameList{this, "OutStream", {}, "List of output stream names"};
196  Gaudi::Property<std::string> m_outStreamType{this, "OutStreamType", "OutputStream",
197  "[[deprecated]] Output stream type"};
198  Gaudi::Property<std::string> m_messageSvcType{this, "MessageSvcType", "MessageSvc", "MessageSvc type"};
199  Gaudi::Property<std::string> m_jobOptionsSvcType{this, "JobOptionsSvcType", "JobOptionsSvc", "JobOptionsSvc type"};
200 
201  std::string m_name = "ApplicationMgr";
204 
205  Gaudi::Property<std::vector<std::string>> m_svcMapping{this, "SvcMapping", {}, "Default mapping of services"};
207  this, "SvcOptMapping", {}, "Default mapping of optional services"};
208 
213 
214  //
215  // The public ApplicationMgr properties
216  //
217 
218  Gaudi::Property<int> m_evtMax{this, "EvtMax", -1, "Number of events to be processed (-1 means all events)"};
219  Gaudi::Property<std::vector<std::string>> m_extSvcNameList{this, "ExtSvc", {}, "List of external services names"};
220  Gaudi::Property<bool> m_extSvcCreates{this, "ExtSvcCreates", true,
221  "LHCb (default) or ATLAS definition of \"ExtSvc\""};
222 
225  Gaudi::Property<int> m_noOfEvtThreads{this, "NoOfThreads", 0, "MultiThreadSvc copies"};
226 
227  Gaudi::Property<std::vector<std::string>> m_dllNameList{this, "Dlls", {}, "List of DDL's names"};
228  Gaudi::Property<std::string> m_jobOptionsType{this, "JobOptionsType", "FILE", "Source type (e.g. dbase, file...)"};
229  Gaudi::Property<std::string> m_jobOptionsPath{this, "JobOptionsPath", {}, "The \"file\" to look for properties"};
231  this, "JobOptionsPostAction", {}, "additional command to run on config"};
233  this, "JobOptionsPreAction", {}, "additional command to run on config"};
234  Gaudi::Property<std::string> m_runableType{this, "Runable", "AppMgrRunable", "Runable type"};
235  Gaudi::Property<std::string> m_eventLoopMgr{this, "EventLoop", "EventLoopMgr", "Processing manager type"};
236  Gaudi::Property<std::string> m_evtsel{this, "EvtSel", {}, "Event selection"};
237  Gaudi::Property<std::string> m_histPersName{this, "HistogramPersistency", "NONE", "Name of the Hist Pers Svc"};
238  Gaudi::Property<int> m_outputLevel{this, "OutputLevel", MSG::INFO, "Message output level"};
239  Gaudi::Property<std::string> m_appName{this, "AppName", "ApplicationMgr", "The name of the application"};
240  Gaudi::Property<std::string> m_appVersion{this, "AppVersion", {}, "The version of the application"};
241  Gaudi::Property<bool> m_actHistory{this, "ActivateHistory", false, "Activate HistorySvc"};
242  Gaudi::Property<bool> m_codeCheck{this, "StatusCodeCheck", false, "Activate StatusCode checking"};
243  Gaudi::Property<int> m_pluginDebugLevel{this, "PluginDebugLevel", 0, "Debug level for the plugin system"};
244 
246  this, "CreateSvc", {}, "List of extra services to be created"};
247 
249  Gaudi::Property<bool> m_auditTools{this, "AuditTools", false};
250  Gaudi::Property<bool> m_auditSvcs{this, "AuditServices", false};
251  Gaudi::Property<bool> m_auditAlgs{this, "AuditAlgorithms", false};
252 
254  this, "Environment", {}, "Environment variables to set"};
255 
256  Gaudi::Property<bool> m_loopCheck{this, "InitializationLoopCheck", true,
257  "For ServiceMgr initialization loop checking"};
258 
262  this, "StopOnSignal", false, "Flag to enable/disable the signal handler that schedule a stop of the event loop"};
263 
267  this, "StalledEventMonitoring", false, "Flag to enable/disable the monitoring and reporting of stalled events"};
268 
269  Gaudi::Property<bool> m_propertiesPrint{this, "PropertiesPrint", false,
270  "Flag to activate the printout of properties"};
271 
274  "Return code of the application. Set internally in case of error conditions."};
275 
276  // For concurrency
278 
279 private:
281 };
282 #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
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< int > m_returnCode
Property to record the error conditions occurring during the running.
void SIExitHandler(Gaudi::Details::PropertyBase &theProp)
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:319
void SIGoHandler(Gaudi::Details::PropertyBase &theProp)
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
void multiThreadSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< std::map< std::string, std::string > > m_environment
Gaudi::Property< std::vector< std::string > > m_multiThreadSvcNameList
List of external services names for which we want a copy per evt thread.
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:14
StatusCode sysFinalize() override
StatusCode nextEvent(int maxevt) override
SmartIF< IJobOptionsSvc > m_jobOptionsSvc
Reference to JobOption service.
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 addMultiSvc(const Gaudi::Utils::TypeNameString &typeName, int prio)
add one or more copies of svc type/name as determined by NoOfThreads
StatusCode sysReinitialize() override
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
Interface ID class.
Definition: IInterface.h:29
Gaudi::Property< int > m_outputLevel
Helper class to parse a string of format "type/name".
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)
void initLoopCheckHndlr(Gaudi::Details::PropertyBase &)
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:28
Definition of the basic interface.
Definition: IInterface.h:277
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< std::string > m_runableType
Gaudi::Property< std::vector< std::string > > m_declaredManagers
Property to declare the list of known managers.
StatusCode sysStop() override
Gaudi::Property< int > m_SIExit
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
StatusCode executeEvent(void *par) override
implementation of IEventProcessor::executeEvent(void*)
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()
Gaudi::Property< std::string > m_jobOptionsPostAction
~ApplicationMgr() override=default
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.
int maxevt
Definition: Bootstrap.cpp:279
constexpr int Success
Definition: AppReturnCode.h:18
StatusCode run() override
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:23
StatusCode decodeMultiThreadSvcNameList()
SmartIF< IAlgManager > & algManager()
Gaudi::Property< int > m_noOfEvtThreads
void setServiceManager(ISvcManager *) override
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
StatusCode sysInitialize() override
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
StatusCode declareMultiSvcType(const std::string &name, const std::string &type)
declare one or more copies of svc type/name as determined by NoOfThreads