All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ApplicationMgr.h
Go to the documentation of this file.
1 #ifndef GAUDI_APPLICATIONMGR_H
2 #define GAUDI_APPLICATIONMGR_H
3 
4 #include "GaudiKernel/Kernel.h"
5 #include "GaudiKernel/IAppMgrUI.h"
6 #include "GaudiKernel/IEventProcessor.h"
7 #include "GaudiKernel/IProperty.h"
8 #include "GaudiKernel/IStateful.h"
9 #include "GaudiKernel/IComponentManager.h"
10 #include "GaudiKernel/IAlgorithm.h"
11 #include "GaudiKernel/IAlgManager.h"
12 #include "GaudiKernel/ISvcManager.h"
13 #include "GaudiKernel/Service.h"
14 #include "GaudiKernel/CommonMessaging.h"
15 #include "GaudiKernel/PropertyMgr.h"
16 
17 // STL include files
18 #include <list>
19 #include <vector>
20 
21 // Forward declarations
22 class ISvcLocator;
23 class ServiceManager;
24 class AlgorithmManager;
25 class DLLClassManager;
26 
27 class IMessageSvc;
28 class IIncidentSvc;
29 class IRunable;
30 class IDataManagerSvc;
31 class IConversionSvc;
32 class IJobOptionsSvc;
33 
46 class ApplicationMgr : public CommonMessaging<implements4<IAppMgrUI,
47  IEventProcessor,
48  IService,
49  IStateful> > {
52  IService,
54 public:
55  typedef std::list<std::pair<IService*,int> > ListSvc;
56  typedef std::vector<std::string> VectorName;
57 
58 public:
59 
60  // default creator
61  ApplicationMgr(IInterface* = nullptr);
62  // virtual destructor
63  ~ApplicationMgr() override = default;
64 
65  // implementation of IInterface::queryInterface
66  StatusCode queryInterface(const InterfaceID& iid, void** pinterface) override;
67 
68  // implementation of IAppMgrUI::run
69  StatusCode run() override;
70  // implementation of IAppMgrUI::configure
71  StatusCode configure() override;
72  // implementation of IAppMgrUI::terminate
73  StatusCode terminate() override;
74  // implementation of IAppMgrUI::initialize
75  StatusCode initialize() override;
76  // implementation of IAppMgrUI::start
77  StatusCode start() override;
78  // implementation of IAppMgrUI::stop
79  StatusCode stop() override;
80  // implementation of IAppMgrUI::finalize
81  StatusCode finalize() override;
82  // implementation of IAppMgrUI::nextEvent
83  StatusCode nextEvent(int maxevt) override;
84  // implementation of IAppMgrUI::name
85  const std::string& name() const override;
87  StatusCode executeEvent(void* par) override;
89  StatusCode executeRun(int evtmax) override;
91  StatusCode stopRun() override;
92 
93  // implementation of IStateful::state
94  Gaudi::StateMachine::State FSMState() const override;
95  // implementation of IStateful::targetState
97  // implementation of IStateful::reinitialize
98  StatusCode reinitialize() override;
99  // implementation of IStateful::reinitialize
100  StatusCode restart() override;
101  // implementation of IService::sysItinitilaize
103  // implementation of IService::sysStart
104  StatusCode sysStart() override { return StatusCode::SUCCESS; }
105  // implementation of IService::sysStop
106  StatusCode sysStop() override { return StatusCode::SUCCESS; }
107  // implementation of IService::sysFinalize
109  // implementation of IService::sysReinitialize
111  // implementation of IService::sysRestart
113 
114  // SI Go Handler
115  void SIGoHandler ( Property& theProp );
116  // SI Exit handler
117  void SIExitHandler ( Property& theProp );
118 
120 
121  void evtLoopPropertyHandler ( Property& theProp );
125  void extSvcNameListHandler ( Property& theProp );
127  void multiThreadSvcNameListHandler( Property& theProp );
129  void dllNameListHandler ( Property& theProp );
130  void pluginDebugPropertyHandler ( Property& theProp );
131  void initLoopCheckHndlr ( Property& );
133 
134  template <class I>
136  return m_managers[I::interfaceID().id()];
137  }
138 
140  // Cache the casted pointer to ISvcManager
141  if (!m_svcManager) {
142  m_svcManager = getManager<IService>();
143  }
144  return m_svcManager;
145  }
146 
148  // Cache the casted pointer to IAlgManager
149  if (!m_algManager) {
150  m_algManager = getManager<IAlgorithm>();
151  }
152  return m_algManager;
153  }
154 
157  return m_svcLocator;
158  }
159 
160 protected:
162  StatusCode declareMultiSvcType(const std::string& name,
163  const std::string& type);
166  int prio);
167 
168  // implementation of IService::setServiceManager
169  void setServiceManager(ISvcManager*) override {}
170 
173 
178  StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures = false);
179 
182  typedef std::map<unsigned long, SmartIF<IComponentManager> > ManagersMap;
186  ManagersMap m_managers;
189 
192 
195 
196 
197  // data members
201 
209 
210  std::string m_name = "ApplicationMgr";
213 
214  VectorName m_defServices;
215  VectorName m_svcMapping;
216  VectorName m_svcOptMapping;
217 
222 
223  //
224  // The public ApplicationMgr properties
225  //
226 
227  int m_evtMax;
230 
234 
236  std::string m_jobOptionsType;
237  std::string m_jobOptionsPath;
238  std::string m_jobOptionsPreAction;
240  std::string m_runableType;
241  std::string m_eventLoopMgr;
242  std::string m_evtsel;
243  std::string m_histPersName;
245  std::string m_appName;
246  std::string m_appVersion;
248  bool m_codeCheck;
250 
252 
257 
258  std::map<std::string,std::string> m_environment;
259 
262 
266 
270 
271  // Flag to activate the printout of properties
273 
276 
277  // For concurrency
279 
280 private:
281  std::vector<std::string> m_okDlls;
282 };
283 #endif // GAUDI_APPLICATIONMGR_H
The ServiceManager class is in charge of the creation of concrete instances of Services.
void dllNameListHandler(Property &theProp)
Gaudi::StateMachine::State m_targetState
Internal State.
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
StatusCode initialize() override
std::string m_jobOptionsType
Source type (e.g. dbase, file...)
StringArrayProperty m_createSvcNameList
void createSvcNameListHandler(Property &)
StringArrayProperty m_outStreamNameList
List of output stream names.
StringProperty m_messageSvcType
MessageSvc type.
Base class used to implement the interfaces.
Definition: implements.h:9
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
StatusCode decodeDllNameList()
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 ...
SmartIF< IRunable > m_runable
Reference to the runable object.
std::list< std::pair< IService *, int > > ListSvc
int m_noOfEvtThreads
no of multiThreadSvc copies
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.
StringArrayProperty m_declaredManagers
Property to declare the list of known managers.
std::string m_histPersName
CGL: Name of the Hist Pers Svc.
StatusCode sysStart() override
bool m_codeCheck
Activate StatusCode checking.
std::string m_jobOptionsPreAction
additional command to run on config
VectorName m_defServices
Vector default services names.
StringProperty m_outStreamType
Output stream type (obsolete?)
std::string m_appName
The name of the application.
IntegerProperty m_pluginDebugLevel
Debug level for the plugin system.
std::vector< std::string > m_okDlls
names of successfully loaded dlls
StatusCode sysRestart() override
std::map< std::string, std::string > m_environment
Environment variables to set.
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
Definition: StateMachine.h:12
StringArrayProperty m_dllNameList
List of DDL's names.
StatusCode sysFinalize() override
StatusCode nextEvent(int maxevt) override
SmartIF< IJobOptionsSvc > m_jobOptionsSvc
Reference to JobOption service.
CommonMessaging< implements4< IAppMgrUI, IEventProcessor, IService, IStateful > > base_class
std::string m_jobOptionsPostAction
additional command to run on config
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
StatusCode terminate() override
SmartIF< ISvcManager > & svcManager()
int m_outputLevel
Message output level.
SmartIF< IComponentManager > & getManager()
StatusCode addMultiSvc(const Gaudi::Utils::TypeNameString &typeName, int prio)
add one or more copies of svc type/name as determined by NoOfThreads
int m_evtMax
Number of events to be processed.
StatusCode sysReinitialize() override
IntegerProperty m_returnCode
Property to record the error conditions occurring during the running.
void multiThreadSvcNameListHandler(Property &theProp)
Interface ID class.
Definition: IInterface.h:30
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
Main interface for the JobOptions service.
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
std::string m_jobOptionsPath
The "file" to look for properties.
BooleanProperty m_extSvcCreates
LHCb or ATLAS defn of "ExtSvc".
General service interface definition.
Definition: IService.h:18
VectorName m_svcMapping
Default mapping of services.
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:26
Definition of the basic interface.
Definition: IInterface.h:234
bool m_actHistory
Activate HistorySvc.
BooleanProperty m_loopCheck
For ServiceMgr initialization loop checking.
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
StatusCode sysStop() override
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
StringArrayProperty m_topAlgNameList
List of top level algorithms names.
std::string m_evtsel
Event selection.
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
StringArrayProperty m_multiThreadSvcNameList
List of external services names for which we want a copy per evt thread.
VectorName m_svcOptMapping
Default mapping of services.
StatusCode executeEvent(void *par) override
implementation of IEventProcessor::executeEvent(void*)
The Application Manager class.
std::vector< std::string > VectorName
std::string m_runableType
Runable type.
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
StatusCode decodeExtSvcNameList()
SmartIF< PropertyMgr > m_propertyMgr
Reference to Property Manager.
Application Manager User Interface.
Definition: IAppMgrUI.h:20
void initLoopCheckHndlr(Property &)
bool m_propertiesPrint
flag to activate the printout of properties
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
void SIGoHandler(Property &theProp)
SmartIF< DLLClassManager > m_classManager
Reference to the class manager.
StatusCode start() override
StatusCode restart() override
StatusCode configure() override
StringArrayProperty m_extSvcNameList
List of external services names.
ApplicationMgr(IInterface *=nullptr)
StringProperty m_jobOptionsSvcType
JobOptionsSvc type.
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
StatusCode decodeCreateSvcNameList()
void evtLoopPropertyHandler(Property &theProp)
~ApplicationMgr() override=default
BooleanProperty m_stalledEventMonitoring
Property to enable/disable the monitoring and reporting of stalled events (enabled by default)...
std::string m_eventLoopMgr
Processing manager type.
Runable interface definition.
Definition: IRunable.h:18
The IEventProcessor is the interface to process events.
void SIExitHandler(Property &theProp)
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.
IntegerProperty m_SIGo
For SI's "Go" command via callback.
BooleanProperty m_auditTools
Defaults for auditors.
BooleanProperty m_auditAlgs
StatusCode reinitialize() override
Gaudi::StateMachine::State m_state
Internal State.
Gaudi::StateMachine::State FSMState() const override
Interface for classes that implement the Gaudi State Machine.
Definition: IStateful.h:16
StatusCode run() override
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:21
StatusCode decodeMultiThreadSvcNameList()
SmartIF< IAlgManager > & algManager()
void extSvcNameListHandler(Property &theProp)
void pluginDebugPropertyHandler(Property &theProp)
BooleanProperty m_stopOnSignal
Property to enable/disable the "stop on signal" service (enabled by default).
const std::string & name() const override
void setServiceManager(ISvcManager *) override
std::string m_appVersion
The version of the application.
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
StatusCode sysInitialize() override
BooleanProperty m_auditSvcs
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
bool m_useHiveAlgorithmManager
IntegerProperty m_SIExit
For SI's "Exit" command via callback.
Gaudi::StateMachine::State targetFSMState() const override
string type
Definition: gaudirun.py:151
StatusCode declareMultiSvcType(const std::string &name, const std::string &type)
declare one or more copies of svc type/name as determined by NoOfThreads