Go to the documentation of this file.
40 #define ON_DEBUG if ( m_outputLevel <= MSG::DEBUG )
41 #define ON_VERBOSE if ( m_outputLevel <= MSG::VERBOSE )
47 static IMessageSvc* s_messageSvcInstance{
nullptr };
49 static ErrorHandlerFunc_t s_originalRootErrorHandler{
nullptr };
52 void ROOTErrorHandlerAdapter(
int level, Bool_t abort,
const char* location,
const char*
msg ) {
53 if ( s_messageSvcInstance ) {
55 if (
level >= gErrorIgnoreLevel ) {
61 if ( msgLevel >= s_messageSvcInstance->outputLevel( location ) ) {
62 s_messageSvcInstance->reportMessage(
Message{ location, msgLevel,
msg }, msgLevel );
67 if ( s_originalRootErrorHandler ) {
69 s_originalRootErrorHandler(
level, abort, location,
msg );
72 ROOT::Internal::MinimalErrorHandler(
level, abort, location,
msg );
101 m_managers[IAlgorithm::interfaceID().id()] = algMgr;
106 "Aliases of algorithm types, to replace an algorithm type for every instance" );
112 "DetDataSvc/DetectorDataSvc",
113 "HistogramSvc/HistogramDataSvc",
114 "HbookCnv::PersSvc/HbookHistSvc",
115 "RootHistCnv::PersSvc/RootHistSvc",
116 "EvtPersistencySvc/EventPersistencySvc",
117 "DetPersistencySvc/DetectorPersistencySvc",
118 "HistogramPersistencySvc/HistogramPersistencySvc" };
128 StatusCode sc = base_class::queryInterface( iid, ppvi );
181 s_originalRootErrorHandler = SetErrorHandler( ROOTErrorHandlerAdapter );
184 <<
"ROOT not yet initialized, we cannot override the error handler are requested "
185 "(UseMessageSvcForROOTMessages==true)"
197 auto jobOptsIProp = jobsvc.as<
IProperty>();
198 if ( !jobOptsIProp ) {
211 log <<
MSG::FATAL <<
"Error setting JobOptionsPreAction option in JobOptionsSvc" <<
endmsg;
219 log <<
MSG::FATAL <<
"Error setting JobOptionsPostAction option in JobOptionsSvc" <<
endmsg;
230 }
else if (
isEnvSet(
"JOBOPTPATH" ) ) {
243 jobOptsIProp.reset();
247 auto msgSvcIProp = msgsvc.as<
IProperty>();
251 sc = jobsvc->sysInitialize();
256 sc = msgsvc->sysInitialize();
307 <<
"=================================================================="
308 <<
"==================================================================" <<
std::endl
317 #if GAUDI_PATCH_VERSION
327 <<
"=================================================================="
328 <<
"==================================================================" <<
endmsg;
394 sc =
svcManager()->addService( evtloop_item, ServiceManager::DEFAULT_SVC_PRIORITY * 10 );
452 std::string svcname(
"Gaudi::Utils::StopSignalHandler" );
455 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
512 .andThen( [&]() {
return svcManager()->start(); } )
513 .andThen( [&]() {
return algManager()->start(); } )
563 .andThen( [&]() {
return svcManager()->stop(); } )
565 .andThen( [&]() {
return m_svcLocator->service(
"JobOptionsSvc" )->sysStop(); } )
642 log <<
MSG::INFO <<
"Application Manager Terminated successfully with a user requested ScheduledStop" <<
endmsg;
650 opts.set(
"MessageSvc.AuditFinalize",
"false" );
652 opts.set(
"JobOptionsSvc.AuditFinalize",
"false" );
656 if ( s_originalRootErrorHandler ) {
657 SetErrorHandler( s_originalRootErrorHandler );
658 s_originalRootErrorHandler =
nullptr;
661 s_messageSvcInstance =
nullptr;
667 svc->sysFinalize().ignore();
674 log <<
MSG::ERROR <<
"Could not get the IService interface of the JobOptionsSvc" <<
endmsg;
676 svc->sysFinalize().ignore();
761 if ( ignoreFailures ) {
826 ss <<
"createEventContext: Invalid state \"" <<
FSMState() <<
'"';
872 throw GaudiException(
"Cannot reinitialize application if not INITIALIZED or RUNNING",
883 sc =
m_svcLocator->service(
"JobOptionsSvc" )->sysReinitialize();
908 sc =
m_svcLocator->service(
"JobOptionsSvc" )->sysRestart();
920 if (
props )
props->setProperty( p ).ignore();
929 throw GaudiException(
"Failed to create ext services",
"MinimalEventLoopMgr::createSvcNameListHandler",
939 auto it = theNames.begin();
940 auto et = theNames.end();
941 while ( result.
isSuccess() && it != et ) {
943 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
945 log <<
MSG::ERROR <<
"decodeCreateSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
962 throw GaudiException(
"Failed to declare ext services",
"MinimalEventLoopMgr::extSvcNameListHandler",
975 auto it = theNames.begin();
976 auto et = theNames.end();
977 while ( result.
isSuccess() && it != et ) {
980 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
982 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
986 if ( ( result =
svcManager()->declareSvcType( item.
name(), item.
type() ) ).isFailure() ) {
988 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot declare service " << item.
type() <<
"/" << item.
name()
1019 if ( 0 == dllInList[it] ) {
1022 ++duplicateList[it];
1031 log <<
MSG::DEBUG <<
"Removed duplicate entries for modules : ";
1032 for (
auto it = duplicateList.
begin(); it != duplicateList.
end(); ++it ) {
1033 log << it->first <<
"(" << 1 + it->second <<
")";
1034 if ( it != --duplicateList.
end() )
log <<
", ";
1046 for (
const auto& it : theNames ) {
1060 if ( !successNames.
empty() ) {
1062 for (
auto it = successNames.
begin(); it != successNames.
end(); it++ ) {
1064 if ( ( it + 1 ) != successNames.
end() )
log <<
", ";
1073 for (
auto it = failNames.
begin(); it != failNames.
end(); it++ ) {
1075 if ( ( it + 1 ) != failNames.
end() )
log <<
", ";
1084 for (
auto& mgrItem :
m_managers ) { mgrItem.second->outputLevelUpdate(); }
1093 for (
int i = 0; i < indent; ++i )
log <<
" ";
1095 auto prop = algmgr->algorithm<
IProperty>( algname, false );
1099 if ( prop->getProperty( &p ).isSuccess() ) {
1100 for (
auto& subalgname : p.value() ) { printAlgsSequencesHelper( algmgr, subalgname,
log, indent + 1 ); }
1110 log <<
MSG::ALWAYS <<
"****************************** Algorithm Sequence ****************************" <<
endmsg;
1112 log <<
MSG::ALWAYS <<
"******************************************************************************" <<
endmsg;
void printAlgsSequences()
Print the sequence of algorithms that have been loaded.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
const std::string name() const
property name
virtual std::optional< ResultType > pop()=0
Get the next available result.
constexpr int FinalizationFailure
Error codes for operation failures.
Gaudi::Property< bool > m_propertiesPrint
const std::string & name() const
bool empty() const override
StatusCode decodeDllNameList()
MSG::Level resetMessaging()
Reinitialize internal states.
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
StatusCode run() override
SmartIF< IRunable > m_runable
Reference to the runable object.
StatusCode i_startup()
Internal startup routine.
StatusCode stop() override
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Gaudi::Property< std::string > m_messageSvcType
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
#define GAUDI_MINOR_VERSION
const std::string & name() const override
Gaudi::StateMachine::State FSMState() const override
StatusCode sysStop() override
Gaudi::Property< bool > m_stopOnSignal
Property to enable/disable the "stop on signal" service.
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
std::vector< std::string > m_okDlls
names of successfully loaded dlls
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
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.
StatusCode terminate() override
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
StatusCode finalize() override
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Gaudi::Property< std::string > m_jobOptionsSvcType
StatusCode nextEvent(int maxevt) override
ApplicationMgr(IInterface *=nullptr)
Gaudi::Details::PropertyBase * property(std::string_view name) const
\fixme property and bindPropertiesTo should be protected
void createSvcNameListHandler(Gaudi::Details::PropertyBase &)
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
SmartIF< ISvcManager > & svcManager()
Gaudi::Property< std::vector< std::string > > m_dllNameList
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm,...
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
Helper class to parse a string of format "type/name".
Gaudi::Property< int > m_returnCode
Property to record the error conditions occurring during the running.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
StatusCode restart() override
StatusCode configure() override
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Gaudi::Property< std::string > m_jobOptionsPostAction
virtual void push(EventContext &&ctx)=0
Schedule the processing of an event.
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Gaudi::Property< std::string > m_jobOptionsPreAction
std::optional< Gaudi::Interfaces::IQueueingEventProcessor::ResultType > pop() override
const ValueType & value() const
constexpr int ScheduledStop
SmartIF< ISvcLocator > m_svcLocator
Reference to its own service locator (must be instantiated prior to any service!)
Gaudi::Property< std::string > m_appVersion
StatusCode sysReinitialize() override
Gaudi::Property< std::string > m_jobOptionsType
StatusCode sysRestart() override
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void*)
Gaudi::Property< std::string > m_runableType
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Gaudi::StateMachine::State targetFSMState() const override
Gaudi::Property< std::vector< std::string > > m_topAlgNameList
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
Gaudi::Property< std::vector< std::string > > m_svcMapping
const std::string & type() const
Gaudi::Property< std::vector< std::string > > m_svcOptMapping
StatusCode decodeExtSvcNameList()
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
Gaudi::Property< std::string > m_eventLoopMgr
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Gaudi::Property< bool > m_extSvcCreates
Gaudi::Property< bool > m_useMessageSvcForROOTMessages
Gaudi::Property< std::vector< std::string > > m_createSvcNameList
Gaudi::Property< bool > m_actHistory
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
constexpr static const auto SUCCESS
StatusCode decodeCreateSvcNameList()
TYPE * get() const
Get interface pointer.
Gaudi::Property< std::string > m_appName
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
static Time current()
Returns the current time.
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
SmartIF< IQueueingEventProcessor > m_queueingProcessor
Reference to a queueing processing manager object.
Gaudi::Property< int > m_outputLevel
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
ManagersMap m_managers
Map of known component managers.
Gaudi::StateMachine::State m_state
Internal State.
StatusCode sysStart() override
Gaudi::Property< std::string > m_jobOptionsPath
Gaudi::Property< bool > m_printAlgsSequence
GAUDI_API const std::string & hostName()
Host name.
void extSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures=false)
Reach a state from current state (whichever it is) going through the correct transitions.
#define GAUDI_MAJOR_VERSION
StatusCode reinitialize() override
Gaudi::Property< bool > m_loopCheck
constexpr static const auto FAILURE
virtual bool empty() const =0
Tell if the processor has events in the queues.
Gaudi::Property< std::map< std::string, std::string > > m_environment
AlgTypeAliasesMap & typeAliases()
#define DECLARE_OBJECT_FACTORY(x)
SmartIF< IAlgManager > & algManager()
SmartIF< DLLClassManager > m_classManager
Reference to the class manager.
void push(EventContext &&ctx) override
StatusCode start() override
Gaudi::StateMachine::State m_targetState
Internal State.
StatusCode initialize() override
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
#define GAUDI_PATCH_VERSION