The Gaudi Framework  v33r0 (d5ea422b)
Service Class Reference

Base class for all services. More...

#include <GaudiKernel/Service.h>

Inheritance diagram for Service:
Collaboration diagram for Service:

Public Types

using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 

Public Member Functions

const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Member Functions

 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, " unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Private Member Functions

void sysInitialize_imp ()
 
void setServiceManager (ISvcManager *ism) override
 

Private Attributes

StatusCode m_initSC
 
std::once_flag m_initFlag
 
std::string m_name
 Service Name. More...
 
SmartIF< ISvcLocatorm_svcLocator
 Service Locator reference. More...
 
SmartIF< ISvcManagerm_svcManager
 

Friends

class ServiceManager
 

Detailed Description

Base class for all services.

It implements the IService and IProperty interfaces.

Author
Pere Mato
Marco Clemencic

Definition at line 46 of file Service.h.

Member Typedef Documentation

◆ Factory

using Service::Factory = Gaudi::PluginService::Factory<IService*( const std::string&, ISvcLocator* )>

Definition at line 48 of file Service.h.

Constructor & Destructor Documentation

◆ Service()

Service::Service ( std::string  name,
ISvcLocator svcloc 
)

Standard Constructor.

Definition at line 307 of file Service.cpp.

307  : m_name( std::move( name ) ), m_svcLocator( svcloc ) {
308  if ( m_name != "MessageSvc" ) { // the MessageSvc should not notify itself
309  m_outputLevel.declareUpdateHandler(
311  }
312 
313  // Initialize the default value from ApplicationMgr AuditAlgorithms
314  Gaudi::Property<bool> audit( false );
315  auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" );
316  if ( appMgr && appMgr->hasProperty( "AuditServices" ) ) { audit.assign( appMgr->getProperty( "AuditServices" ) ); }
317  m_auditInit = audit;
318  m_auditorInitialize = audit;
319  m_auditorStart = audit;
320  m_auditorStop = audit;
321  m_auditorFinalize = audit;
322  m_auditorReinitialize = audit;
323  m_auditorRestart = audit;
324 }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:186
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:188
Implementation of property with value of concrete type.
Definition: Property.h:370
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:178
Gaudi::Property< bool > m_auditInit
Definition: Service.h:187
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:193
std::string m_name
Service Name.
Definition: Service.h:176
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:192
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:191
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:42
T move(T... args)
appMgr
Definition: IOTest.py:103
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:189
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:30
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:190

◆ ~Service()

Service::~Service ( )
overrideprotected

Standard Destructor.

Definition at line 29 of file Service.cpp.

29  {
31 }
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:164
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:179
virtual StatusCode removeService(IService *svc)=0
Remove a service from the "active" list of services of the factory.

Member Function Documentation

◆ auditorSvc()

SmartIF< IAuditorSvc > & Service::auditorSvc ( ) const

The standard auditor service.May not be invoked before sysInitialize() has been invoked.

Definition at line 326 of file Service.cpp.

326  {
327  if ( !m_pAuditorSvc ) {
328  m_pAuditorSvc = serviceLocator()->service( "AuditorSvc" );
329  if ( !m_pAuditorSvc ) { throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE ); }
330  }
331  return m_pAuditorSvc;
332 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
Define general base for Gaudi exception.
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:196
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ configure()

StatusCode Service::configure ( )
inlineoverride

Definition at line 56 of file Service.h.

56 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ declareTool()

template<class T >
StatusCode Service::declareTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName,
bool  createIf = true 
)
inline

Declare used tool.

Parameters
handleToolHandle<T>
toolTypeAndName
parent,defaultpublic tool
createif necessary, default true

Definition at line 141 of file Service.h.

141  {
142 
143  StatusCode sc = handle.initialize( toolTypeAndName, handle.isPublic() ? nullptr : this, createIf );
144  if ( UNLIKELY( !sc ) ) {
145  throw GaudiException{std::string{"Cannot create handle for "} + ( handle.isPublic() ? "public" : "private" ) +
146  " tool " + toolTypeAndName,
147  name(), sc};
148  }
149 
150  return sc;
151  }
#define UNLIKELY(x)
Definition: Kernel.h:106
Define general base for Gaudi exception.
STL class.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isPublic() const noexcept
Definition: ToolHandle.h:50
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:210

◆ finalize()

StatusCode Service::finalize ( )
override

Definition at line 174 of file Service.cpp.

174  {
175  // m_state = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::TERMINATE,m_state);
176  return StatusCode::SUCCESS;
177 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ FSMState()

Gaudi::StateMachine::State Service::FSMState ( ) const
inlineoverride

Definition at line 62 of file Service.h.

62 { return m_state; }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163

◆ initialize()

StatusCode Service::initialize ( )
override

Definition at line 70 of file Service.cpp.

70  {
71  ON_DEBUG debug() << "Service base class initialized successfully" << endmsg;
73  return StatusCode::SUCCESS;
74 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
#define ON_DEBUG
Definition: Service.cpp:26
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ name()

const std::string & Service::name ( ) const
override

Retrieve name of the service.

Definition at line 284 of file Service.cpp.

284 { return m_name; }
std::string m_name
Service Name.
Definition: Service.h:176

◆ outputLevel()

int Service::outputLevel ( ) const
inlineprotected

get the Service's output level

Definition at line 168 of file Service.h.

168 { return m_outputLevel.value(); }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:186

◆ reinitialize()

StatusCode Service::reinitialize ( )
override

Definition at line 247 of file Service.cpp.

247  {
248  /* @TODO
249  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
250  * is causing too many problems
251  *
252  // Default implementation is finalize+initialize
253  StatusCode sc = finalize();
254  if (sc.isFailure()) {
255  error() << "reinitialize(): cannot be finalized" << endmsg;
256  return sc;
257  }
258  sc = initialize();
259  if (sc.isFailure()) {
260  error() << "reinitialize(): cannot be initialized" << endmsg;
261  return sc;
262  }
263  */
264  return StatusCode::SUCCESS;
265 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ restart()

StatusCode Service::restart ( )
override

Definition at line 268 of file Service.cpp.

268  {
269  // Default implementation is stop+start
270  StatusCode sc = stop();
271  if ( sc.isFailure() ) {
272  error() << "restart(): cannot be stopped" << endmsg;
273  return sc;
274  }
275  sc = start();
276  if ( sc.isFailure() ) {
277  error() << "restart(): cannot be started" << endmsg;
278  return sc;
279  }
280  return StatusCode::SUCCESS;
281 }
StatusCode start() override
Definition: Service.cpp:139
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode stop() override
Definition: Service.cpp:133
bool isFailure() const
Definition: StatusCode.h:141
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ service() [1/4]

template<class T >
StatusCode Service::service ( const std::string name,
const T *&  psvc,
bool  createIf = true 
) const
inline

Access a service by name, creating it if it doesn't already exist.

Definition at line 93 of file Service.h.

93  {
94  ISvcLocator& svcLoc = *serviceLocator();
95  auto ptr = ServiceLocatorHelper( svcLoc, *this )
96  .service<T>( name, !createIf, // quiet
97  createIf );
98  if ( ptr ) {
99  psvc = ptr.get();
100  const_cast<T*>( psvc )->addRef();
101  return StatusCode::SUCCESS;
102  }
103  // else
104  psvc = nullptr;
105  return StatusCode::FAILURE;
106  }
an helper to share the implementation of service() among the various kernel base classes
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ service() [2/4]

template<class T >
StatusCode Service::service ( const std::string name,
T *&  psvc,
bool  createIf = true 
) const
inline

Definition at line 109 of file Service.h.

109  {
110  auto ptr = service<T>( name, createIf );
111  psvc = ( ptr ? ptr.get() : nullptr );
112  if ( psvc ) {
113  psvc->addRef();
114  return StatusCode::SUCCESS;
115  }
116  return StatusCode::FAILURE;
117  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ service() [3/4]

template<typename IFace = IService>
SmartIF<IFace> Service::service ( const std::string name,
bool  createIf = true 
) const
inline

Definition at line 120 of file Service.h.

120  {
121  return ServiceLocatorHelper( *serviceLocator(), *this )
122  .service<IFace>( name, !createIf, // quiet
123  createIf );
124  }
an helper to share the implementation of service() among the various kernel base classes
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const

◆ service() [4/4]

template<class T >
StatusCode Service::service ( const std::string svcType,
const std::string svcName,
T *&  psvc 
) const
inline

Access a service by name and type, creating it if it doesn't already exist.

Definition at line 129 of file Service.h.

129  {
130  return service( svcType + "/" + svcName, psvc );
131  }
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Service.h:93

◆ serviceLocator()

SmartIF< ISvcLocator > & Service::serviceLocator ( ) const
override

Retrieve pointer to service locator.

Definition at line 287 of file Service.cpp.

287 { return m_svcLocator; }
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:178

◆ setProperties()

StatusCode Service::setProperties ( )

Method for setting declared properties to the values specified for the job.

Definition at line 290 of file Service.cpp.

290  {
291  const bool CREATEIF( true );
292  auto jos = serviceLocator()->service<IJobOptionsSvc>( "JobOptionsSvc", CREATEIF );
293  if ( !jos ) { throw GaudiException( "Service [JobOptionsSvc] not found", name(), StatusCode::FAILURE ); }
294 
295  // initialize messaging (except for MessageSvc)
296  if ( name() != "MessageSvc" ) {
297  // this initializes the messaging, in case property update handlers need to print
298  // and update the property value bypassing the update handler
299  m_outputLevel.value() = setUpMessaging();
300  }
301 
302  return jos->setMyProperties( name(), this );
303 }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:186
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
Define general base for Gaudi exception.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
Main interface for the JobOptions service.
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ setServiceManager()

void Service::setServiceManager ( ISvcManager ism)
overrideprivate

Definition at line 334 of file Service.cpp.

334 { m_svcManager = ism; }
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:179

◆ start()

StatusCode Service::start ( )
override

Definition at line 139 of file Service.cpp.

139  {
140  // stub implementation
141  return StatusCode::SUCCESS;
142 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ stop()

StatusCode Service::stop ( )
override

Definition at line 133 of file Service.cpp.

133  {
134  // stub implementation
135  return StatusCode::SUCCESS;
136 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ sysFinalize()

StatusCode Service::sysFinalize ( )
override

Finalize Service.

Definition at line 145 of file Service.cpp.

145  {
146 
148 
149  try {
151  Gaudi::Guards::AuditorGuard guard( this,
152  // check if we want to audit the initialize
153  ( m_auditorFinalize ) ? auditorSvc().get() : nullptr, IAuditor::Finalize );
154  sc = finalize();
155  if ( sc.isSuccess() ) m_state = m_targetState;
156  } catch ( const GaudiException& Exception ) {
157  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
158  error() << Exception << endmsg;
159  // Stat stat( chronoSvc() , Exception.tag() ) ;
160  } catch ( const std::exception& Exception ) {
161  fatal() << " Standard std::exception is caught " << endmsg;
162  error() << Exception.what() << endmsg;
163  // Stat stat( chronoSvc() , "*std::exception*" ) ;
164  } catch ( ... ) {
165  fatal() << "UNKNOWN Exception is caught " << endmsg;
166  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
167  }
168 
169  m_pAuditorSvc = nullptr;
170  return sc;
171 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:165
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:196
StatusCode finalize() override
Definition: Service.cpp:174
virtual const std::string & tag() const
name tag for the exception, or exception type
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:191
STL class.
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:326
constexpr static const auto FAILURE
Definition: StatusCode.h:97
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.
Definition: Guards.h:213
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ sysInitialize()

StatusCode Service::sysInitialize ( )
override

Initialize Service.

Definition at line 34 of file Service.cpp.

34  {
36  return m_initSC;
37 }
void sysInitialize_imp()
Definition: Service.cpp:39
StatusCode m_initSC
Definition: Service.h:172
T call_once(T... args)
std::once_flag m_initFlag
Definition: Service.h:173

◆ sysInitialize_imp()

void Service::sysInitialize_imp ( )
private

Definition at line 39 of file Service.cpp.

39  {
40 
41  try {
43  Gaudi::Guards::AuditorGuard guard( this,
44  // check if we want to audit the initialize
46 
48  if ( !m_initSC ) return;
49 
50  m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
52  return;
53  } catch ( const GaudiException& Exception ) {
54  fatal() << "in sysInitialize(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
55  error() << Exception << endmsg;
56  // Stat stat( chronoSvc() , Exception.tag() );
57  } catch ( const std::exception& Exception ) {
58  fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
59  error() << Exception.what() << endmsg;
60  // Stat stat( chronoSvc() , "*std::exception*" );
61  } catch ( ... ) {
62  fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
63  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
64  }
65 
67 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:165
StatusCode initialize() override
Definition: Service.cpp:70
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:188
StatusCode m_initSC
Definition: Service.h:172
virtual const std::string & tag() const
name tag for the exception, or exception type
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T... args)
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:290
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:326
constexpr static const auto FAILURE
Definition: StatusCode.h:97
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.
Definition: Guards.h:213
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ sysReinitialize()

StatusCode Service::sysReinitialize ( )
override

Re-initialize the Service.

Definition at line 180 of file Service.cpp.

180  {
181 
182  StatusCode sc;
183 
184  // Check that the current status is the correct one.
186  error() << "sysReinitialize(): cannot reinitialize service not initialized" << endmsg;
187  return StatusCode::FAILURE;
188  }
189 
190  try {
191 
192  Gaudi::Guards::AuditorGuard guard( this,
193  // check if we want to audit the initialize
194  ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
196  sc = reinitialize();
197  return sc;
198  } catch ( const GaudiException& Exception ) {
199  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
200  error() << Exception << endmsg;
201  // Stat stat( chronoSvc() , Exception.tag() ) ;
202  } catch ( const std::exception& Exception ) {
203  fatal() << " Standard std::exception is caught " << endmsg;
204  error() << Exception.what() << endmsg;
205  // Stat stat( chronoSvc() , "*std::exception*" ) ;
206  } catch ( ... ) {
207  fatal() << "UNKNOWN Exception is caught " << endmsg;
208  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
209  }
210  return StatusCode::FAILURE;
211 }
Define general base for Gaudi exception.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
virtual const std::string & tag() const
name tag for the exception, or exception type
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:192
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode reinitialize() override
Definition: Service.cpp:247
STL class.
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:326
constexpr static const auto FAILURE
Definition: StatusCode.h:97
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.
Definition: Guards.h:213
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ sysRestart()

StatusCode Service::sysRestart ( )
override

Re-initialize the Service.

Definition at line 214 of file Service.cpp.

214  {
215 
216  StatusCode sc;
217 
218  // Check that the current status is the correct one.
220  error() << "sysRestart(): cannot restart service in state " << FSMState() << " -- must be RUNNING " << endmsg;
221  return StatusCode::FAILURE;
222  }
223 
224  try {
225 
226  Gaudi::Guards::AuditorGuard guard( this,
227  // check if we want to audit the initialize
228  ( m_auditorRestart ) ? auditorSvc().get() : nullptr, IAuditor::ReStart );
229  sc = restart();
230  return sc;
231  } catch ( const GaudiException& Exception ) {
232  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
233  error() << Exception << endmsg;
234  // Stat stat( chronoSvc() , Exception.tag() ) ;
235  } catch ( const std::exception& Exception ) {
236  fatal() << " Standard std::exception is caught " << endmsg;
237  error() << Exception.what() << endmsg;
238  // Stat stat( chronoSvc() , "*std::exception*" ) ;
239  } catch ( ... ) {
240  fatal() << "UNKNOWN Exception is caught " << endmsg;
241  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
242  }
243  return StatusCode::FAILURE;
244 }
Define general base for Gaudi exception.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
virtual const std::string & tag() const
name tag for the exception, or exception type
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:193
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
STL class.
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:326
constexpr static const auto FAILURE
Definition: StatusCode.h:97
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.
Definition: Guards.h:213
StatusCode restart() override
Definition: Service.cpp:268
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ sysStart()

StatusCode Service::sysStart ( )
override

Initialize Service.

Definition at line 77 of file Service.cpp.

77  {
78  StatusCode sc;
79 
80  try {
82  Gaudi::Guards::AuditorGuard guard( this,
83  // check if we want to audit the initialize
84  ( m_auditorStart ) ? auditorSvc().get() : nullptr, IAuditor::Start );
85  sc = start();
86  if ( sc.isSuccess() ) m_state = m_targetState;
87  return sc;
88  } catch ( const GaudiException& Exception ) {
89  fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
90  error() << Exception << endmsg;
91  // Stat stat( chronoSvc() , Exception.tag() );
92  } catch ( const std::exception& Exception ) {
93  fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
94  fatal() << Exception.what() << endmsg;
95  // Stat stat( chronoSvc() , "*std::exception*" );
96  } catch ( ... ) {
97  fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
98  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
99  }
100 
101  return StatusCode::FAILURE;
102 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:165
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163
StatusCode start() override
Definition: Service.cpp:139
virtual const std::string & tag() const
name tag for the exception, or exception type
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:326
constexpr static const auto FAILURE
Definition: StatusCode.h:97
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:189
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.
Definition: Guards.h:213
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ sysStop()

StatusCode Service::sysStop ( )
override

Initialize Service.

Definition at line 105 of file Service.cpp.

105  {
106  StatusCode sc;
107 
108  try {
110  Gaudi::Guards::AuditorGuard guard( this,
111  // check if we want to audit the initialize
112  ( m_auditorStop ) ? auditorSvc().get() : nullptr, IAuditor::Stop );
113  sc = stop();
114  if ( sc.isSuccess() ) m_state = m_targetState;
115  return sc;
116  } catch ( const GaudiException& Exception ) {
117  fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
118  error() << Exception << endmsg;
119  // Stat stat( chronoSvc() , Exception.tag() );
120  } catch ( const std::exception& Exception ) {
121  fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
122  error() << Exception.what() << endmsg;
123  // Stat stat( chronoSvc() , "*std::exception*" );
124  } catch ( ... ) {
125  fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
126  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
127  }
128 
129  return StatusCode::FAILURE;
130 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:165
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163
virtual const std::string & tag() const
name tag for the exception, or exception type
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode stop() override
Definition: Service.cpp:133
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:326
constexpr static const auto FAILURE
Definition: StatusCode.h:97
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.
Definition: Guards.h:213
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:190
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ targetFSMState()

Gaudi::StateMachine::State Service::targetFSMState ( ) const
inlineoverride

Definition at line 63 of file Service.h.

63 { return m_targetState; }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:165

◆ terminate()

StatusCode Service::terminate ( )
inlineoverride

Definition at line 61 of file Service.h.

61 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

Friends And Related Function Documentation

◆ ServiceManager

friend class ServiceManager
friend

Definition at line 50 of file Service.h.

Member Data Documentation

◆ m_auditInit

Gaudi::Property<bool> Service::m_auditInit {this, "AuditServices", false, " unused"}
protected

Definition at line 187 of file Service.h.

◆ m_auditorFinalize

Gaudi::Property<bool> Service::m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
protected

Definition at line 191 of file Service.h.

◆ m_auditorInitialize

Gaudi::Property<bool> Service::m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
protected

Definition at line 188 of file Service.h.

◆ m_auditorReinitialize

Gaudi::Property<bool> Service::m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
protected

Definition at line 192 of file Service.h.

◆ m_auditorRestart

Gaudi::Property<bool> Service::m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
protected

Definition at line 193 of file Service.h.

◆ m_auditorStart

Gaudi::Property<bool> Service::m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
protected

Definition at line 189 of file Service.h.

◆ m_auditorStop

Gaudi::Property<bool> Service::m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
protected

Definition at line 190 of file Service.h.

◆ m_initFlag

std::once_flag Service::m_initFlag
private

Definition at line 173 of file Service.h.

◆ m_initSC

StatusCode Service::m_initSC
private

Definition at line 172 of file Service.h.

◆ m_name

std::string Service::m_name
private

Service Name.

Definition at line 176 of file Service.h.

◆ m_outputLevel

Gaudi::Property<int> Service::m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
protected

Definition at line 186 of file Service.h.

◆ m_pAuditorSvc

SmartIF<IAuditorSvc> Service::m_pAuditorSvc
mutableprotected

Auditor Service.

Definition at line 196 of file Service.h.

◆ m_state

Service state.

Definition at line 163 of file Service.h.

◆ m_svcLocator

SmartIF<ISvcLocator> Service::m_svcLocator
mutableprivate

Service Locator reference.

Definition at line 178 of file Service.h.

◆ m_svcManager

SmartIF<ISvcManager> Service::m_svcManager
private

Definition at line 179 of file Service.h.

◆ m_targetState

Gaudi::StateMachine::State Service::m_targetState = Gaudi::StateMachine::OFFLINE
protected

Service state.

Definition at line 165 of file Service.h.


The documentation for this class was generated from the following files: