Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 
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 public:
51  // default creator
52  ApplicationMgr( IInterface* = nullptr );
53 
54  // implementation of IInterface::queryInterface
55  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
56 
57  // implementation of IAppMgrUI::run
58  StatusCode run() override;
59  // implementation of IAppMgrUI::configure
60  StatusCode configure() override;
61  // implementation of IAppMgrUI::terminate
62  StatusCode terminate() override;
63  // implementation of IAppMgrUI::initialize
64  StatusCode initialize() override;
65  // implementation of IAppMgrUI::start
66  StatusCode start() override;
67  // implementation of IAppMgrUI::stop
68  StatusCode stop() override;
69  // implementation of IAppMgrUI::finalize
70  StatusCode finalize() override;
71  // implementation of IAppMgrUI::nextEvent
72  StatusCode nextEvent( int maxevt ) override;
73  // implementation of IAppMgrUI::name
74  const std::string& name() const override;
76  StatusCode executeEvent( void* par ) 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 
114 
115  template <class I>
117  return m_managers[I::interfaceID().id()];
118  }
119 
121  // Cache the casted pointer to ISvcManager
122  if ( !m_svcManager ) { m_svcManager = getManager<IService>(); }
123  return m_svcManager;
124  }
125 
127  // Cache the casted pointer to IAlgManager
128  if ( !m_algManager ) { m_algManager = getManager<IAlgorithm>(); }
129  return m_algManager;
130  }
131 
133  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
134 
136  void outputLevelUpdate() override;
137 
138 protected:
139  // implementation of IService::setServiceManager
140  void setServiceManager( ISvcManager* ) override {}
141 
144 
149  StatusCode GoToState( Gaudi::StateMachine::State state, bool ignoreFailures = false );
150 
157  ManagersMap m_managers;
160 
163 
166 
167  // data members
171 
173  [this]( auto& ) {
174  // Re-initialize everything
175  this->reinitialize().ignore();
176  // Execute a number of events
177  this->executeRun( m_evtMax ).ignore();
178  },
179  "For SI's \"Go\" command via callback"};
181  [this]( auto& ) {
182  finalize().ignore();
183  terminate().ignore();
184  ::exit( 0 );
185  },
186  "For SI's \"Exit\" command via callback"};
188  this, "TopAlg", {}, &ApplicationMgr::evtLoopPropertyHandler, "List of top level algorithms names"};
190  this, "OutStream", {}, &ApplicationMgr::evtLoopPropertyHandler, "List of output stream names"};
191  Gaudi::Property<std::string> m_outStreamType{this, "OutStreamType", "OutputStream",
193  "[[deprecated]] Output stream type"};
194  Gaudi::Property<std::string> m_messageSvcType{this, "MessageSvcType", "MessageSvc", "MessageSvc type"};
195  Gaudi::Property<std::string> m_jobOptionsSvcType{this, "JobOptionsSvcType", "JobOptionsSvc", "JobOptionsSvc type"};
196 
197  std::string m_name = "ApplicationMgr";
200 
201  Gaudi::Property<std::vector<std::string>> m_svcMapping{this, "SvcMapping", {}, "Default mapping of services"};
203  this, "SvcOptMapping", {}, "Default mapping of optional services"};
204 
209 
210  //
211  // The public ApplicationMgr properties
212  //
213 
214  Gaudi::Property<int> m_evtMax{this, "EvtMax", -1, "Number of events to be processed (-1 means all events)"};
215  Gaudi::Property<std::vector<std::string>> m_extSvcNameList{this, "ExtSvc", {}, "List of external services names"};
216  Gaudi::Property<bool> m_extSvcCreates{this, "ExtSvcCreates", true,
217  "LHCb (default) or ATLAS definition of \"ExtSvc\""};
218 
219  Gaudi::Property<std::vector<std::string>> m_dllNameList{this, "Dlls", {}, "List of DDL's names"};
220  Gaudi::Property<std::string> m_jobOptionsType{this, "JobOptionsType", "FILE", "Source type (e.g. dbase, file...)"};
221  Gaudi::Property<std::string> m_jobOptionsPath{this, "JobOptionsPath", {}, "The \"file\" to look for properties"};
223  this, "JobOptionsPostAction", {}, "additional command to run on config"};
225  this, "JobOptionsPreAction", {}, "additional command to run on config"};
226  Gaudi::Property<std::string> m_runableType{this, "Runable", "AppMgrRunable", "Runable type"};
227  Gaudi::Property<std::string> m_eventLoopMgr{this, "EventLoop", "EventLoopMgr", "Processing manager type"};
228  Gaudi::Property<std::string> m_evtsel{this, "EvtSel", {}, "Event selection"};
229  Gaudi::Property<std::string> m_histPersName{this, "HistogramPersistency", "NONE", "Name of the Hist Pers Svc"};
230  Gaudi::Property<int> m_outputLevel{this, "OutputLevel", MSG::INFO, "Message output level"};
231  Gaudi::Property<std::string> m_appName{this, "AppName", "ApplicationMgr", "The name of the application"};
232  Gaudi::Property<std::string> m_appVersion{this, "AppVersion", {}, "The version of the application"};
233  Gaudi::Property<bool> m_actHistory{this, "ActivateHistory", false, "Activate HistorySvc"};
234  Gaudi::Property<bool> m_codeCheck{this, "StatusCodeCheck", false, "Activate StatusCode checking"};
236  this, "PluginDebugLevel", 0,
237  [this]( auto& ) {
238  // Setup debug level for the plugin system
239  MsgStream log( m_messageSvc, this->name() );
240  log << MSG::INFO << "Updating Gaudi::PluginService::SetDebug(level) to level=" << m_pluginDebugLevel << endmsg;
242  },
243  "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  [this]( auto& ) { this->svcManager()->setLoopCheckEnabled( m_loopCheck ); },
258  "For ServiceMgr initialization loop checking"};
259 
263  this, "StopOnSignal", false, "Flag to enable/disable the signal handler that schedule a stop of the event loop"};
264 
268  this, "StalledEventMonitoring", false, "Flag to enable/disable the monitoring and reporting of stalled events"};
269 
270  Gaudi::Property<bool> m_propertiesPrint{this, "PropertiesPrint", false,
271  "Flag to activate the printout of properties"};
272 
275  "Return code of the application. Set internally in case of error conditions."};
276 
277  // For concurrency
279 
280 private:
282 };
283 #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< 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.
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
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)
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()
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.
int maxevt
Definition: Bootstrap.cpp:260
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