The Gaudi Framework  v30r3 (a5ef0a68)
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, "[[deprecated]] 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 36 of file Service.h.

Member Typedef Documentation

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

Definition at line 39 of file Service.h.

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 314 of file Service.cpp.

314  : m_name( std::move( name ) ), m_svcLocator( svcloc )
315 {
316  if ( m_name != "MessageSvc" ) { // the MessageSvc should not notify itself
317  m_outputLevel.declareUpdateHandler(
319  }
320 
321  // Initialize the default value from ApplicationMgr AuditAlgorithms
322  Gaudi::Property<bool> audit( false );
323  auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" );
324  if ( appMgr && appMgr->hasProperty( "AuditServices" ) ) {
325  audit.assign( appMgr->getProperty( "AuditServices" ) );
326  }
327  m_auditInit = audit;
328  m_auditorInitialize = audit;
329  m_auditorStart = audit;
330  m_auditorStop = audit;
331  m_auditorFinalize = audit;
332  m_auditorReinitialize = audit;
333  m_auditorRestart = audit;
334 }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:182
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:184
Implementation of property with value of concrete type.
Definition: Property.h:381
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:174
Gaudi::Property< bool > m_auditInit
Definition: Service.h:183
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:189
std::string m_name
Service Name.
Definition: Service.h:172
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:188
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:187
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
T move(T...args)
appMgr
Definition: IOTest.py:94
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:185
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:186
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:291
Service::~Service ( )
overrideprotected

Standard Destructor.

Definition at line 19 of file Service.cpp.

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

Member Function Documentation

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

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

Definition at line 336 of file Service.cpp.

337 {
338  if ( !m_pAuditorSvc ) {
339  m_pAuditorSvc = serviceLocator()->service( "AuditorSvc" );
340  if ( !m_pAuditorSvc ) {
341  throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE );
342  }
343  }
344  return m_pAuditorSvc;
345 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
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:79
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:291
StatusCode Service::configure ( )
inlineoverride

Definition at line 47 of file Service.h.

47 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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 136 of file Service.h.

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

Definition at line 173 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:87
Gaudi::StateMachine::State Service::FSMState ( ) const
inlineoverride

Definition at line 53 of file Service.h.

53 { return m_state; }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
StatusCode Service::initialize ( )
override

Definition at line 63 of file Service.cpp.

64 {
65  ON_DEBUG debug() << "Service base class initialized successfully" << endmsg;
67  return StatusCode::SUCCESS;
68 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
#define ON_DEBUG
Definition: Service.cpp:16
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 & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
const std::string & Service::name ( ) const
override

Retrieve name of the service.

Definition at line 288 of file Service.cpp.

288 { return m_name; }
std::string m_name
Service Name.
Definition: Service.h:172
int Service::outputLevel ( ) const
inlineprotected

get the Service's output level

Definition at line 164 of file Service.h.

164 { return m_outputLevel.value(); }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:182
StatusCode Service::reinitialize ( )
override

Definition at line 249 of file Service.cpp.

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

Definition at line 271 of file Service.cpp.

272 {
273  // Default implementation is stop+start
274  StatusCode sc = stop();
275  if ( sc.isFailure() ) {
276  error() << "restart(): cannot be stopped" << endmsg;
277  return sc;
278  }
279  sc = start();
280  if ( sc.isFailure() ) {
281  error() << "restart(): cannot be started" << endmsg;
282  return sc;
283  }
284  return StatusCode::SUCCESS;
285 }
StatusCode start() override
Definition: Service.cpp:136
bool isFailure() const
Definition: StatusCode.h:139
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
StatusCode stop() override
Definition: Service.cpp:129
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
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 84 of file Service.h.

85  {
86  ISvcLocator& svcLoc = *serviceLocator();
87  auto ptr = ServiceLocatorHelper( svcLoc, *this )
88  .service<T>( name, !createIf, // quiet
89  createIf );
90  if ( ptr ) {
91  psvc = ptr.get();
92  const_cast<T*>( psvc )->addRef();
93  return StatusCode::SUCCESS;
94  }
95  // else
96  psvc = nullptr;
97  return StatusCode::FAILURE;
98  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
an helper to share the implementation of service() among the various kernel base classes ...
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:291
template<class T >
StatusCode Service::service ( const std::string name,
T *&  psvc,
bool  createIf = true 
) const
inline

Definition at line 101 of file Service.h.

102  {
103  auto ptr = service<T>( name, createIf );
104  psvc = ( ptr ? ptr.get() : nullptr );
105  if ( psvc ) {
106  psvc->addRef();
107  return StatusCode::SUCCESS;
108  }
109  return StatusCode::FAILURE;
110  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
template<typename IFace = IService>
SmartIF<IFace> Service::service ( const std::string name,
bool  createIf = true 
) const
inline

Definition at line 113 of file Service.h.

114  {
115  return ServiceLocatorHelper( *serviceLocator(), *this )
116  .service<IFace>( name, !createIf, // quiet
117  createIf );
118  }
an helper to share the implementation of service() among the various kernel base classes ...
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:291
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 123 of file Service.h.

124  {
125  return service( svcType + "/" + svcName, psvc );
126  }
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:84
SmartIF< ISvcLocator > & Service::serviceLocator ( ) const
override

Retrieve pointer to service locator.

Definition at line 291 of file Service.cpp.

291 { return m_svcLocator; }
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:174
StatusCode Service::setProperties ( )

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

Definition at line 294 of file Service.cpp.

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

Definition at line 347 of file Service.cpp.

347 { m_svcManager = ism; }
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:175
StatusCode Service::start ( )
override

Definition at line 136 of file Service.cpp.

137 {
138  // stub implementation
139  return StatusCode::SUCCESS;
140 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode Service::stop ( )
override

Definition at line 129 of file Service.cpp.

130 {
131  // stub implementation
132  return StatusCode::SUCCESS;
133 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode Service::sysFinalize ( )
override

Finalize Service.

Definition at line 143 of file Service.cpp.

144 {
145 
147 
148  try {
150  Gaudi::Guards::AuditorGuard guard( this,
151  // check if we want to audit the initialize
152  ( m_auditorFinalize ) ? auditorSvc().get() : nullptr, IAuditor::Finalize );
153  sc = finalize();
154  if ( sc.isSuccess() ) m_state = m_targetState;
155  } catch ( const GaudiException& Exception ) {
156  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
157  error() << Exception << endmsg;
158  // Stat stat( chronoSvc() , Exception.tag() ) ;
159  } catch ( const std::exception& Exception ) {
160  fatal() << " Standard std::exception is caught " << endmsg;
161  error() << Exception.what() << endmsg;
162  // Stat stat( chronoSvc() , "*std::exception*" ) ;
163  } catch ( ... ) {
164  fatal() << "UNKNOWN Exception is caught " << endmsg;
165  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
166  }
167 
168  m_pAuditorSvc = nullptr;
169  return sc;
170 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:161
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:192
StatusCode finalize() override
Definition: Service.cpp:173
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:336
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:51
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:187
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode Service::sysInitialize ( )
override

Initialize Service.

Definition at line 25 of file Service.cpp.

26 {
28  return m_initSC;
29 }
void sysInitialize_imp()
Definition: Service.cpp:31
StatusCode m_initSC
Definition: Service.h:168
T call_once(T...args)
std::once_flag m_initFlag
Definition: Service.h:169
void Service::sysInitialize_imp ( )
private

Definition at line 31 of file Service.cpp.

32 {
33 
34  try {
36  Gaudi::Guards::AuditorGuard guard( this,
37  // check if we want to audit the initialize
38  ( m_auditorInitialize ) ? auditorSvc().get() : nullptr, IAuditor::Initialize );
39 
41  if ( !m_initSC ) return;
42 
43  m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
45  return;
46  } catch ( const GaudiException& Exception ) {
47  fatal() << "in sysInitialize(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
48  error() << Exception << endmsg;
49  // Stat stat( chronoSvc() , Exception.tag() );
50  } catch ( const std::exception& Exception ) {
51  fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
52  error() << Exception.what() << endmsg;
53  // Stat stat( chronoSvc() , "*std::exception*" );
54  } catch ( ... ) {
55  fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
56  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
57  }
58 
60 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:161
StatusCode initialize() override
Definition: Service.cpp:63
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:184
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:336
StatusCode m_initSC
Definition: Service.h:168
bool isSuccess() const
Definition: StatusCode.h:287
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T what(T...args)
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:294
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode Service::sysReinitialize ( )
override

Re-initialize the Service.

Definition at line 180 of file Service.cpp.

181 {
182 
183  StatusCode sc;
184 
185  // Check that the current status is the correct one.
187  error() << "sysReinitialize(): cannot reinitialize service not initialized" << endmsg;
188  return StatusCode::FAILURE;
189  }
190 
191  try {
192 
193  Gaudi::Guards::AuditorGuard guard( this,
194  // check if we want to audit the initialize
195  ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
197  sc = reinitialize();
198  return sc;
199  } catch ( const GaudiException& Exception ) {
200  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
201  error() << Exception << endmsg;
202  // Stat stat( chronoSvc() , Exception.tag() ) ;
203  } catch ( const std::exception& Exception ) {
204  fatal() << " Standard std::exception is caught " << endmsg;
205  error() << Exception.what() << endmsg;
206  // Stat stat( chronoSvc() , "*std::exception*" ) ;
207  } catch ( ... ) {
208  fatal() << "UNKNOWN Exception is caught " << endmsg;
209  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
210  }
211  return StatusCode::FAILURE;
212 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:336
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:188
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:51
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode reinitialize() override
Definition: Service.cpp:249
STL class.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:53
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode Service::sysRestart ( )
override

Re-initialize the Service.

Definition at line 215 of file Service.cpp.

216 {
217 
218  StatusCode sc;
219 
220  // Check that the current status is the correct one.
222  error() << "sysRestart(): cannot restart service in state " << FSMState() << " -- must be RUNNING " << endmsg;
223  return StatusCode::FAILURE;
224  }
225 
226  try {
227 
228  Gaudi::Guards::AuditorGuard guard( this,
229  // check if we want to audit the initialize
230  ( m_auditorRestart ) ? auditorSvc().get() : nullptr, IAuditor::ReStart );
231  sc = restart();
232  return sc;
233  } catch ( const GaudiException& Exception ) {
234  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
235  error() << Exception << endmsg;
236  // Stat stat( chronoSvc() , Exception.tag() ) ;
237  } catch ( const std::exception& Exception ) {
238  fatal() << " Standard std::exception is caught " << endmsg;
239  error() << Exception.what() << endmsg;
240  // Stat stat( chronoSvc() , "*std::exception*" ) ;
241  } catch ( ... ) {
242  fatal() << "UNKNOWN Exception is caught " << endmsg;
243  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
244  }
245  return StatusCode::FAILURE;
246 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:336
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:189
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:51
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:53
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
StatusCode restart() override
Definition: Service.cpp:271
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode Service::sysStart ( )
override

Initialize Service.

Definition at line 71 of file Service.cpp.

72 {
73  StatusCode sc;
74 
75  try {
77  Gaudi::Guards::AuditorGuard guard( this,
78  // check if we want to audit the initialize
79  ( m_auditorStart ) ? auditorSvc().get() : nullptr, IAuditor::Start );
80  sc = start();
81  if ( sc.isSuccess() ) m_state = m_targetState;
82  return sc;
83  } catch ( const GaudiException& Exception ) {
84  fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
85  error() << Exception << endmsg;
86  // Stat stat( chronoSvc() , Exception.tag() );
87  } catch ( const std::exception& Exception ) {
88  fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
89  fatal() << Exception.what() << endmsg;
90  // Stat stat( chronoSvc() , "*std::exception*" );
91  } catch ( ... ) {
92  fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
93  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
94  }
95 
96  return StatusCode::FAILURE;
97 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:161
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:336
StatusCode start() override
Definition: Service.cpp:136
bool isSuccess() const
Definition: StatusCode.h:287
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:51
virtual const std::string & tag() const
name tag for the exception, or exception type
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...
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:185
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode Service::sysStop ( )
override

Initialize Service.

Definition at line 100 of file Service.cpp.

101 {
102  StatusCode sc;
103 
104  try {
106  Gaudi::Guards::AuditorGuard guard( this,
107  // check if we want to audit the initialize
108  ( m_auditorStop ) ? auditorSvc().get() : nullptr, IAuditor::Stop );
109  sc = stop();
110  if ( sc.isSuccess() ) m_state = m_targetState;
111  return sc;
112  } catch ( const GaudiException& Exception ) {
113  fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
114  error() << Exception << endmsg;
115  // Stat stat( chronoSvc() , Exception.tag() );
116  } catch ( const std::exception& Exception ) {
117  fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
118  error() << Exception.what() << endmsg;
119  // Stat stat( chronoSvc() , "*std::exception*" );
120  } catch ( ... ) {
121  fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
122  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
123  }
124 
125  return StatusCode::FAILURE;
126 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:161
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:336
bool isSuccess() const
Definition: StatusCode.h:287
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:51
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode stop() override
Definition: Service.cpp:129
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...
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:186
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::StateMachine::State Service::targetFSMState ( ) const
inlineoverride

Definition at line 54 of file Service.h.

54 { return m_targetState; }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:161
StatusCode Service::terminate ( )
inlineoverride

Definition at line 52 of file Service.h.

52 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87

Friends And Related Function Documentation

friend class ServiceManager
friend

Definition at line 41 of file Service.h.

Member Data Documentation

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

Definition at line 183 of file Service.h.

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

Definition at line 187 of file Service.h.

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

Definition at line 184 of file Service.h.

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

Definition at line 188 of file Service.h.

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

Definition at line 189 of file Service.h.

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

Definition at line 185 of file Service.h.

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

Definition at line 186 of file Service.h.

std::once_flag Service::m_initFlag
private

Definition at line 169 of file Service.h.

StatusCode Service::m_initSC
private

Definition at line 168 of file Service.h.

std::string Service::m_name
private

Service Name.

Definition at line 172 of file Service.h.

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

Definition at line 182 of file Service.h.

SmartIF<IAuditorSvc> Service::m_pAuditorSvc
mutableprotected

Auditor Service.

Definition at line 192 of file Service.h.

Service state.

Definition at line 159 of file Service.h.

SmartIF<ISvcLocator> Service::m_svcLocator
mutableprivate

Service Locator reference.

Definition at line 174 of file Service.h.

SmartIF<ISvcManager> Service::m_svcManager
private

Definition at line 175 of file Service.h.

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

Service state.

Definition at line 161 of file Service.h.


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