| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Service Class Reference

Base class for all services. More...

`#include <GaudiKernel/Service.h>`

Inheritance diagram for Service:
[legend]
Collaboration diagram for Service:
[legend]

## Public Types
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
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 Property & | getProperty (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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (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 CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. 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...
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
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...

## Private Member Functions
void | sysInitialize_imp ()
void | setServiceManager (ISvcManager *ism) override
void | initOutputLevel (Property &prop)
| callback for output level property More...

## Private Attributes
StatusCode | m_initSC
std::once_flag | m_initFlag
std::string | m_name
| Service Name. More...
SmartIF< ISvcLocator > | m_svcLocator
| Service Locator reference. More...
SmartIF< ISvcManager > | m_svcManager
SmartIF< PropertyMgr > | m_propertyMgr
| Property Manager. More...
SmartIF< IAuditorSvc > | m_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 36 of file Service.h.

## Member Typedef Documentation

typedef Gaudi::PluginService::Factory<IService*, const std::string&, ISvcLocator*> Service::Factory

Definition at line 43 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
394 m_outputLevel = msgSvc()->outputLevel();
395 }
396 declareProperty("OutputLevel", m_outputLevel);
397 m_outputLevel.declareUpdateHandler(&Service::initOutputLevel, this);
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 }
Service::m_auditInit
BooleanProperty m_auditInit
Definition: Service.h:336
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
Service::m_auditorInitialize
bool m_auditorInitialize
Definition: Service.h:337
Property::declareUpdateHandler
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
Service::setProperty
StatusCode setProperty(const Property &p) override
Definition: Service.cpp:330
Service::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:327
Service::m_name
std::string m_name
Service Name.
Definition: Service.h:325
PropertyMgr
Property manager helper class.
Definition: PropertyMgr.h:37
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
IMessageSvc::outputLevel
virtual int outputLevel() const =0
Retrieve the current output level threshold.
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
Service::m_auditorFinalize
bool m_auditorFinalize
Definition: Service.h:340
Service::m_auditorReinitialize
bool m_auditorReinitialize
Definition: Service.h:341
std::move
T move(T...args)
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
Service::m_auditorStart
bool m_auditorStart
Definition: Service.h:338
Service::initOutputLevel
void initOutputLevel(Property &prop)
callback for output level property
Definition: Service.cpp:423
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
IOTest.appMgr
tuple appMgr
Definition: IOTest.py:83
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
Service::m_auditorRestart
bool m_auditorRestart
Definition: Service.h:342
Service::m_auditorStop
bool m_auditorStop
Definition: Service.h:339

Service::~Service | ( |  | ) |
| override protected

Standard Destructor.

Definition at line 21 of file Service.cpp.

21 {
22 if (m_svcManager) m_svcManager->removeService(this).ignore();
23 }
Service::m_svcManager
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:328
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
ISvcManager::removeService
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 428 of file Service.cpp.

428 {
429 if ( !m_pAuditorSvc ) {
430 m_pAuditorSvc = serviceLocator()->service("AuditorSvc");
431 if( !m_pAuditorSvc ) {
432 throw GaudiException("Service [AuditorSvc] not found", name(), StatusCode::FAILURE);
433 }
434 }
435 return m_pAuditorSvc;
436 }
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::m_pAuditorSvc
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:335
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
StatusCode::FAILURE
Definition: StatusCode.h:29

StatusCode Service::configure | ( |  | ) |
| inline override

Definition at line 51 of file Service.h.

51 { return StatusCode::SUCCESS; }
StatusCode::SUCCESS
Definition: StatusCode.h:30
template<class T >

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

Declare used Private tool.

Parameters

  handle | ToolHandle<T>
  toolTypeAndName |
  parent,default | public tool
  create | if necessary, default true

Definition at line 246 of file Service.h.

247 {
248
249 if (toolTypeAndName == "")
250 toolTypeAndName = System::typeinfoName(typeid(T));
251
252 StatusCode sc = handle.initialize(toolTypeAndName, this, createIf);
253
254 if (sc.isSuccess()) {
255 if (UNLIKELY(msgLevel(MSG::DEBUG)))
256 debug() << "Handle for private tool" << toolTypeAndName
257 << " successfully created and stored." << endmsg;
258 } else {
259
260 error() << "Handle for private tool" << toolTypeAndName
261 << " could not be created." << endmsg;
262 }
263
264 return sc;
265
266 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MSG::DEBUG
Definition: IMessageSvc.h:18
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ToolHandle::initialize
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:157
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:136
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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

  name | the property name
  property | the property itself,
  doc | the documentation string

Returns
  the actual property objects

Definition at line 215 of file Service.h.

218 {
219 return m_propertyMgr -> declareProperty ( name , property , doc ) ;
220 }
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
template<class T >

StatusCode Service::declarePublicTool | ( | ToolHandle< T > & | handle,
|  | std::string | toolTypeAndName = `""`,
|  | bool | createIf = `true`
| ) |  |
| inline

Declare used Public tool.

Parameters

  handle | ToolHandle<T>
  toolTypeAndName |
  parent,default | public tool
  create | if necessary, default true

Definition at line 276 of file Service.h.

277 {
278
279 if (toolTypeAndName == "")
280 toolTypeAndName = System::typeinfoName(typeid(T));
281
282 StatusCode sc = handle.initialize(toolTypeAndName, 0, createIf);
283
284
285 if (sc.isSuccess()) {
286 if (UNLIKELY(msgLevel(MSG::DEBUG)))
287 debug() << "Handle for public tool" << toolTypeAndName
288 << " successfully created and stored." << endmsg;
289 } else {
290
291 error() << "Handle for public tool" << toolTypeAndName
292 << " could not be created." << endmsg;
293 }
294
295 return sc;
296
297 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MSG::DEBUG
Definition: IMessageSvc.h:18
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ToolHandle::initialize
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:157
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:136
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

  name | Local property name
  rsvc | Remote IProperty interface
  rname | Name of the property at remote service

Definition at line 231 of file Service.h.

234 {
235 return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
236 }
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
Service::declareRemoteProperty
Property * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="") const
Declare remote named properties.
Definition: Service.h:231

StatusCode Service::finalize | ( |  | ) |
| override

Definition at line 193 of file Service.cpp.

193 {
194 //m_state = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::TERMINATE,m_state);
195 return StatusCode::SUCCESS;
196 }
StatusCode::SUCCESS
Definition: StatusCode.h:30

Gaudi::StateMachine::State Service::FSMState | ( |  | ) | const
| inline override

Definition at line 57 of file Service.h.

57 { return m_state; }
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311

const std::vector< Property * > & Service::getProperties | ( |  | ) | const
| override

Definition at line 354 of file Service.cpp.

354 {
355 return m_propertyMgr->getProperties();
356 }
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
PropertyMgr::getProperties
const std::vector< Property * > & getProperties() const override
get all properties
Definition: PropertyMgr.cpp:186

StatusCode Service::getProperty | ( | Property * | p | ) | const
| override

Definition at line 342 of file Service.cpp.

342 {
343 return m_propertyMgr->getProperty(p);
344 }
PropertyMgr::getProperty
StatusCode getProperty(Property *p) const override
get the property
Definition: PropertyMgr.cpp:144
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330

const Property & Service::getProperty | ( | const std::string & | name | ) | const
| override

Definition at line 346 of file Service.cpp.

346 {
347 return m_propertyMgr->getProperty(n);
348 }
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
PropertyMgr::getProperty
StatusCode getProperty(Property *p) const override
get the property
Definition: PropertyMgr.cpp:144
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330

StatusCode Service::getProperty | ( | const std::string & | n,
|  | std::string & | v
| ) |  | const
| override

Definition at line 350 of file Service.cpp.

350 {
351 return m_propertyMgr->getProperty(n,v);
352 }
PropertyMgr::getProperty
StatusCode getProperty(Property *p) const override
get the property
Definition: PropertyMgr.cpp:144
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330

bool Service::hasProperty | ( | const std::string & | name | ) | const
| override

Definition at line 358 of file Service.cpp.

358 {
359 return m_propertyMgr->hasProperty(name);
360 }
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
PropertyMgr::hasProperty
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
Definition: PropertyMgr.cpp:201

StatusCode Service::initialize | ( |  | ) |
| override

Definition at line 68 of file Service.cpp.

68 {
69 // Set the Algorithm's properties
70 StatusCode sc = setProperties();
71 ON_DEBUG debug() << "Service base class initialized successfully" << endmsg;
72 m_state = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::CONFIGURE,m_state);
73 return sc ;
74 }
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
merge_files.sc
int sc
Definition: merge_files.py:167
Gaudi::StateMachine::CONFIGURE
Definition: StateMachine.h:24
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Service::setProperties
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:363
ON_DEBUG
#define ON_DEBUG
Definition: Service.cpp:17
Gaudi::StateMachine::ChangeState
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
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void Service::initOutputLevel | ( | Property & | prop | ) |
| private

callback for output level property

Definition at line 423 of file Service.cpp.

423 {
424 if ( name() != "MessageSvc") updateMsgStreamOutputLevel(m_outputLevel);
425 }
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
CommonMessaging< implements< IService, IProperty, IStateful > >::updateMsgStreamOutputLevel
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Definition: CommonMessaging.h:187

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

Retrieve name of the service.

Definition at line 319 of file Service.cpp.

319 {
320 return m_name;
321 }
Service::m_name
std::string m_name
Service Name.
Definition: Service.h:325

int Service::outputLevel | ( |  | ) | const
| inline protected

get the `Service's` output level

Definition at line 316 of file Service.h.

316 { return m_outputLevel.value(); }
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341

StatusCode Service::reinitialize | ( |  | ) |
| override

Definition at line 282 of file Service.cpp.

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

StatusCode Service::restart | ( |  | ) |
| override

Definition at line 303 of file Service.cpp.

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

144 {
145 ISvcLocator& svcLoc = *serviceLocator();
146 auto ptr =
147 ServiceLocatorHelper(svcLoc, *this).service<T>(name, !createIf, // quiet
148 createIf);
149 if (ptr) {
150 psvc = ptr.get();
151 const_cast<T*>(psvc)->addRef();
152 return StatusCode::SUCCESS;
153 }
154 // else
155 psvc = nullptr;
156 return StatusCode::FAILURE;
157 }
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes ...
Definition: ServiceLocatorHelper.h:17
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
ServiceLocatorHelper::service
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
Definition: ServiceLocatorHelper.cpp:63
template<class T >

StatusCode Service::service | ( | const std::string & | name,
|  | T *& | psvc,
|  | bool | createIf = `true`
| ) |  | const
| inline

Definition at line 160 of file Service.h.

160 {
161 auto ptr = service<T>(name,createIf);
162 psvc = ( ptr ? ptr.get() : nullptr );
163 if (psvc) {
164 psvc->addRef();
165 return StatusCode::SUCCESS;
166 }
167 return StatusCode::FAILURE;
168 }
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
template<typename IFace = IService>

SmartIF<IFace> Service::service | ( | const std::string & | name,
|  | bool | createIf = `true`
| ) |  | const
| inline

Definition at line 171 of file Service.h.

171 {
172 return ServiceLocatorHelper(*serviceLocator(), *this).
173 service<IFace>(name, !createIf, // quiet
174 createIf);
175 }
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes ...
Definition: ServiceLocatorHelper.h:17
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
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 180 of file Service.h.

181 {
182 return service(svcType + "/" + svcName, psvc);
183 }
Service::service
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:144

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

Retrieve pointer to service locator.

Definition at line 324 of file Service.cpp.

324 {
325 return m_svcLocator;
326 }
Service::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Service.h:327

StatusCode Service::setProperties | ( |  | ) |

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

Definition at line 363 of file Service.cpp.

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

StatusCode Service::setProperty | ( | const Property & | p | ) |
| override

Definition at line 330 of file Service.cpp.

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

StatusCode Service::setProperty | ( | const std::string & | s | ) |
| override

Definition at line 334 of file Service.cpp.

334 {
335 return m_propertyMgr->setProperty(s);
336 }
PropertyMgr::setProperty
StatusCode setProperty(const Property &p) override
set the property form another property
Definition: PropertyMgr.cpp:105
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330

StatusCode Service::setProperty | ( | const std::string & | n,
|  | const std::string & | v
| ) |  |
| override

Definition at line 338 of file Service.cpp.

338 {
339 return m_propertyMgr->setProperty(n,v);
340 }
PropertyMgr::setProperty
StatusCode setProperty(const Property &p) override
set the property form another property
Definition: PropertyMgr.cpp:105
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
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

  name | name of the property
  value | value 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 127 of file Service.h.

129 { return Gaudi::Utils::setProperty ( m_propertyMgr.get() , name , value ) ; }
Gaudi::Utils::setProperty
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
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
Service::m_propertyMgr
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: Service.h:330
dump_component_properties.value
list value
Definition: dump_component_properties.py:12

void Service::setServiceManager | ( | ISvcManager * | ism | ) |
| override private

Definition at line 439 of file Service.cpp.

439 {
440 m_svcManager = ism;
441 }
Service::m_svcManager
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:328

StatusCode Service::start | ( |  | ) |
| override

Definition at line 152 of file Service.cpp.

152 {
153 // stub implementation
154 return StatusCode::SUCCESS;
155 }
StatusCode::SUCCESS
Definition: StatusCode.h:30

StatusCode Service::stop | ( |  | ) |
| override

Definition at line 146 of file Service.cpp.

146 {
147 // stub implementation
148 return StatusCode::SUCCESS;
149 }
StatusCode::SUCCESS
Definition: StatusCode.h:30

StatusCode Service::sysFinalize | ( |  | ) |
| override

Finalize Service.

Definition at line 158 of file Service.cpp.

158 {
159
160 StatusCode sc(StatusCode::FAILURE);
161
162 try {
163 m_targetState = Gaudi::StateMachine::OFFLINE;
164 Gaudi::Guards::AuditorGuard guard(this,
165 // check if we want to audit the initialize
166 (m_auditorFinalize) ? auditorSvc().get() : nullptr,
167 IAuditor::Finalize);
168 sc = finalize();
169 if (sc.isSuccess())
170 m_state = m_targetState;
171 }
172 catch( const GaudiException& Exception ) {
173 fatal() << " Exception with tag=" << Exception.tag()
174 << " is caught " << endmsg;
175 error() << Exception << endmsg;
176 // Stat stat( chronoSvc() , Exception.tag() ) ;
177 }
178 catch( const std::exception& Exception ) {
179 fatal() << " Standard std::exception is caught " << endmsg;
180 error() << Exception.what() << endmsg;
181 // Stat stat( chronoSvc() , "*std::exception*" ) ;
182 }
183 catch( ... ) {
184 fatal() << "UNKNOWN Exception is caught " << endmsg;
185 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
186 }
187
188 m_pAuditorSvc = nullptr;
189 return sc;
190 }
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:313
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
Service::m_pAuditorSvc
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Service.h:335
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:428
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IAuditor::Finalize
Definition: IAuditor.h:30
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
Service::m_auditorFinalize
bool m_auditorFinalize
Definition: Service.h:340
std::exception
STL class.
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
Gaudi::StateMachine::OFFLINE
Definition: StateMachine.h:13
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode Service::sysInitialize | ( |  | ) |
| override

Initialize Service.

Definition at line 26 of file Service.cpp.

26 {
27 std::call_once( m_initFlag, &Service::sysInitialize_imp, this );
28 return m_initSC;
29 }
Service::sysInitialize_imp
void sysInitialize_imp()
Definition: Service.cpp:31
Service::m_initSC
StatusCode m_initSC
Definition: Service.h:321
std::call_once
T call_once(T...args)
Service::m_initFlag
std::once_flag m_initFlag
Definition: Service.h:322

void Service::sysInitialize_imp | ( |  | ) |
| private

Definition at line 31 of file Service.cpp.

31 {
32
33 try {
34 m_targetState = Gaudi::StateMachine::INITIALIZED;
35 Gaudi::Guards::AuditorGuard guard(this,
36 // check if we want to audit the initialize
37 (m_auditorInitialize) ? auditorSvc().get() : nullptr,
38 IAuditor::Initialize);
39 if ((name() != "MessageSvc") && msgSvc()) // pre-set the outputLevel from the MessageSvc value
40 m_outputLevel = msgSvc()->outputLevel(name());
41 m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
42 if (m_initSC.isSuccess())
43 m_state = m_targetState;
44 return;
45 }
46 catch ( const GaudiException& Exception ) {
47 fatal() << "in sysInitialize(): exception with tag=" << Exception.tag()
48 << " is caught" << endmsg;
49 error() << Exception << endmsg;
50 // Stat stat( chronoSvc() , Exception.tag() );
51 }
52 catch( const std::exception& Exception ) {
53 fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
54 error() << Exception.what() << endmsg;
55 // Stat stat( chronoSvc() , "*std::exception*" );
56 }
57 catch(...) {
58 fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
59 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
60 }
61
62 m_initSC = StatusCode::FAILURE;
63
64 }
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:313
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::m_auditorInitialize
bool m_auditorInitialize
Definition: Service.h:337
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:428
Service::m_initSC
StatusCode m_initSC
Definition: Service.h:321
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
IMessageSvc::outputLevel
virtual int outputLevel() const =0
Retrieve the current output level threshold.
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
std::exception
STL class.
IAuditor::Initialize
Definition: IAuditor.h:25
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode Service::sysReinitialize | ( |  | ) |
| override

Re-initialize the Service.

Definition at line 199 of file Service.cpp.

199 {
200
201 StatusCode sc;
202
203 // Check that the current status is the correct one.
204 if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
205 error()
206 << "sysReinitialize(): cannot reinitialize service not initialized"
207 << endmsg;
208 return StatusCode::FAILURE;
209 }
210
211 try {
212
213 Gaudi::Guards::AuditorGuard guard(this,
214 // check if we want to audit the initialize
215 (m_auditorReinitialize) ? auditorSvc().get() : nullptr,
216 IAuditor::ReInitialize);
217 sc = reinitialize();
218 return sc;
219 }
220 catch( const GaudiException& Exception ) {
221 fatal() << " Exception with tag=" << Exception.tag()
222 << " is caught " << endmsg;
223 error() << Exception << endmsg;
224 // Stat stat( chronoSvc() , Exception.tag() ) ;
225 }
226 catch( const std::exception& Exception ) {
227 fatal() << " Standard std::exception is caught " << endmsg;
228 error() << Exception.what() << endmsg;
229 // Stat stat( chronoSvc() , "*std::exception*" ) ;
230 }
231 catch( ... ) {
232 fatal() << "UNKNOWN Exception is caught " << endmsg;
233 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
234 }
235 return StatusCode::FAILURE ;
236
237 }
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:57
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:428
IAuditor::ReInitialize
Definition: IAuditor.h:26
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
Service::reinitialize
StatusCode reinitialize() override
Definition: Service.cpp:282
Service::m_auditorReinitialize
bool m_auditorReinitialize
Definition: Service.h:341
std::exception
STL class.
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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.
245 if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
246 error()
247 << "sysRestart(): cannot restart service in state " << FSMState()
248 << " -- must be RUNNING "
249 << endmsg;
250 return StatusCode::FAILURE;
251 }
252
253 try {
254
255 Gaudi::Guards::AuditorGuard guard(this,
256 // check if we want to audit the initialize
257 (m_auditorRestart) ? auditorSvc().get() : nullptr,
258 IAuditor::ReStart);
259 sc = restart();
260 return sc;
261 }
262 catch( const GaudiException& Exception ) {
263 fatal() << " Exception with tag=" << Exception.tag()
264 << " is caught " << endmsg;
265 error() << Exception << endmsg;
266 // Stat stat( chronoSvc() , Exception.tag() ) ;
267 }
268 catch( const std::exception& Exception ) {
269 fatal() << " Standard std::exception is caught " << endmsg;
270 error() << Exception.what() << endmsg;
271 // Stat stat( chronoSvc() , "*std::exception*" ) ;
272 }
273 catch( ... ) {
274 fatal() << "UNKNOWN Exception is caught " << endmsg;
275 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
276 }
277 return StatusCode::FAILURE ;
278
279 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:57
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:428
merge_files.sc
int sc
Definition: merge_files.py:167
IAuditor::ReStart
Definition: IAuditor.h:33
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
std::exception
STL class.
Gaudi::StateMachine::RUNNING
Definition: StateMachine.h:16
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
Service::restart
StatusCode restart() override
Definition: Service.cpp:303
Service::m_auditorRestart
bool m_auditorRestart
Definition: Service.h:342
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode Service::sysStart | ( |  | ) |
| override

Initialize Service.

Definition at line 77 of file Service.cpp.

77 {
78 StatusCode sc;
79
80 try {
81 m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
82 Gaudi::Guards::AuditorGuard guard(this,
83 // check if we want to audit the initialize
84 (m_auditorStart) ? auditorSvc().get() : nullptr,
85 IAuditor::Start);
86 sc = start();
87 if (sc.isSuccess())
88 m_state = m_targetState;
89 return sc;
90 }
91 catch ( const GaudiException& Exception ) {
92 fatal() << "in sysStart(): exception with tag=" << Exception.tag()
93 << " is caught" << endmsg;
94 error() << Exception << endmsg;
95 // Stat stat( chronoSvc() , Exception.tag() );
96 }
97 catch( const std::exception& Exception ) {
98 fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
99 fatal() << Exception.what() << endmsg;
100 // Stat stat( chronoSvc() , "*std::exception*" );
101 }
102 catch(...) {
103 fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
104 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
105 }
106
107 return StatusCode::FAILURE;
108 }
IAuditor::Start
Definition: IAuditor.h:31
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:313
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:428
Service::start
StatusCode start() override
Definition: Service.cpp:152
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
std::exception
STL class.
Gaudi::StateMachine::ChangeState
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
Service::m_auditorStart
bool m_auditorStart
Definition: Service.h:338
Gaudi::StateMachine::START
Definition: StateMachine.h:26
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode Service::sysStop | ( |  | ) |
| override

Initialize Service.

Definition at line 111 of file Service.cpp.

111 {
112 StatusCode sc;
113
114 try {
115 m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
116 Gaudi::Guards::AuditorGuard guard(this,
117 // check if we want to audit the initialize
118 (m_auditorStop) ? auditorSvc().get() : nullptr,
119 IAuditor::Stop);
120 sc = stop();
121 if (sc.isSuccess())
122 m_state = m_targetState;
123 return sc;
124 }
125 catch ( const GaudiException& Exception ) {
126 fatal() << "in sysStop(): exception with tag=" << Exception.tag()
127 << " is caught" << endmsg;
128 error() << Exception << endmsg;
129 // Stat stat( chronoSvc() , Exception.tag() );
130 }
131 catch( const std::exception& Exception ) {
132 fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
133 error() << Exception.what() << endmsg;
134 // Stat stat( chronoSvc() , "*std::exception*" );
135 }
136 catch(...) {
137 fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
138 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
139 }
140
141 return StatusCode::FAILURE;
142 }
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:313
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
IAuditor::Stop
Definition: IAuditor.h:32
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:428
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
merge_files.sc
int sc
Definition: merge_files.py:167
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
Service::stop
StatusCode stop() override
Definition: Service.cpp:146
std::exception
STL class.
Gaudi::StateMachine::STOP
Definition: StateMachine.h:27
Gaudi::StateMachine::ChangeState
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
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Service::m_auditorStop
bool m_auditorStop
Definition: Service.h:339

Gaudi::StateMachine::State Service::targetFSMState | ( |  | ) | const
| inline override

Definition at line 58 of file Service.h.

58 { return m_targetState; }
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:313

StatusCode Service::terminate | ( |  | ) |
| inline override

Definition at line 56 of file Service.h.

56 { return StatusCode::SUCCESS; }
StatusCode::SUCCESS
Definition: StatusCode.h:30

## Friends And Related Function Documentation

friend class ServiceManager
| friend

Definition at line 45 of file Service.h.

## Member Data Documentation

BooleanProperty Service::m_auditInit
| private

Definition at line 336 of file Service.h.

bool Service::m_auditorFinalize
| private

Definition at line 340 of file Service.h.

bool Service::m_auditorInitialize
| private

Definition at line 337 of file Service.h.

bool Service::m_auditorReinitialize
| private

Definition at line 341 of file Service.h.

bool Service::m_auditorRestart
| private

Definition at line 342 of file Service.h.

bool Service::m_auditorStart
| private

Definition at line 338 of file Service.h.

bool Service::m_auditorStop
| private

Definition at line 339 of file Service.h.

std::once_flag Service::m_initFlag
| private

Definition at line 322 of file Service.h.

StatusCode Service::m_initSC
| private

Definition at line 321 of file Service.h.

std::string Service::m_name
| private

Service Name.

Definition at line 325 of file Service.h.

IntegerProperty Service::m_outputLevel = MSG::NIL
| protected

Service output level.

Definition at line 309 of file Service.h.

SmartIF<IAuditorSvc> Service::m_pAuditorSvc
| mutable private

Auditor Service.

Definition at line 335 of file Service.h.

SmartIF<PropertyMgr> Service::m_propertyMgr
| private

Property Manager.

Definition at line 330 of file Service.h.

Gaudi::StateMachine::State Service::m_state = Gaudi::StateMachine::OFFLINE
| protected

Service state.

Definition at line 311 of file Service.h.

SmartIF<ISvcLocator> Service::m_svcLocator
| mutable private

Service Locator reference.

Definition at line 327 of file Service.h.

SmartIF<ISvcManager> Service::m_svcManager
| private

Definition at line 328 of file Service.h.

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

Service state.

Definition at line 313 of file Service.h.

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

- GaudiKernel/GaudiKernel/Service.h
- GaudiKernel/src/Lib/Service.cpp