34 #include "GaudiCoreSvcVersion.h" 45 #define ON_DEBUG if ( UNLIKELY( m_outputLevel <= MSG::DEBUG ) ) 46 #define ON_VERBOSE if ( UNLIKELY( m_outputLevel <= MSG::VERBOSE ) ) 63 m_managers[IService::interfaceID().id()] =
new ServiceManager(
this );
65 m_svcLocator = svcManager();
72 m_managers[IAlgorithm::interfaceID().id()] = algMgr;
76 declareProperty(
"AlgTypeAliases", algMgr->
typeAliases(),
77 "Aliases of algorithm types, to replace an algorithm type for every instance" );
80 svcManager()->setLoopCheckEnabled( m_loopCheck );
82 m_svcMapping = {
"EvtDataSvc/EventDataSvc",
83 "DetDataSvc/DetectorDataSvc",
84 "HistogramSvc/HistogramDataSvc",
85 "HbookCnv::PersSvc/HbookHistSvc",
86 "RootHistCnv::PersSvc/RootHistSvc",
87 "EvtPersistencySvc/EventPersistencySvc",
88 "DetPersistencySvc/DetectorPersistencySvc",
89 "HistogramPersistencySvc/HistogramPersistencySvc"};
99 StatusCode sc = base_class::queryInterface( iid, ppvi );
157 auto jobOptsIProp = jobsvc.as<
IProperty>();
158 if ( !jobOptsIProp ) {
171 log <<
MSG::FATAL <<
"Error setting JobOptionsPreAction option in JobOptionsSvc" <<
endmsg;
179 log <<
MSG::FATAL <<
"Error setting JobOptionsPostAction option in JobOptionsSvc" <<
endmsg;
190 }
else if (
isEnvSet(
"JOBOPTPATH" ) ) {
203 jobOptsIProp.reset();
207 auto msgSvcIProp = msgsvc.as<
IProperty>();
211 sc = jobsvc->sysInitialize();
216 sc = msgsvc->sysInitialize();
271 <<
"==================================================================" 272 <<
"==================================================================" <<
std::endl 280 <<
"v" << GAUDICORESVC_MAJOR_VERSION <<
"r" << GAUDICORESVC_MINOR_VERSION
281 #if GAUDICORESVC_PATCH_VERSION 282 <<
"p" << GAUDICORESVC_PATCH_VERSION
291 <<
"==================================================================" 292 <<
"==================================================================" <<
endmsg;
391 <<
"\n Check option ApplicationMgr." <<
m_eventLoopMgr.name() <<
"\n No events will be processed." <<
endmsg;
431 std::string svcname(
"Gaudi::Utils::StopSignalHandler" );
434 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
443 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
648 log <<
MSG::INFO <<
"Application Manager Terminated successfully with a user requested ScheduledStop" <<
endmsg;
667 svc->sysFinalize().ignore();
673 log <<
MSG::ERROR <<
"Could not get the IService interface of the JobOptionsSvc" <<
endmsg;
675 svc->sysFinalize().ignore();
759 if ( ignoreFailures ) {
824 ss <<
"createEventContext: Invalid state \"" <<
FSMState() <<
'"';
870 throw GaudiException(
"Cannot reinitialize application if not INITIALIZED or RUNNING",
927 throw GaudiException(
"Failed to create ext services",
"MinimalEventLoopMgr::createSvcNameListHandler",
937 auto it = theNames.begin();
938 auto et = theNames.end();
939 while ( result.
isSuccess() && it != et ) {
941 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
943 log <<
MSG::ERROR <<
"decodeCreateSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
960 throw GaudiException(
"Failed to declare ext services",
"MinimalEventLoopMgr::extSvcNameListHandler",
973 auto it = theNames.begin();
974 auto et = theNames.end();
975 while ( result.
isSuccess() && it != et ) {
978 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
980 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
984 if ( ( result =
svcManager()->declareSvcType( item.
name(), item.
type() ) ).isFailure() ) {
986 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot declare service " << item.
type() <<
"/" << item.
name()
1017 if ( 0 == dllInList[it] ) {
1020 ++duplicateList[it];
1029 log <<
MSG::DEBUG <<
"Removed duplicate entries for modules : ";
1030 for (
auto it = duplicateList.
begin(); it != duplicateList.
end(); ++it ) {
1031 log << it->first <<
"(" << 1 + it->second <<
")";
1032 if ( it != --duplicateList.
end() )
log <<
", ";
1044 for (
const auto& it : theNames ) {
1058 if ( !successNames.
empty() ) {
1060 for (
auto it = successNames.
begin(); it != successNames.
end(); it++ ) {
1062 if ( ( it + 1 ) != successNames.
end() )
log <<
", ";
1071 for (
auto it = failNames.
begin(); it != failNames.
end(); it++ ) {
1073 if ( ( it + 1 ) != failNames.
end() )
log <<
", ";
1082 for (
auto& mgrItem :
m_managers ) { mgrItem.second->outputLevelUpdate(); }
1091 for (
int i = 0; i < indent; ++i )
log <<
" ";
1097 if ( prop->getProperty( &p ).isSuccess() ) {
1098 for (
auto& subalgname : p.value() ) { printAlgsSequencesHelper( algmgr, subalgname,
log, indent + 1 ); }
1108 log <<
MSG::ALWAYS <<
"****************************** Algorithm Sequence ****************************" <<
endmsg;
1110 log <<
MSG::ALWAYS <<
"******************************************************************************" <<
endmsg;
The ServiceManager class is in charge of the creation of concrete instances of Services.
Gaudi::StateMachine::State m_targetState
Internal State.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
StatusCode initialize() override
constexpr int FinalizationFailure
Error codes for operation failures.
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
virtual StatusCode addService(IService *svc, int prio=DEFAULT_SVC_PRIORITY)=0
Add a service to the "active" list of services of the factory.
Definition of the MsgStream class used to transmit messages.
Gaudi::Property< bool > m_propertiesPrint
virtual StatusCode stopRun()=0
Schedule a stop of the current event processing.
virtual StatusCode run()=0
Run the class implementation.
Define general base for Gaudi exception.
StatusCode decodeDllNameList()
Gaudi::Property< bool > m_printAlgsSequence
Gaudi::Property< int > m_returnCode
Property to record the error conditions occurring during the running.
Gaudi::Details::PropertyBase * property(const std::string &name) const
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
Gaudi::Property< bool > m_stopOnSignal
Property to enable/disable the "stop on signal" service.
StatusCode loadModule(const std::string &module, bool fireIncident=true) override
Gaudi::Property< bool > m_codeCheck
SmartIF< IRunable > m_runable
Reference to the runable object.
Implementation of property with value of concrete type.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
bool empty() const override
virtual StatusCode executeEvent(EventContext &&ctx)=0
Process single event.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
ManagersMap m_managers
Map of known component managers.
StatusCode sysStart() override
MSG::Level resetMessaging()
Reinitialize internal states.
Gaudi::Property< std::string > m_jobOptionsType
static Time current()
Returns the current time.
Gaudi::Property< std::map< std::string, std::string > > m_environment
constexpr static const auto SUCCESS
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
const std::string & type() const
Gaudi::Property< std::string > m_appVersion
static GAUDI_API void enableChecking()
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,...
void push(EventContext &&ctx) override
StatusCode nextEvent(int maxevt) override
SmartIF< IJobOptionsSvc > m_jobOptionsSvc
Reference to JobOption service.
AlgTypeAliasesMap & typeAliases()
TYPE * get() const
Get interface pointer.
This class represents an entry point to all the event specific data.
void createSvcNameListHandler(Gaudi::Details::PropertyBase &)
static auto i_delegateToEvtProc(SELF *self, PIMPL &member, std::string_view method_name, METHOD &&method, ARGS &&... args)
Helper to delegate calls to event processor implementation.
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
StatusCode terminate() override
virtual bool empty() const =0
Tell if the processor has events in the queues.
SmartIF< ISvcManager > & svcManager()
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
constexpr int ScheduledStop
Gaudi::Property< std::string > m_eventLoopMgr
constexpr bool versionMatch(const InterfaceID &iid) const
check compatibility.
StatusCode sysReinitialize() override
virtual StatusCode nextEvent(int maxevt)=0
Process the next maxevt events.
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
virtual StatusCode setProperty(const Gaudi::Details::PropertyBase &p)=0
Set the property by property.
Gaudi::Property< int > m_outputLevel
Helper class to parse a string of format "type/name".
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
Gaudi::Property< std::vector< std::string > > m_topAlgNameList
virtual StatusCode reinitialize()=0
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
void extSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
General service interface definition.
std::optional< Gaudi::Interfaces::IQueueingEventProcessor::ResultType > pop() override
const std::string & name() const
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.
virtual SmartIF< IService > & createService(const Gaudi::Utils::TypeNameString &nametype)=0
Creates and instance of a service type that has been declared beforehand and assigns it a name.
Definition of the basic interface.
virtual StatusCode setMyProperties(const std::string &client, IProperty *me)=0
Override default properties of the calling client.
virtual std::optional< ResultType > pop()=0
Get the next available result.
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
#define DECLARE_OBJECT_FACTORY(x)
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void*)
Gaudi::Property< std::string > m_runableType
StatusCode sysStop() override
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
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".
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
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
virtual EventContext createEventContext()=0
Gaudi::Property< std::string > m_jobOptionsPreAction
Gaudi::Property< std::vector< std::string > > m_svcMapping
Gaudi::Property< std::vector< std::string > > m_dllNameList
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
implementation of IInterface::queryInterface
The Application Manager class.
virtual void push(EventContext &&ctx)=0
Schedule the processing of an event.
Gaudi::Property< bool > m_actHistory
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
StatusCode decodeExtSvcNameList()
GAUDI_API const std::string & hostName()
Host name.
const StatusCode & ignore() const
Ignore/check StatusCode.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
Gaudi::Property< bool > m_extSvcCreates
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
virtual StatusCode restart()=0
Initialization (from RUNNING to RUNNING, via INITIALIZED).
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
StatusCode decodeCreateSvcNameList()
void printAlgsSequences()
Print the sequence of algorithms that have been loaded.
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
Gaudi::Property< std::string > m_jobOptionsPostAction
constexpr static const auto FAILURE
StatusCode i_startup()
Internal startup routine.
StatusCode stop() override
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
static GAUDI_API void disableChecking()
Gaudi::Property< std::string > m_messageSvcType
StatusCode reinitialize() override
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
Gaudi::StateMachine::State m_state
Internal State.
Gaudi::StateMachine::State FSMState() const override
Gaudi::Property< std::string > m_appName
virtual StatusCode executeRun(int maxevt)=0
Process the maxevt events as a Run.
StatusCode run() override
The IProperty is the basic interface for all components which have properties that can be set or get.
SmartIF< IAlgManager > & algManager()
SmartIF< IQueueingEventProcessor > m_queueingProcessor
Reference to a queueing processing manager object.
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
const std::string & name() const override
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Gaudi::Property< std::string > m_jobOptionsPath
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
Gaudi::StateMachine::State targetFSMState() const override
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.