Service Class Reference

Base class for all services. More...

#include </tmp/marcocle/lhcb-release/1122/GAUDI/GAUDI_v27r0/InstallArea/x86_64-slc6-gcc49-opt/include/GaudiKernel/Service.h>

Inheritance diagram for Service:
Collaboration diagram for Service:

Public Types

typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
using base_class = CommonMessaging
 

Public Member Functions

const std::string & name () 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...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value 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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
const std::string & name () 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...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value 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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public 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 CommonMessaging< implements3< IService, IProperty, IStateful > >
 ~CommonMessaging () override=default
 Virtual destructor. More...
 
 ~CommonMessaging () override=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
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...
 
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...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () 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...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Protected Member Functions

 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::unique_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Private Member Functions

void setServiceManager (ISvcManager *ism) override
 
void initOutputLevel (Property &prop)
 callback for output level property More...
 
void setServiceManager (ISvcManager *ism) override
 
void initOutputLevel (Property &prop)
 callback for output level property More...
 

Private Attributes

std::string m_name
 Service Name. More...
 
SmartIF< ISvcLocatorm_svcLocator
 Service Locator reference. More...
 
SmartIF< ISvcManagerm_svcManager
 
SmartIF< PropertyMgrm_propertyMgr
 Property Manager. More...
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 
BooleanProperty m_auditInit
 
bool m_auditorInitialize
 
bool m_auditorStart
 
bool m_auditorStop
 
bool m_auditorFinalize
 
bool m_auditorReinitialize
 
bool m_auditorRestart
 

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 35 of file Service.h.

Member Typedef Documentation

Definition at line 40 of file Service.h.

Definition at line 40 of file Service.h.

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 386 of file Service.cpp.

386  :
387  m_name( std::move(name) ),
388  m_svcLocator( svcloc ),
389  m_propertyMgr( new PropertyMgr() )
390 {
391  // Declare common Service properties with their defaults
392  if ( (name != "MessageSvc") && msgSvc() ) {
393  // In genconf a service is instantiated without the ApplicationMgr
395  }
396  declareProperty("OutputLevel", m_outputLevel);
398 
399  // Get the default setting for service auditing from the AppMgr
400  declareProperty("AuditServices", m_auditInit = true);
401 
402  bool audit(false);
403  auto appMgr = serviceLocator()->service<IProperty>("ApplicationMgr");
404  if (appMgr) {
405  const Property& prop = appMgr->getProperty("AuditServices");
406  if (m_name != "IncidentSvc") {
407  setProperty(prop).ignore();
408  audit = m_auditInit.value();
409  } else {
410  audit = false;
411  }
412  }
413 
414  declareProperty( "AuditInitialize" , m_auditorInitialize = audit );
415  declareProperty( "AuditStart" , m_auditorStart = audit );
416  declareProperty( "AuditStop" , m_auditorStop = audit );
417  declareProperty( "AuditFinalize" , m_auditorFinalize = audit );
418  declareProperty( "AuditReInitialize" , m_auditorReinitialize = audit );
419  declareProperty( "AuditReStart" , m_auditorRestart = audit );
420 }
BooleanProperty m_auditInit
Definition: Service.h:329
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:307
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:325
bool m_auditorInitialize
Definition: Service.h:330
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
StatusCode setProperty(const Property &p) override
Definition: Service.cpp:331
std::string m_name
Service Name.
Definition: Service.h:318
Property manager helper class.
Definition: PropertyMgr.h:35
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
virtual int outputLevel() const =0
Retrieve the current output level threshold.
bool m_auditorFinalize
Definition: Service.h:333
bool m_auditorReinitialize
Definition: Service.h:334
const TYPE & value() const
explicit conversion
Definition: Property.h:341
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:320
bool m_auditorStart
Definition: Service.h:331
void initOutputLevel(Property &prop)
callback for output level property
Definition: Service.cpp:423
tuple appMgr
Definition: IOTest.py:83
void ignore() const
Definition: StatusCode.h:108
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:212
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
bool m_auditorRestart
Definition: Service.h:335
bool m_auditorStop
Definition: Service.h:332
Service::~Service ( )
overrideprotected

Standard Destructor.

Definition at line 21 of file Service.cpp.

21  {
23 }
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:321
void ignore() const
Definition: StatusCode.h:108
virtual StatusCode removeService(IService *svc)=0
Remove a service from the "active" list of services of the factory.
Service::Service ( std::string  name,
ISvcLocator svcloc 
)

Standard Constructor.

Service::~Service ( )
overrideprotected

Standard Destructor.

Member Function Documentation

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

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

Definition at line 431 of file Service.cpp.

431  {
432  if ( !m_pAuditorSvc ) {
433  m_pAuditorSvc = serviceLocator()->service("AuditorSvc");
434  if( !m_pAuditorSvc ) {
435  throw GaudiException("Service [AuditorSvc] not found", name(), StatusCode::FAILURE);
436  }
437  }
438  return m_pAuditorSvc;
439 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:325
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:78
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:328
SmartIF<IAuditorSvc>& Service::auditorSvc ( ) const

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

StatusCode Service::configure ( )
inlineoverride

Definition at line 48 of file Service.h.

StatusCode Service::configure ( )
inlineoverride

Definition at line 48 of file Service.h.

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

Declare used Private tool.

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

Definition at line 243 of file Service.h.

244  {
245 
246  if (toolTypeAndName == "")
247  toolTypeAndName = System::typeinfoName(typeid(T));
248 
249  StatusCode sc = handle.initialize(toolTypeAndName, this, createIf);
250 
251  MsgStream log(msgSvc(), name());
252 
253  if (sc.isSuccess()) {
254  log << MSG::DEBUG << "Handle for private tool" << toolTypeAndName
255  << " successfully created and stored." << endmsg;
256  } else {
257 
258  log << MSG::ERROR << "Handle for private tool" << toolTypeAndName
259  << " could not be created." << endmsg;
260  }
261 
262  return sc;
263 
264  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:156
template<class T >
StatusCode Service::declarePrivateTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName = "",
bool  createIf = true 
)
inline

Declare used Private tool.

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

Definition at line 243 of file Service.h.

244  {
245 
246  if (toolTypeAndName == "")
247  toolTypeAndName = System::typeinfoName(typeid(T));
248 
249  StatusCode sc = handle.initialize(toolTypeAndName, this, createIf);
250 
251  MsgStream log(msgSvc(), name());
252 
253  if (sc.isSuccess()) {
254  log << MSG::DEBUG << "Handle for private tool" << toolTypeAndName
255  << " successfully created and stored." << endmsg;
256  } else {
257 
258  log << MSG::ERROR << "Handle for private tool" << toolTypeAndName
259  << " could not be created." << endmsg;
260  }
261 
262  return sc;
263 
264  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:156
template<class T >
Property* Service::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
) const
inline

Declare the named property.

MySvc ( const std::string& name ,
ISvcLocator* pSvc )
: Service ( name , pSvc )
, m_property1 ( ... )
, m_property2 ( ... )
{
// declare the property
declareProperty( "Property1" , m_property1 , "Doc for property #1" ) ;
// declare the property and attach the handler to it
declareProperty( "Property2" , m_property2 , "Doc for property #2" )
-> declareUpdateHandler( &MySvc::handler_2 ) ;
}
See also
PropertyMgr
PropertyMgr::declareProperty
Parameters
namethe property name
propertythe property itself,
docthe documentation string
Returns
the actual property objects

Definition at line 212 of file Service.h.

215  {
216  return m_propertyMgr -> declareProperty ( name , property , doc ) ;
217  }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:212
template<class T >
Property* Service::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
) const
inline

Declare the named property.

MySvc ( const std::string& name ,
ISvcLocator* pSvc )
: Service ( name , pSvc )
, m_property1 ( ... )
, m_property2 ( ... )
{
// declare the property
declareProperty( "Property1" , m_property1 , "Doc for property #1" ) ;
// declare the property and attach the handler to it
declareProperty( "Property2" , m_property2 , "Doc for property #2" )
-> declareUpdateHandler( &MySvc::handler_2 ) ;
}
See also
PropertyMgr
PropertyMgr::declareProperty
Parameters
namethe property name
propertythe property itself,
docthe documentation string
Returns
the actual property objects

Definition at line 212 of file Service.h.

215  {
216  return m_propertyMgr -> declareProperty ( name , property , doc ) ;
217  }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:212
template<class T >
StatusCode Service::declarePublicTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName = "",
bool  createIf = true 
)
inline

Declare used Public tool.

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

Definition at line 274 of file Service.h.

275  {
276 
277  if (toolTypeAndName == "")
278  toolTypeAndName = System::typeinfoName(typeid(T));
279 
280  StatusCode sc = handle.initialize(toolTypeAndName, 0, createIf);
281 
282  MsgStream log(msgSvc(), name());
283 
284  if (sc.isSuccess()) {
285  log << MSG::DEBUG << "Handle for public tool" << toolTypeAndName
286  << " successfully created and stored." << endmsg;
287  } else {
288 
289  log << MSG::ERROR << "Handle for public tool" << toolTypeAndName
290  << " could not be created." << endmsg;
291  }
292 
293  return sc;
294 
295  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:156
template<class T >
StatusCode Service::declarePublicTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName = "",
bool  createIf = true 
)
inline

Declare used Public tool.

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

Definition at line 274 of file Service.h.

275  {
276 
277  if (toolTypeAndName == "")
278  toolTypeAndName = System::typeinfoName(typeid(T));
279 
280  StatusCode sc = handle.initialize(toolTypeAndName, 0, createIf);
281 
282  MsgStream log(msgSvc(), name());
283 
284  if (sc.isSuccess()) {
285  log << MSG::DEBUG << "Handle for public tool" << toolTypeAndName
286  << " successfully created and stored." << endmsg;
287  } else {
288 
289  log << MSG::ERROR << "Handle for public tool" << toolTypeAndName
290  << " could not be created." << endmsg;
291  }
292 
293  return sc;
294 
295  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:156
Property* Service::declareRemoteProperty ( const std::string &  name,
IProperty rsvc,
const std::string &  rname = "" 
) const
inline

Declare remote named properties.

This is used to declare as a local property a property of another services or algorithm. The only needed information is IProperty interface of the remote service and the its property name if different of the current one.

Parameters
nameLocal property name
rsvcRemote IProperty interface
rnameName of the property at remote service

Definition at line 228 of file Service.h.

231  {
232  return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
233  }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
Property * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="") const
Declare remote named properties.
Definition: Service.h:228
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
Property* Service::declareRemoteProperty ( const std::string &  name,
IProperty rsvc,
const std::string &  rname = "" 
) const
inline

Declare remote named properties.

This is used to declare as a local property a property of another services or algorithm. The only needed information is IProperty interface of the remote service and the its property name if different of the current one.

Parameters
nameLocal property name
rsvcRemote IProperty interface
rnameName of the property at remote service

Definition at line 228 of file Service.h.

231  {
232  return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
233  }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
Property * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="") const
Declare remote named properties.
Definition: Service.h:228
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
StatusCode Service::finalize ( )
override
StatusCode Service::finalize ( )
override

Definition at line 188 of file Service.cpp.

188  {
189  //MsgStream log(msgSvc(),name());
190  //m_state = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::TERMINATE,m_state);
191  return StatusCode::SUCCESS;
192 }
Gaudi::StateMachine::State Service::FSMState ( ) const
inlineoverride

Definition at line 54 of file Service.h.

54 { return m_state; }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
Gaudi::StateMachine::State Service::FSMState ( ) const
inlineoverride

Definition at line 54 of file Service.h.

54 { return m_state; }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
const std::vector<Property*>& Service::getProperties ( ) const
override
const std::vector< Property * > & Service::getProperties ( ) const
override

Definition at line 355 of file Service.cpp.

355  {
356  return m_propertyMgr->getProperties();
357 }
const std::vector< Property * > & getProperties() const override
get all properties
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
StatusCode Service::getProperty ( Property p) const
override

Definition at line 343 of file Service.cpp.

343  {
344  return m_propertyMgr->getProperty(p);
345 }
StatusCode getProperty(Property *p) const override
get the property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
StatusCode Service::getProperty ( Property p) const
override
const Property & Service::getProperty ( const std::string &  name) const
override

Definition at line 347 of file Service.cpp.

347  {
348  return m_propertyMgr->getProperty(n);
349 }
StatusCode getProperty(Property *p) const override
get the property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
const Property& Service::getProperty ( const std::string &  name) const
override
StatusCode Service::getProperty ( const std::string &  n,
std::string &  v 
) const
override

Definition at line 351 of file Service.cpp.

351  {
352  return m_propertyMgr->getProperty(n,v);
353 }
StatusCode getProperty(Property *p) const override
get the property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
StatusCode Service::getProperty ( const std::string &  n,
std::string &  v 
) const
override
bool Service::hasProperty ( const std::string &  name) const
override
bool Service::hasProperty ( const std::string &  name) const
override

Definition at line 359 of file Service.cpp.

359  {
360  return m_propertyMgr->hasProperty(name);
361 }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
StatusCode Service::initialize ( )
override
StatusCode Service::initialize ( )
override

Definition at line 63 of file Service.cpp.

63  {
64  // Set the Algorithm's properties
66  ON_DEBUG debug() << "Service base class initialized successfully" << endmsg;
68  return sc ;
69 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
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:8
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:364
#define ON_DEBUG
Definition: Service.cpp:17
void Service::initOutputLevel ( Property prop)
private

callback for output level property

void Service::initOutputLevel ( Property prop)
private

callback for output level property

Definition at line 423 of file Service.cpp.

423  {
424  if ( (name() != "MessageSvc") && msgSvc() ) {
426  }
428 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:307
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
const std::string & Service::name ( ) const
override

Retrieve name of the service.

Definition at line 320 of file Service.cpp.

320  {
321  return m_name;
322 }
std::string m_name
Service Name.
Definition: Service.h:318
const std::string& Service::name ( ) const
override

Retrieve name of the service.

int Service::outputLevel ( ) const
inlineprotected

get the Service's output level

Definition at line 314 of file Service.h.

314 { return m_outputLevel.value(); }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:307
const TYPE & value() const
explicit conversion
Definition: Property.h:341
int Service::outputLevel ( ) const
inlineprotected

get the Service's output level

Definition at line 314 of file Service.h.

314 { return m_outputLevel.value(); }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:307
const TYPE & value() const
explicit conversion
Definition: Property.h:341
StatusCode Service::reinitialize ( )
override

Definition at line 283 of file Service.cpp.

283  {
284  /* @TODO
285  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
286  * is causing too many problems
287  *
288  // Default implementation is finalize+initialize
289  StatusCode sc = finalize();
290  if (sc.isFailure()) {
291  error() << "reinitialize(): cannot be finalized" << endmsg;
292  return sc;
293  }
294  sc = initialize();
295  if (sc.isFailure()) {
296  error() << "reinitialize(): cannot be initialized" << endmsg;
297  return sc;
298  }
299  */
300  return StatusCode::SUCCESS;
301 }
StatusCode Service::reinitialize ( )
override
StatusCode Service::restart ( )
override

Definition at line 304 of file Service.cpp.

304  {
305  // Default implementation is stop+start
306  StatusCode sc = stop();
307  if (sc.isFailure()) {
308  error() << "restart(): cannot be stopped" << endmsg;
309  return sc;
310  }
311  sc = start();
312  if (sc.isFailure()) {
313  error() << "restart(): cannot be started" << endmsg;
314  return sc;
315  }
316  return StatusCode::SUCCESS;
317 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode start() override
Definition: Service.cpp:147
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode stop() override
Definition: Service.cpp:141
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode Service::restart ( )
override
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 141 of file Service.h.

141  {
142  ISvcLocator& svcLoc = *serviceLocator();
143  auto ptr =
144  ServiceLocatorHelper(svcLoc, *this).service<T>(name, !createIf, // quiet
145  createIf);
146  if (ptr) {
147  psvc = ptr.get();
148  const_cast<T*>(psvc)->addRef();
149  return StatusCode::SUCCESS;
150  }
151  // else
152  psvc = nullptr;
153  return StatusCode::FAILURE;
154  }
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:325
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
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 141 of file Service.h.

141  {
142  ISvcLocator& svcLoc = *serviceLocator();
143  auto ptr =
144  ServiceLocatorHelper(svcLoc, *this).service<T>(name, !createIf, // quiet
145  createIf);
146  if (ptr) {
147  psvc = ptr.get();
148  const_cast<T*>(psvc)->addRef();
149  return StatusCode::SUCCESS;
150  }
151  // else
152  psvc = nullptr;
153  return StatusCode::FAILURE;
154  }
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:325
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
template<class T >
StatusCode Service::service ( const std::string &  name,
T *&  psvc,
bool  createIf = true 
) const
inline

Definition at line 157 of file Service.h.

157  {
158  auto ptr = service<T>(name,createIf);
159  psvc = ( ptr ? ptr.get() : nullptr );
160  if (psvc) {
161  psvc->addRef();
162  return StatusCode::SUCCESS;
163  }
164  return StatusCode::FAILURE;
165  }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
template<class T >
StatusCode Service::service ( const std::string &  name,
T *&  psvc,
bool  createIf = true 
) const
inline

Definition at line 157 of file Service.h.

157  {
158  auto ptr = service<T>(name,createIf);
159  psvc = ( ptr ? ptr.get() : nullptr );
160  if (psvc) {
161  psvc->addRef();
162  return StatusCode::SUCCESS;
163  }
164  return StatusCode::FAILURE;
165  }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
template<typename IFace = IService>
SmartIF<IFace> Service::service ( const std::string &  name,
bool  createIf = true 
) const
inline

Definition at line 168 of file Service.h.

168  {
169  return ServiceLocatorHelper(*serviceLocator(), *this).
170  service<IFace>(name, !createIf, // quiet
171  createIf);
172  }
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:325
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
template<typename IFace = IService>
SmartIF<IFace> Service::service ( const std::string &  name,
bool  createIf = true 
) const
inline

Definition at line 168 of file Service.h.

168  {
169  return ServiceLocatorHelper(*serviceLocator(), *this).
170  service<IFace>(name, !createIf, // quiet
171  createIf);
172  }
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:325
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
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 177 of file Service.h.

178  {
179  return service(svcType + "/" + svcName, psvc);
180  }
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:141
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 177 of file Service.h.

178  {
179  return service(svcType + "/" + svcName, psvc);
180  }
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:141
SmartIF<ISvcLocator>& Service::serviceLocator ( ) const
override

Retrieve pointer to service locator.

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

Retrieve pointer to service locator.

Definition at line 325 of file Service.cpp.

325  {
326  return m_svcLocator;
327 }
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:320
StatusCode Service::setProperties ( )

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

StatusCode Service::setProperties ( )

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

Definition at line 364 of file Service.cpp.

364  {
365  const bool CREATEIF(true);
366  auto jos = serviceLocator()->service<IJobOptionsSvc>("JobOptionsSvc", CREATEIF);
367  if( !jos ) {
368  throw GaudiException("Service [JobOptionsSvc] not found", name(), StatusCode::FAILURE);
369  }
370  // set first generic Properties
371  StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
372  if( sc.isFailure() ) return sc;
373 
374  // set specific Properties
375  if (isGaudiThreaded(name())) {
376  if (jos->setMyProperties( name(), this ).isFailure()) {
377  return StatusCode::FAILURE;
378  }
379  }
380  return StatusCode::SUCCESS;
381 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:325
Define general base for Gaudi exception.
GAUDI_API bool isGaudiThreaded(const std::string &name)
test if current Gaudi object is running /will run in a thread
Definition: ThreadGaudi.cpp:73
GAUDI_API std::string getGaudiThreadGenericName(const std::string &name)
helper function to extract Gaudi instance name from thread copy name
Definition: ThreadGaudi.cpp:50
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
Main interface for the JobOptions service.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode Service::setProperty ( const Property p)
override

Definition at line 331 of file Service.cpp.

331  {
332  return m_propertyMgr->setProperty(p);
333 }
StatusCode setProperty(const Property &p) override
set the property form another property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
StatusCode Service::setProperty ( const Property p)
override
StatusCode Service::setProperty ( const std::string &  s)
override
StatusCode Service::setProperty ( const std::string &  s)
override

Definition at line 335 of file Service.cpp.

335  {
336  return m_propertyMgr->setProperty(s);
337 }
StatusCode setProperty(const Property &p) override
set the property form another property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
string s
Definition: gaudirun.py:245
StatusCode Service::setProperty ( const std::string &  n,
const std::string &  v 
)
override
StatusCode Service::setProperty ( const std::string &  n,
const std::string &  v 
)
override

Definition at line 339 of file Service.cpp.

339  {
340  return m_propertyMgr->setProperty(n,v);
341 }
StatusCode setProperty(const Property &p) override
set the property form another property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
template<class TYPE >
StatusCode Service::setProperty ( const std::string &  name,
const TYPE &  value 
)
inline

set the property form the value

std::vector<double> data = ... ;
setProperty( "Data" , data ) ;
std::map<std::string,double> cuts = ... ;
setProperty( "Cuts" , cuts ) ;
std::map<std::string,std::string> dict = ... ;
setProperty( "Dictionary" , dict ) ;

Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only

This is very convenient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty

setProperty ( "OutputLevel" , "1" ) ;
setProperty ( "Enable" , "True" ) ;
setProperty ( "ErrorMax" , "10" ) ;

For simple cases it is more or less ok, but for complicated properties it is just ugly..

Parameters
namename of the property
valuevalue of the property
See also
Gaudi::Utils::setProperty
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-05-13

Definition at line 124 of file Service.h.

126  { return Gaudi::Utils::setProperty ( m_propertyMgr.get() , name , value ) ; }
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition: Property.h:1187
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
template<class TYPE >
StatusCode Service::setProperty ( const std::string &  name,
const TYPE &  value 
)
inline

set the property form the value

std::vector<double> data = ... ;
setProperty( "Data" , data ) ;
std::map<std::string,double> cuts = ... ;
setProperty( "Cuts" , cuts ) ;
std::map<std::string,std::string> dict = ... ;
setProperty( "Dictionary" , dict ) ;

Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only

This is very convenient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty

setProperty ( "OutputLevel" , "1" ) ;
setProperty ( "Enable" , "True" ) ;
setProperty ( "ErrorMax" , "10" ) ;

For simple cases it is more or less ok, but for complicated properties it is just ugly..

Parameters
namename of the property
valuevalue of the property
See also
Gaudi::Utils::setProperty
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-05-13

Definition at line 124 of file Service.h.

126  { return Gaudi::Utils::setProperty ( m_propertyMgr.get() , name , value ) ; }
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition: Property.h:1187
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:323
void Service::setServiceManager ( ISvcManager ism)
overrideprivate

Definition at line 442 of file Service.cpp.

442  {
443  m_svcManager = ism;
444 }
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:321
void Service::setServiceManager ( ISvcManager ism)
overrideprivate
StatusCode Service::start ( )
override
StatusCode Service::start ( )
override

Definition at line 147 of file Service.cpp.

147  {
148  // stub implementation
149  return StatusCode::SUCCESS;
150 }
StatusCode Service::stop ( )
override
StatusCode Service::stop ( )
override

Definition at line 141 of file Service.cpp.

141  {
142  // stub implementation
143  return StatusCode::SUCCESS;
144 }
StatusCode Service::sysFinalize ( )
override

Finalize Service.

StatusCode Service::sysFinalize ( )
override

Finalize Service.

Definition at line 153 of file Service.cpp.

153  {
154 
156 
157  try {
159  Gaudi::Guards::AuditorGuard guard(this,
160  // check if we want to audit the initialize
161  (m_auditorFinalize) ? auditorSvc().get() : nullptr,
163  sc = finalize();
164  if (sc.isSuccess())
166  }
167  catch( const GaudiException& Exception ) {
168  fatal() << " Exception with tag=" << Exception.tag()
169  << " is caught " << endmsg;
170  error() << Exception << endmsg;
171  // Stat stat( chronoSvc() , Exception.tag() ) ;
172  }
173  catch( const std::exception& Exception ) {
174  fatal() << " Standard std::exception is caught " << endmsg;
175  error() << Exception.what() << endmsg;
176  // Stat stat( chronoSvc() , "*std::exception*" ) ;
177  }
178  catch( ... ) {
179  fatal() << "UNKNOWN Exception is caught " << endmsg;
180  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
181  }
182 
183  m_pAuditorSvc = nullptr;
184  return sc;
185 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:311
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
StatusCode finalize() override
Definition: Service.cpp:188
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:431
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
bool m_auditorFinalize
Definition: Service.h:333
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:214
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:328
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode Service::sysInitialize ( )
override

Initialize Service.

Definition at line 26 of file Service.cpp.

26  {
27  StatusCode sc;
28 
29  try {
31  Gaudi::Guards::AuditorGuard guard(this,
32  // check if we want to audit the initialize
33  (m_auditorInitialize) ? auditorSvc().get() : nullptr,
35  if ((name() != "MessageSvc") && msgSvc()) // pre-set the outputLevel from the MessageSvc value
37  sc = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
38  if (sc.isSuccess())
40  return sc;
41  }
42  catch ( const GaudiException& Exception ) {
43  fatal() << "in sysInitialize(): exception with tag=" << Exception.tag()
44  << " is caught" << endmsg;
45  error() << Exception << endmsg;
46  // Stat stat( chronoSvc() , Exception.tag() );
47  }
48  catch( const std::exception& Exception ) {
49  fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
50  error() << Exception.what() << endmsg;
51  // Stat stat( chronoSvc() , "*std::exception*" );
52  }
53  catch(...) {
54  fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
55  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
56  }
57 
58  return StatusCode::FAILURE;
59 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:311
StatusCode initialize() override
Definition: Service.cpp:63
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:307
Define general base for Gaudi exception.
bool m_auditorInitialize
Definition: Service.h:330
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:431
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
virtual int outputLevel() const =0
Retrieve the current output level threshold.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
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:214
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode Service::sysInitialize ( )
override

Initialize Service.

StatusCode Service::sysReinitialize ( )
override

Re-initialize the Service.

Definition at line 195 of file Service.cpp.

195  {
196 
197  StatusCode sc;
198 
199  // Check that the current status is the correct one.
201  MsgStream log ( msgSvc() , name() );
202  error()
203  << "sysReinitialize(): cannot reinitialize service not initialized"
204  << endmsg;
205  return StatusCode::FAILURE;
206  }
207 
208  try {
209 
210  Gaudi::Guards::AuditorGuard guard(this,
211  // check if we want to audit the initialize
212  (m_auditorReinitialize) ? auditorSvc().get() : nullptr,
214  sc = reinitialize();
215  return sc;
216  }
217  catch( const GaudiException& Exception ) {
218  MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
219  fatal() << " Exception with tag=" << Exception.tag()
220  << " is caught " << endmsg;
221  error() << Exception << endmsg;
222  // Stat stat( chronoSvc() , Exception.tag() ) ;
223  }
224  catch( const std::exception& Exception ) {
225  MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
226  fatal() << " Standard std::exception is caught " << endmsg;
227  error() << Exception.what() << endmsg;
228  // Stat stat( chronoSvc() , "*std::exception*" ) ;
229  }
230  catch( ... ) {
231  MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
232  fatal() << "UNKNOWN Exception is caught " << endmsg;
233  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
234  }
235  return StatusCode::FAILURE ;
236 
237 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:54
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:431
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode reinitialize() override
Definition: Service.cpp:283
bool m_auditorReinitialize
Definition: Service.h:334
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:214
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode Service::sysReinitialize ( )
override

Re-initialize the Service.

StatusCode Service::sysRestart ( )
override

Re-initialize the Service.

StatusCode Service::sysRestart ( )
override

Re-initialize the Service.

Definition at line 240 of file Service.cpp.

240  {
241 
242  StatusCode sc;
243 
244  // Check that the current status is the correct one.
246  MsgStream log ( msgSvc() , name() );
247  error()
248  << "sysRestart(): cannot restart service in state " << FSMState()
249  << " -- must be RUNNING "
250  << endmsg;
251  return StatusCode::FAILURE;
252  }
253 
254  try {
255 
256  Gaudi::Guards::AuditorGuard guard(this,
257  // check if we want to audit the initialize
258  (m_auditorRestart) ? auditorSvc().get() : nullptr,
260  sc = restart();
261  return sc;
262  }
263  catch( const GaudiException& Exception ) {
264  fatal() << " Exception with tag=" << Exception.tag()
265  << " is caught " << endmsg;
266  error() << Exception << endmsg;
267  // Stat stat( chronoSvc() , Exception.tag() ) ;
268  }
269  catch( const std::exception& Exception ) {
270  fatal() << " Standard std::exception is caught " << endmsg;
271  error() << Exception.what() << endmsg;
272  // Stat stat( chronoSvc() , "*std::exception*" ) ;
273  }
274  catch( ... ) {
275  fatal() << "UNKNOWN Exception is caught " << endmsg;
276  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
277  }
278  return StatusCode::FAILURE ;
279 
280 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:54
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:431
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:320
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
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:214
StatusCode restart() override
Definition: Service.cpp:304
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool m_auditorRestart
Definition: Service.h:335
StatusCode Service::sysStart ( )
override

Initialize Service.

Definition at line 72 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,
81  sc = start();
82  if (sc.isSuccess())
84  return sc;
85  }
86  catch ( const GaudiException& Exception ) {
87  fatal() << "in sysStart(): exception with tag=" << Exception.tag()
88  << " is caught" << endmsg;
89  error() << Exception << endmsg;
90  // Stat stat( chronoSvc() , Exception.tag() );
91  }
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  }
97  catch(...) {
98  fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
99  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
100  }
101 
102  return StatusCode::FAILURE;
103 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:311
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:431
StatusCode start() override
Definition: Service.cpp:147
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
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:8
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
bool m_auditorStart
Definition: Service.h:331
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:214
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode Service::sysStart ( )
override

Initialize Service.

StatusCode Service::sysStop ( )
override

Initialize Service.

Definition at line 106 of file Service.cpp.

106  {
107  StatusCode sc;
108 
109  try {
111  Gaudi::Guards::AuditorGuard guard(this,
112  // check if we want to audit the initialize
113  (m_auditorStop) ? auditorSvc().get() : nullptr,
115  sc = stop();
116  if (sc.isSuccess())
118  return sc;
119  }
120  catch ( const GaudiException& Exception ) {
121  fatal() << "in sysStop(): exception with tag=" << Exception.tag()
122  << " is caught" << endmsg;
123  error() << Exception << endmsg;
124  // Stat stat( chronoSvc() , Exception.tag() );
125  }
126  catch( const std::exception& Exception ) {
127  fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
128  error() << Exception.what() << endmsg;
129  // Stat stat( chronoSvc() , "*std::exception*" );
130  }
131  catch(...) {
132  fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
133  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
134  }
135 
136  return StatusCode::FAILURE;
137 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:311
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:309
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:431
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
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:8
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode stop() override
Definition: Service.cpp:141
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:214
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool m_auditorStop
Definition: Service.h:332
StatusCode Service::sysStop ( )
override

Initialize Service.

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

Definition at line 55 of file Service.h.

55 { return m_targetState; }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:311
Gaudi::StateMachine::State Service::targetFSMState ( ) const
inlineoverride

Definition at line 55 of file Service.h.

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

Definition at line 53 of file Service.h.

StatusCode Service::terminate ( )
inlineoverride

Definition at line 53 of file Service.h.

Friends And Related Function Documentation

Definition at line 42 of file Service.h.

Member Data Documentation

BooleanProperty Service::m_auditInit
private

Definition at line 329 of file Service.h.

bool Service::m_auditorFinalize
private

Definition at line 333 of file Service.h.

bool Service::m_auditorInitialize
private

Definition at line 330 of file Service.h.

bool Service::m_auditorReinitialize
private

Definition at line 334 of file Service.h.

bool Service::m_auditorRestart
private

Definition at line 335 of file Service.h.

bool Service::m_auditorStart
private

Definition at line 331 of file Service.h.

bool Service::m_auditorStop
private

Definition at line 332 of file Service.h.

std::string Service::m_name
private

Service Name.

Definition at line 318 of file Service.h.

IntegerProperty Service::m_outputLevel = MSG::NIL
protected

Service output level.

Definition at line 307 of file Service.h.

SmartIF< IAuditorSvc > Service::m_pAuditorSvc
mutableprivate

Auditor Service.

Definition at line 328 of file Service.h.

SmartIF< PropertyMgr > Service::m_propertyMgr
private

Property Manager.

Definition at line 323 of file Service.h.

Service state.

Definition at line 309 of file Service.h.

SmartIF< ISvcLocator > Service::m_svcLocator
mutableprivate

Service Locator reference.

Definition at line 320 of file Service.h.

SmartIF< ISvcManager > Service::m_svcManager
private

Definition at line 321 of file Service.h.

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

Service state.

Definition at line 311 of file Service.h.


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