Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 38 of file Service.h.

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 297 of file Service.cpp.

297  : m_name( std::move( name ) ), m_svcLocator( svcloc ) {
298  if ( m_name != "MessageSvc" ) { // the MessageSvc should not notify itself
299  m_outputLevel.declareUpdateHandler(
301  }
302 
303  // Initialize the default value from ApplicationMgr AuditAlgorithms
304  Gaudi::Property<bool> audit( false );
305  auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" );
306  if ( appMgr && appMgr->hasProperty( "AuditServices" ) ) { audit.assign( appMgr->getProperty( "AuditServices" ) ); }
307  m_auditInit = audit;
308  m_auditorInitialize = audit;
309  m_auditorStart = audit;
310  m_auditorStop = audit;
311  m_auditorFinalize = audit;
312  m_auditorReinitialize = audit;
313  m_auditorRestart = audit;
314 }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:178
Implementation of property with value of concrete type.
Definition: Property.h:352
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:168
Gaudi::Property< bool > m_auditInit
Definition: Service.h:177
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:183
std::string m_name
Service Name.
Definition: Service.h:166
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:182
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:181
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
T move(T...args)
appMgr
Definition: IOTest.py:92
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:179
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:180
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
Service::~Service ( )
overrideprotected

Standard Destructor.

Definition at line 19 of file Service.cpp.

19  {
21 }
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:169
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 316 of file Service.cpp.

316  {
317  if ( !m_pAuditorSvc ) {
318  m_pAuditorSvc = serviceLocator()->service( "AuditorSvc" );
319  if ( !m_pAuditorSvc ) { throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE ); }
320  }
321  return m_pAuditorSvc;
322 }
Define general base for Gaudi exception.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:186
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
constexpr static const auto FAILURE
Definition: StatusCode.h:86
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
StatusCode Service::configure ( )
inlineoverride

Definition at line 46 of file Service.h.

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

131  {
132 
133  StatusCode sc = handle.initialize( toolTypeAndName, handle.isPublic() ? nullptr : this, createIf );
134  if ( UNLIKELY( !sc ) ) {
135  throw GaudiException{std::string{"Cannot create handle for "} + ( handle.isPublic() ? "public" : "private" ) +
136  " tool " + toolTypeAndName,
137  name(), sc};
138  }
139 
140  return sc;
141  }
#define UNLIKELY(x)
Definition: Kernel.h:89
Define general base for Gaudi exception.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
bool isPublic() const noexcept
Definition: ToolHandle.h:40
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:200
StatusCode Service::finalize ( )
override

Definition at line 164 of file Service.cpp.

164  {
165  // m_state = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::TERMINATE,m_state);
166  return StatusCode::SUCCESS;
167 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::StateMachine::State Service::FSMState ( ) const
inlineoverride

Definition at line 52 of file Service.h.

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

Definition at line 60 of file Service.cpp.

60  {
61  ON_DEBUG debug() << "Service base class initialized successfully" << endmsg;
63  return StatusCode::SUCCESS;
64 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
#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...
Definition: StateMachine.cpp:9
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:192
const std::string & Service::name ( ) const
override

Retrieve name of the service.

Definition at line 274 of file Service.cpp.

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

get the Service's output level

Definition at line 158 of file Service.h.

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

Definition at line 237 of file Service.cpp.

237  {
238  /* @TODO
239  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
240  * is causing too many problems
241  *
242  // Default implementation is finalize+initialize
243  StatusCode sc = finalize();
244  if (sc.isFailure()) {
245  error() << "reinitialize(): cannot be finalized" << endmsg;
246  return sc;
247  }
248  sc = initialize();
249  if (sc.isFailure()) {
250  error() << "reinitialize(): cannot be initialized" << endmsg;
251  return sc;
252  }
253  */
254  return StatusCode::SUCCESS;
255 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode Service::restart ( )
override

Definition at line 258 of file Service.cpp.

258  {
259  // Default implementation is stop+start
260  StatusCode sc = stop();
261  if ( sc.isFailure() ) {
262  error() << "restart(): cannot be stopped" << endmsg;
263  return sc;
264  }
265  sc = start();
266  if ( sc.isFailure() ) {
267  error() << "restart(): cannot be started" << endmsg;
268  return sc;
269  }
270  return StatusCode::SUCCESS;
271 }
StatusCode start() override
Definition: Service.cpp:129
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
bool isFailure() const
Definition: StatusCode.h:130
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode stop() override
Definition: Service.cpp:123
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 83 of file Service.h.

83  {
84  ISvcLocator& svcLoc = *serviceLocator();
85  auto ptr = ServiceLocatorHelper( svcLoc, *this )
86  .service<T>( name, !createIf, // quiet
87  createIf );
88  if ( ptr ) {
89  psvc = ptr.get();
90  const_cast<T*>( psvc )->addRef();
91  return StatusCode::SUCCESS;
92  }
93  // else
94  psvc = nullptr;
95  return StatusCode::FAILURE;
96  }
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:274
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:277
template<class T >
StatusCode Service::service ( const std::string name,
T *&  psvc,
bool  createIf = true 
) const
inline

Definition at line 99 of file Service.h.

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

Definition at line 110 of file Service.h.

110  {
111  return ServiceLocatorHelper( *serviceLocator(), *this )
112  .service<IFace>( name, !createIf, // quiet
113  createIf );
114  }
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:274
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:277
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 119 of file Service.h.

119  {
120  return service( svcType + "/" + svcName, psvc );
121  }
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:83
SmartIF< ISvcLocator > & Service::serviceLocator ( ) const
override

Retrieve pointer to service locator.

Definition at line 277 of file Service.cpp.

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

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

Definition at line 280 of file Service.cpp.

280  {
281  const bool CREATEIF( true );
282  auto jos = serviceLocator()->service<IJobOptionsSvc>( "JobOptionsSvc", CREATEIF );
283  if ( !jos ) { throw GaudiException( "Service [JobOptionsSvc] not found", name(), StatusCode::FAILURE ); }
284 
285  // initialize messaging (except for MessageSvc)
286  if ( name() != "MessageSvc" ) {
287  // this initializes the messaging, in case property update handlers need to print
288  // and update the property value bypassing the update handler
289  m_outputLevel.value() = setUpMessaging();
290  }
291 
292  return jos->setMyProperties( name(), this );
293 }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176
Define general base for Gaudi exception.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
Main interface for the JobOptions service.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
void Service::setServiceManager ( ISvcManager ism)
overrideprivate

Definition at line 324 of file Service.cpp.

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

Definition at line 129 of file Service.cpp.

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

Definition at line 123 of file Service.cpp.

123  {
124  // stub implementation
125  return StatusCode::SUCCESS;
126 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode Service::sysFinalize ( )
override

Finalize Service.

Definition at line 135 of file Service.cpp.

135  {
136 
138 
139  try {
141  Gaudi::Guards::AuditorGuard guard( this,
142  // check if we want to audit the initialize
143  ( m_auditorFinalize ) ? auditorSvc().get() : nullptr, IAuditor::Finalize );
144  sc = finalize();
145  if ( sc.isSuccess() ) m_state = m_targetState;
146  } catch ( const GaudiException& Exception ) {
147  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
148  error() << Exception << endmsg;
149  // Stat stat( chronoSvc() , Exception.tag() ) ;
150  } catch ( const std::exception& Exception ) {
151  fatal() << " Standard std::exception is caught " << endmsg;
152  error() << Exception.what() << endmsg;
153  // Stat stat( chronoSvc() , "*std::exception*" ) ;
154  } catch ( ... ) {
155  fatal() << "UNKNOWN Exception is caught " << endmsg;
156  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
157  }
158 
159  m_pAuditorSvc = nullptr;
160  return sc;
161 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:155
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:186
StatusCode finalize() override
Definition: Service.cpp:164
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:316
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:50
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:181
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:203
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode Service::sysInitialize ( )
override

Initialize Service.

Definition at line 24 of file Service.cpp.

24  {
26  return m_initSC;
27 }
void sysInitialize_imp()
Definition: Service.cpp:29
StatusCode m_initSC
Definition: Service.h:162
T call_once(T...args)
std::once_flag m_initFlag
Definition: Service.h:163
void Service::sysInitialize_imp ( )
private

Definition at line 29 of file Service.cpp.

29  {
30 
31  try {
33  Gaudi::Guards::AuditorGuard guard( this,
34  // check if we want to audit the initialize
35  ( m_auditorInitialize ) ? auditorSvc().get() : nullptr, IAuditor::Initialize );
36 
38  if ( !m_initSC ) return;
39 
40  m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
42  return;
43  } catch ( const GaudiException& Exception ) {
44  fatal() << "in sysInitialize(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
45  error() << Exception << endmsg;
46  // Stat stat( chronoSvc() , Exception.tag() );
47  } catch ( const std::exception& Exception ) {
48  fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
49  error() << Exception.what() << endmsg;
50  // Stat stat( chronoSvc() , "*std::exception*" );
51  } catch ( ... ) {
52  fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
53  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
54  }
55 
57 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:155
StatusCode initialize() override
Definition: Service.cpp:60
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:178
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:316
StatusCode m_initSC
Definition: Service.h:162
bool isSuccess() const
Definition: StatusCode.h:267
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:280
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:203
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode Service::sysReinitialize ( )
override

Re-initialize the Service.

Definition at line 170 of file Service.cpp.

170  {
171 
172  StatusCode sc;
173 
174  // Check that the current status is the correct one.
176  error() << "sysReinitialize(): cannot reinitialize service not initialized" << endmsg;
177  return StatusCode::FAILURE;
178  }
179 
180  try {
181 
182  Gaudi::Guards::AuditorGuard guard( this,
183  // check if we want to audit the initialize
184  ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
186  sc = reinitialize();
187  return sc;
188  } catch ( const GaudiException& Exception ) {
189  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
190  error() << Exception << endmsg;
191  // Stat stat( chronoSvc() , Exception.tag() ) ;
192  } catch ( const std::exception& Exception ) {
193  fatal() << " Standard std::exception is caught " << endmsg;
194  error() << Exception.what() << endmsg;
195  // Stat stat( chronoSvc() , "*std::exception*" ) ;
196  } catch ( ... ) {
197  fatal() << "UNKNOWN Exception is caught " << endmsg;
198  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
199  }
200  return StatusCode::FAILURE;
201 }
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:316
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:182
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:50
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode reinitialize() override
Definition: Service.cpp:237
STL class.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:52
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:203
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode Service::sysRestart ( )
override

Re-initialize the Service.

Definition at line 204 of file Service.cpp.

204  {
205 
206  StatusCode sc;
207 
208  // Check that the current status is the correct one.
210  error() << "sysRestart(): cannot restart service in state " << FSMState() << " -- must be RUNNING " << endmsg;
211  return StatusCode::FAILURE;
212  }
213 
214  try {
215 
216  Gaudi::Guards::AuditorGuard guard( this,
217  // check if we want to audit the initialize
218  ( m_auditorRestart ) ? auditorSvc().get() : nullptr, IAuditor::ReStart );
219  sc = restart();
220  return sc;
221  } catch ( const GaudiException& Exception ) {
222  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
223  error() << Exception << endmsg;
224  // Stat stat( chronoSvc() , Exception.tag() ) ;
225  } catch ( const std::exception& Exception ) {
226  fatal() << " Standard std::exception is caught " << endmsg;
227  error() << Exception.what() << endmsg;
228  // Stat stat( chronoSvc() , "*std::exception*" ) ;
229  } catch ( ... ) {
230  fatal() << "UNKNOWN Exception is caught " << endmsg;
231  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
232  }
233  return StatusCode::FAILURE;
234 }
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:316
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:183
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:50
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:52
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:203
StatusCode restart() override
Definition: Service.cpp:258
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode Service::sysStart ( )
override

Initialize Service.

Definition at line 67 of file Service.cpp.

67  {
68  StatusCode sc;
69 
70  try {
72  Gaudi::Guards::AuditorGuard guard( this,
73  // check if we want to audit the initialize
74  ( m_auditorStart ) ? auditorSvc().get() : nullptr, IAuditor::Start );
75  sc = start();
76  if ( sc.isSuccess() ) m_state = m_targetState;
77  return sc;
78  } catch ( const GaudiException& Exception ) {
79  fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
80  error() << Exception << endmsg;
81  // Stat stat( chronoSvc() , Exception.tag() );
82  } catch ( const std::exception& Exception ) {
83  fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
84  fatal() << Exception.what() << endmsg;
85  // Stat stat( chronoSvc() , "*std::exception*" );
86  } catch ( ... ) {
87  fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
88  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
89  }
90 
91  return StatusCode::FAILURE;
92 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:155
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:316
StatusCode start() override
Definition: Service.cpp:129
bool isSuccess() const
Definition: StatusCode.h:267
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:50
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...
Definition: StateMachine.cpp:9
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:179
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:203
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode Service::sysStop ( )
override

Initialize Service.

Definition at line 95 of file Service.cpp.

95  {
96  StatusCode sc;
97 
98  try {
100  Gaudi::Guards::AuditorGuard guard( this,
101  // check if we want to audit the initialize
102  ( m_auditorStop ) ? auditorSvc().get() : nullptr, IAuditor::Stop );
103  sc = stop();
104  if ( sc.isSuccess() ) m_state = m_targetState;
105  return sc;
106  } catch ( const GaudiException& Exception ) {
107  fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
108  error() << Exception << endmsg;
109  // Stat stat( chronoSvc() , Exception.tag() );
110  } catch ( const std::exception& Exception ) {
111  fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
112  error() << Exception.what() << endmsg;
113  // Stat stat( chronoSvc() , "*std::exception*" );
114  } catch ( ... ) {
115  fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
116  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
117  }
118 
119  return StatusCode::FAILURE;
120 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:155
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:316
bool isSuccess() const
Definition: StatusCode.h:267
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:50
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode stop() override
Definition: Service.cpp:123
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...
Definition: StateMachine.cpp:9
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:203
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:180
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::StateMachine::State Service::targetFSMState ( ) const
inlineoverride

Definition at line 53 of file Service.h.

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

Definition at line 51 of file Service.h.

51 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85

Friends And Related Function Documentation

friend class ServiceManager
friend

Definition at line 40 of file Service.h.

Member Data Documentation

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

Definition at line 177 of file Service.h.

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

Definition at line 181 of file Service.h.

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

Definition at line 178 of file Service.h.

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

Definition at line 182 of file Service.h.

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

Definition at line 183 of file Service.h.

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

Definition at line 179 of file Service.h.

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

Definition at line 180 of file Service.h.

std::once_flag Service::m_initFlag
private

Definition at line 163 of file Service.h.

StatusCode Service::m_initSC
private

Definition at line 162 of file Service.h.

std::string Service::m_name
private

Service Name.

Definition at line 166 of file Service.h.

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

Definition at line 176 of file Service.h.

SmartIF<IAuditorSvc> Service::m_pAuditorSvc
mutableprotected

Auditor Service.

Definition at line 186 of file Service.h.

Service state.

Definition at line 153 of file Service.h.

SmartIF<ISvcLocator> Service::m_svcLocator
mutableprivate

Service Locator reference.

Definition at line 168 of file Service.h.

SmartIF<ISvcManager> Service::m_svcManager
private

Definition at line 169 of file Service.h.

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

Service state.

Definition at line 155 of file Service.h.


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