The Gaudi Framework  master (42b00024)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Service Class Reference

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/Service.h>

Inheritance diagram for Service:
Collaboration diagram for Service:

Public Types

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

Public Member Functions

const std::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...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
 requires (!Gaudi::Details::is_gaudi_property_v< TYPE >) Gaudi
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Protected Member Functions

std::vector< IAlgTool * > & tools ()
 
 ~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 > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Private Member Functions

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

Private Attributes

StatusCode m_initSC
 
std::once_flag m_initFlag
 
std::string m_name
 Service Name
More...
 
SmartIF< ISvcLocatorm_svcLocator
 Service Locator reference
More...
 
SmartIF< ISvcManagerm_svcManager
 
std::vector< IAlgTool * > m_tools
 
std::vector< BaseToolHandle * > m_toolHandles
 
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
 
bool m_toolHandlesInit = false
 

Friends

class ServiceManager
 

Detailed Description

Base class for all services. It implements the IService and IProperty interfaces.

Author
Pere Mato
Marco Clemencic

Definition at line 46 of file Service.h.

Member Typedef Documentation

◆ Factory

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

Definition at line 48 of file Service.h.

Constructor & Destructor Documentation

◆ Service()

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

Standard Constructor

Definition at line 341 of file Service.cpp.

341  : m_name( std::move( name ) ), m_svcLocator( svcloc ) {
342  if ( m_name != "MessageSvc" ) { // the MessageSvc should not notify itself
345  }
346 
347  // Initialize the default value from ApplicationMgr AuditAlgorithms
348  Gaudi::Property<bool> audit( "AuditServices", false );
349  if ( auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" ) ) {
350  appMgr->getProperty( &audit ).ignore();
351  }
352 
353  m_auditorInitialize = audit;
354  m_auditorStart = audit;
355  m_auditorStop = audit;
356  m_auditorFinalize = audit;
357  m_auditorReinitialize = audit;
358  m_auditorRestart = audit;
359 }

◆ ~Service()

Service::~Service ( )
overrideprotected

Standard Destructor

Definition at line 29 of file Service.cpp.

29  {
30  if ( m_svcManager ) m_svcManager->removeService( this ).ignore();
31 }

Member Function Documentation

◆ addToolsArray()

template<class T >
void Service::addToolsArray ( ToolHandleArray< T > &  hndlArr)
inline

Definition at line 140 of file Service.h.

140  {
141  m_toolHandleArrays.push_back( &hndlArr );
142  }

◆ auditorSvc()

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

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

Definition at line 361 of file Service.cpp.

361  {
362  if ( !m_pAuditorSvc ) {
363  m_pAuditorSvc = serviceLocator()->service( "AuditorSvc" );
364  if ( !m_pAuditorSvc ) { throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE ); }
365  }
366  return m_pAuditorSvc;
367 }

◆ configure()

StatusCode Service::configure ( )
inlineoverride

Definition at line 56 of file Service.h.

56 { return StatusCode::SUCCESS; }

◆ declareProperty() [1/2]

template<class T >
Gaudi::Details::PropertyBase* Service::declareProperty ( const std::string &  name,
ToolHandle< T > &  hndl,
const std::string &  doc = "none" 
)
inline

Definition at line 98 of file Service.h.

99  {
100  this->declareTool( hndl, hndl.typeAndName() ).ignore();
101  return PropertyHolderImpl::declareProperty( name, hndl, doc );
102  }

◆ declareProperty() [2/2]

template<class T >
Gaudi::Details::PropertyBase* Service::declareProperty ( const std::string &  name,
ToolHandleArray< T > &  hndlArr,
const std::string &  doc = "none" 
)
inline

Definition at line 133 of file Service.h.

134  {
135  addToolsArray( hndlArr );
136  return PropertyHolderImpl::declareProperty( name, hndlArr, doc );
137  }

◆ declareTool() [1/2]

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

Definition at line 105 of file Service.h.

105  {
106  return this->declareTool( handle, handle.typeAndName(), createIf );
107  }

◆ declareTool() [2/2]

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

Declare used tool.

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

Definition at line 117 of file Service.h.

117  {
118 
119  StatusCode sc = handle.initialize( toolTypeAndName, handle.isPublic() ? nullptr : this, createIf );
120  if ( !sc ) {
121  throw GaudiException{ std::string{ "Cannot create handle for " } + ( handle.isPublic() ? "public" : "private" ) +
122  " tool " + toolTypeAndName,
123  name(), sc };
124  }
125 
126  m_toolHandles.push_back( &handle );
127 
128  return sc;
129  }

◆ finalize()

StatusCode Service::finalize ( )
override

Definition at line 224 of file Service.cpp.

224  {
225  // m_state = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::TERMINATE,m_state);
226  return StatusCode::SUCCESS;
227 }

◆ FSMState()

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

Definition at line 62 of file Service.h.

62 { return m_state; }

◆ initialize()

StatusCode Service::initialize ( )
override

Definition at line 119 of file Service.cpp.

119  {
120  ON_DEBUG debug() << "Service base class initialized successfully" << endmsg;
122  return StatusCode::SUCCESS;
123 }

◆ initToolHandles()

void Service::initToolHandles ( ) const
private

Definition at line 371 of file Service.cpp.

371  {
372  auto init_one = [&]( BaseToolHandle* th ) {
373  if ( !th->isEnabled() ) {
374  if ( msgLevel( MSG::DEBUG ) && !th->typeAndName().empty() )
375  debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
376  return;
377  }
378  if ( !th->get() ) {
379  auto sc = th->retrieve();
380  if ( sc.isFailure() ) {
381  throw GaudiException( "Failed to retrieve tool " + th->typeAndName(), this->name(), StatusCode::FAILURE );
382  }
383  }
384  auto* tool = th->get();
385  if ( msgLevel( MSG::DEBUG ) )
386  debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
387  << tool->type() << ")" << endmsg;
388  m_tools.push_back( tool );
389  };
390 
391  for ( auto thArr : m_toolHandleArrays ) {
392  if ( msgLevel( MSG::DEBUG ) )
393  debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
394  // Iterate over its tools:
395  for ( auto toolHandle : thArr->getBaseArray() ) {
396  // Try to cast it into a BaseToolHandle pointer:
397  BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
398  if ( bth ) {
399  init_one( bth );
400  } else {
401  error() << "Error retrieving Tool " << toolHandle->typeAndName() << " in ToolHandleArray "
402  << thArr->propertyName() << ". Not registered" << endmsg;
403  }
404  }
405  }
406 
407  for ( BaseToolHandle* th : m_toolHandles ) init_one( th );
408 
409  m_toolHandlesInit = true;
410 }

◆ name()

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

Retrieve name of the service

Definition at line 334 of file Service.cpp.

334 { return m_name; }

◆ outputLevel()

int Service::outputLevel ( ) const
inlineprotected

get the Service's output level

Definition at line 169 of file Service.h.

169 { return m_outputLevel.value(); }

◆ reinitialize()

StatusCode Service::reinitialize ( )
override

Definition at line 297 of file Service.cpp.

297  {
298  /* @TODO
299  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
300  * is causing too many problems
301  *
302  // Default implementation is finalize+initialize
303  StatusCode sc = finalize();
304  if (sc.isFailure()) {
305  error() << "reinitialize(): cannot be finalized" << endmsg;
306  return sc;
307  }
308  sc = initialize();
309  if (sc.isFailure()) {
310  error() << "reinitialize(): cannot be initialized" << endmsg;
311  return sc;
312  }
313  */
314  return StatusCode::SUCCESS;
315 }

◆ restart()

StatusCode Service::restart ( )
override

Definition at line 318 of file Service.cpp.

318  {
319  // Default implementation is stop+start
320  StatusCode sc = stop();
321  if ( sc.isFailure() ) {
322  error() << "restart(): cannot be stopped" << endmsg;
323  return sc;
324  }
325  sc = start();
326  if ( sc.isFailure() ) {
327  error() << "restart(): cannot be started" << endmsg;
328  return sc;
329  }
330  return StatusCode::SUCCESS;
331 }

◆ service()

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

Definition at line 86 of file Service.h.

86  {
87  return ServiceLocatorHelper( *serviceLocator(), *this )
88  .service<IFace>( name, !createIf, // quiet
89  createIf );
90  }

◆ serviceLocator()

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

Retrieve pointer to service locator

Definition at line 337 of file Service.cpp.

337 { return m_svcLocator; }

◆ setServiceManager()

void Service::setServiceManager ( ISvcManager ism)
overrideprivate

Definition at line 369 of file Service.cpp.

369 { m_svcManager = ism; }

◆ start()

StatusCode Service::start ( )
override

Definition at line 188 of file Service.cpp.

188  {
189  // stub implementation
190  return StatusCode::SUCCESS;
191 }

◆ stop()

StatusCode Service::stop ( )
override

Definition at line 182 of file Service.cpp.

182  {
183  // stub implementation
184  return StatusCode::SUCCESS;
185 }

◆ sysFinalize()

StatusCode Service::sysFinalize ( )
override

Finalize Service

Definition at line 194 of file Service.cpp.

194  {
195 
197 
198  try {
201  // check if we want to audit the initialize
202  ( m_auditorFinalize ) ? auditorSvc().get() : nullptr,
204  sc = finalize();
205  if ( sc.isSuccess() ) m_state = m_targetState;
206  } catch ( const GaudiException& Exception ) {
207  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
208  error() << Exception << endmsg;
209  // Stat stat( chronoSvc() , Exception.tag() ) ;
210  } catch ( const std::exception& Exception ) {
211  fatal() << " Standard std::exception is caught " << endmsg;
212  error() << Exception.what() << endmsg;
213  // Stat stat( chronoSvc() , "*std::exception*" ) ;
214  } catch ( ... ) {
215  fatal() << "UNKNOWN Exception is caught " << endmsg;
216  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
217  }
218 
219  m_pAuditorSvc = nullptr;
220  return sc;
221 }

◆ sysInitialize()

StatusCode Service::sysInitialize ( )
override

Initialize Service

Definition at line 34 of file Service.cpp.

34  {
35  std::call_once( m_initFlag, &Service::sysInitialize_imp, this );
36  return m_initSC;
37 }

◆ sysInitialize_imp()

void Service::sysInitialize_imp ( )
private

Definition at line 39 of file Service.cpp.

39  {
40 
41  try {
44  // check if we want to audit the initialize
45  ( m_auditorInitialize ) ? auditorSvc().get() : nullptr,
47 
48  // initialize messaging (except for MessageSvc)
49  if ( name() != "MessageSvc" ) {
50  // this initializes the messaging, in case property update handlers need to print
51  // and update the property value bypassing the update handler
53  }
54 
55  bindPropertiesTo( serviceLocator()->getOptsSvc() );
56 
58  error() << "Property AutoRetrieveTools must be set TRUE if CheckToolDeps is True" << endmsg;
60  return;
61  }
62 
63  m_initSC = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
64 
65  // Check for data dependencies in AlgTools
66  // visit all sub-algs and tools, build full set. First initialize ToolHandles if needed
67  if ( m_autoRetrieveTools ) {
68  try {
70  } catch ( const GaudiException& Exception ) {
71  error() << "Service failed to initilize ToolHandles : " << Exception << endmsg;
73  return;
74  }
75 
76  if ( m_checkToolDeps ) {
77  for ( auto& itool : m_tools ) {
78  info() << " AlgTool: " << itool->name() << endmsg;
79  IDataHandleHolder* idh = dynamic_cast<IDataHandleHolder*>( itool );
80  if ( idh == 0 ) {
81  error() << "dcast to IDataHandleHolder failed" << endmsg;
82  continue;
83  }
84  if ( idh->inputDataObjs().size() != 0 ) {
85  error() << "Service " << name() << " holds AlgTool " << itool->name()
86  << " which holds at least one ReadDataHandle" << endmsg;
87  for ( auto& obj : idh->inputDataObjs() ) { error() << " -> InputHandle: " << obj << endmsg; }
89  }
90  if ( idh->outputDataObjs().size() != 0 ) {
91  error() << "Service " << name() << " holds AlgTool " << itool->name()
92  << " which holds at least one WriteDataHandle" << endmsg;
93  for ( auto& obj : idh->outputDataObjs() ) { error() << " -> OutputHandle: " << obj << endmsg; }
95  }
96  }
97  }
98  }
99 
101  return;
102  } catch ( const GaudiException& Exception ) {
103  fatal() << "in sysInitialize(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
104  error() << Exception << endmsg;
105  // Stat stat( chronoSvc() , Exception.tag() );
106  } catch ( const std::exception& Exception ) {
107  fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
108  error() << Exception.what() << endmsg;
109  // Stat stat( chronoSvc() , "*std::exception*" );
110  } catch ( ... ) {
111  fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
112  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
113  }
114 
116 }

◆ sysReinitialize()

StatusCode Service::sysReinitialize ( )
override

Re-initialize the Service.

Definition at line 230 of file Service.cpp.

230  {
231 
232  StatusCode sc;
233 
234  // Check that the current status is the correct one.
236  error() << "sysReinitialize(): cannot reinitialize service not initialized" << endmsg;
237  return StatusCode::FAILURE;
238  }
239 
240  try {
241 
243  // check if we want to audit the initialize
244  ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
246  sc = reinitialize();
247  return sc;
248  } catch ( const GaudiException& Exception ) {
249  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
250  error() << Exception << endmsg;
251  // Stat stat( chronoSvc() , Exception.tag() ) ;
252  } catch ( const std::exception& Exception ) {
253  fatal() << " Standard std::exception is caught " << endmsg;
254  error() << Exception.what() << endmsg;
255  // Stat stat( chronoSvc() , "*std::exception*" ) ;
256  } catch ( ... ) {
257  fatal() << "UNKNOWN Exception is caught " << endmsg;
258  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
259  }
260  return StatusCode::FAILURE;
261 }

◆ sysRestart()

StatusCode Service::sysRestart ( )
override

Re-initialize the Service.

Definition at line 264 of file Service.cpp.

264  {
265 
266  StatusCode sc;
267 
268  // Check that the current status is the correct one.
270  error() << "sysRestart(): cannot restart service in state " << FSMState() << " -- must be RUNNING " << endmsg;
271  return StatusCode::FAILURE;
272  }
273 
274  try {
275 
277  // check if we want to audit the initialize
279  sc = restart();
280  return sc;
281  } catch ( const GaudiException& Exception ) {
282  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
283  error() << Exception << endmsg;
284  // Stat stat( chronoSvc() , Exception.tag() ) ;
285  } catch ( const std::exception& Exception ) {
286  fatal() << " Standard std::exception is caught " << endmsg;
287  error() << Exception.what() << endmsg;
288  // Stat stat( chronoSvc() , "*std::exception*" ) ;
289  } catch ( ... ) {
290  fatal() << "UNKNOWN Exception is caught " << endmsg;
291  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
292  }
293  return StatusCode::FAILURE;
294 }

◆ sysStart()

StatusCode Service::sysStart ( )
override

Initialize Service

Definition at line 126 of file Service.cpp.

126  {
127  StatusCode sc;
128 
129  try {
132  // check if we want to audit the initialize
133  ( m_auditorStart ) ? auditorSvc().get() : nullptr, Gaudi::IAuditor::Start );
134  sc = start();
135  if ( sc.isSuccess() ) m_state = m_targetState;
136  return sc;
137  } catch ( const GaudiException& Exception ) {
138  fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
139  error() << Exception << endmsg;
140  // Stat stat( chronoSvc() , Exception.tag() );
141  } catch ( const std::exception& Exception ) {
142  fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
143  fatal() << Exception.what() << endmsg;
144  // Stat stat( chronoSvc() , "*std::exception*" );
145  } catch ( ... ) {
146  fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
147  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
148  }
149 
150  return StatusCode::FAILURE;
151 }

◆ sysStop()

StatusCode Service::sysStop ( )
override

Initialize Service

Definition at line 154 of file Service.cpp.

154  {
155  StatusCode sc;
156 
157  try {
160  // check if we want to audit the initialize
161  ( m_auditorStop ) ? auditorSvc().get() : nullptr, Gaudi::IAuditor::Stop );
162  sc = stop();
163  if ( sc.isSuccess() ) m_state = m_targetState;
164  return sc;
165  } catch ( const GaudiException& Exception ) {
166  fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
167  error() << Exception << endmsg;
168  // Stat stat( chronoSvc() , Exception.tag() );
169  } catch ( const std::exception& Exception ) {
170  fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
171  error() << Exception.what() << endmsg;
172  // Stat stat( chronoSvc() , "*std::exception*" );
173  } catch ( ... ) {
174  fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
175  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
176  }
177 
178  return StatusCode::FAILURE;
179 }

◆ targetFSMState()

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

Definition at line 63 of file Service.h.

63 { return m_targetState; }

◆ terminate()

StatusCode Service::terminate ( )
inlineoverride

Definition at line 61 of file Service.h.

61 { return StatusCode::SUCCESS; }

◆ tools() [1/2]

std::vector< IAlgTool * > & Service::tools ( )
protected

Definition at line 418 of file Service.cpp.

418  {
420 
421  return m_tools;
422 }

◆ tools() [2/2]

const std::vector< IAlgTool * > & Service::tools ( ) const

Definition at line 412 of file Service.cpp.

412  {
414 
415  return m_tools;
416 }

Friends And Related Function Documentation

◆ ServiceManager

friend class ServiceManager
friend

Definition at line 50 of file Service.h.

Member Data Documentation

◆ m_auditorFinalize

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

Definition at line 197 of file Service.h.

◆ m_auditorInitialize

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

Definition at line 194 of file Service.h.

◆ m_auditorReinitialize

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

Definition at line 198 of file Service.h.

◆ m_auditorRestart

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

Definition at line 199 of file Service.h.

◆ m_auditorStart

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

Definition at line 195 of file Service.h.

◆ m_auditorStop

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

Definition at line 196 of file Service.h.

◆ m_autoRetrieveTools

Gaudi::Property<bool> Service::m_autoRetrieveTools
protected
Initial value:
{ this, "AutoRetrieveTools", true,
"retrieve all AlgTools during initialize" }

Definition at line 201 of file Service.h.

◆ m_checkToolDeps

Gaudi::Property<bool> Service::m_checkToolDeps
protected
Initial value:
{ this, "CheckToolDeps", true,
"check data dependencies of AlgTools (error if any found)" }

Definition at line 203 of file Service.h.

◆ m_initFlag

std::once_flag Service::m_initFlag
private

Definition at line 174 of file Service.h.

◆ m_initSC

StatusCode Service::m_initSC
private

Definition at line 173 of file Service.h.

◆ m_name

std::string Service::m_name
private

Service Name

Definition at line 177 of file Service.h.

◆ m_outputLevel

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

flag indicating whether ToolHandle tools have been added to m_tools

Definition at line 193 of file Service.h.

◆ m_pAuditorSvc

SmartIF<IAuditorSvc> Service::m_pAuditorSvc
mutableprotected

Auditor Service

Definition at line 207 of file Service.h.

◆ m_state

Service state

Definition at line 164 of file Service.h.

◆ m_svcLocator

SmartIF<ISvcLocator> Service::m_svcLocator
mutableprivate

Service Locator reference

Definition at line 179 of file Service.h.

◆ m_svcManager

SmartIF<ISvcManager> Service::m_svcManager
private

Definition at line 180 of file Service.h.

◆ m_targetState

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

Service state

Definition at line 166 of file Service.h.

◆ m_toolHandleArrays

std::vector<GaudiHandleArrayBase*> Service::m_toolHandleArrays
mutableprivate

Definition at line 187 of file Service.h.

◆ m_toolHandles

std::vector<BaseToolHandle*> Service::m_toolHandles
mutableprivate

Definition at line 186 of file Service.h.

◆ m_toolHandlesInit

bool Service::m_toolHandlesInit = false
mutableprivate

Definition at line 188 of file Service.h.

◆ m_tools

std::vector<IAlgTool*> Service::m_tools
mutableprivate

Definition at line 185 of file Service.h.


The documentation for this class was generated from the following files:
IDataHandleHolder
Definition: IDataHandleHolder.h:24
Service::m_auditorStart
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:195
ServiceLocatorHelper::service
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
Definition: ServiceLocatorHelper.cpp:50
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
Service::m_auditorStop
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:196
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
Service::m_pAuditorSvc
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service
Definition: Service.h:207
Gaudi::IAuditor::Start
static constexpr std::string Start
Definition: IAuditor.h:49
Service::m_toolHandlesInit
bool m_toolHandlesInit
Definition: Service.h:188
Service::m_toolHandleArrays
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition: Service.h:187
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:119
Service::m_state
Gaudi::StateMachine::State m_state
Service state
Definition: Service.h:164
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:315
Service::m_initSC
StatusCode m_initSC
Definition: Service.h:173
Service::start
StatusCode start() override
Definition: Service.cpp:188
Service::sysInitialize_imp
void sysInitialize_imp()
Definition: Service.cpp:39
Service::addToolsArray
void addToolsArray(ToolHandleArray< T > &hndlArr)
Definition: Service.h:140
GaudiException
Definition: GaudiException.h:32
Gaudi::IAuditor::Finalize
static constexpr std::string Finalize
Definition: IAuditor.h:53
GaudiPartProp.decorators.get
get
decorate the vector of properties
Definition: decorators.py:283
Service::m_auditorInitialize
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:194
Service::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference
Definition: Service.h:179
Service::m_auditorReinitialize
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:198
Service::initToolHandles
void initToolHandles() const
Definition: Service.cpp:371
IDataHandleHolder::inputDataObjs
virtual const DataObjIDColl & inputDataObjs() const =0
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:224
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:255
Gaudi::Guards::AuditorGuard
Definition: Guards.h:204
Service::m_name
std::string m_name
Service Name
Definition: Service.h:177
Service::m_initFlag
std::once_flag m_initFlag
Definition: Service.h:174
ON_DEBUG
#define ON_DEBUG
Definition: Service.cpp:26
bug_34121.tool
tool
Definition: bug_34121.py:18
CommonMessaging< implements< IService, IProperty, IStateful > >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:174
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:334
StatusCode
Definition: StatusCode.h:65
Gaudi::IAuditor::ReStart
static constexpr std::string ReStart
Definition: IAuditor.h:50
Service::m_tools
std::vector< IAlgTool * > m_tools
Definition: Service.h:185
Service::m_auditorFinalize
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:197
IDataHandleHolder::outputDataObjs
virtual const DataObjIDColl & outputDataObjs() const =0
Gaudi::StateMachine::OFFLINE
@ OFFLINE
Definition: StateMachine.h:23
Service::m_auditorRestart
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:199
Gaudi::Property::declareUpdateHandler
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:141
Gaudi::IAuditor::ReInitialize
static constexpr std::string ReInitialize
Definition: IAuditor.h:48
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:235
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes
Definition: ServiceLocatorHelper.h:27
CommonMessaging< implements< IService, IProperty, IStateful > >::updateMsgStreamOutputLevel
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Definition: CommonMessaging.h:185
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::StateMachine::RUNNING
@ RUNNING
Definition: StateMachine.h:26
Gaudi::IAuditor::Stop
static constexpr std::string Stop
Definition: IAuditor.h:52
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:140
ToolHandleInfo::isPublic
bool isPublic() const noexcept
Definition: ToolHandle.h:55
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:19
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
Definition: PropertyHolder.h:101
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Service::stop
StatusCode stop() override
Definition: Service.cpp:182
Service::m_autoRetrieveTools
Gaudi::Property< bool > m_autoRetrieveTools
Definition: Service.h:201
BaseToolHandle
Definition: ToolHandle.h:84
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
Gaudi::StateMachine::START
@ START
Definition: StateMachine.h:36
Service::m_svcManager
SmartIF< ISvcManager > m_svcManager
Definition: Service.h:180
Service::reinitialize
StatusCode reinitialize() override
Definition: Service.cpp:297
Gaudi::IAuditor::Initialize
static constexpr std::string Initialize
Definition: IAuditor.h:47
Service::m_targetState
Gaudi::StateMachine::State m_targetState
Service state
Definition: Service.h:166
ToolHandle::initialize
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:217
ToolHandle::typeAndName
std::string typeAndName() const override
Definition: ToolHandle.h:277
Service::declareTool
StatusCode declareTool(ToolHandle< T > &handle, bool createIf=true)
Definition: Service.h:105
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Service::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Service.cpp:361
Gaudi::Details::Property::ParsingErrorPolicy::Exception
@ Exception
Service::restart
StatusCode restart() override
Definition: Service.cpp:318
IOTest.appMgr
appMgr
Definition: IOTest.py:105
Service::m_checkToolDeps
Gaudi::Property< bool > m_checkToolDeps
Definition: Service.h:203
Gaudi::StateMachine::CONFIGURE
@ CONFIGURE
Definition: StateMachine.h:34
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
flag indicating whether ToolHandle tools have been added to m_tools
Definition: Service.h:193
Gaudi::Property< bool >
Gaudi::StateMachine::STOP
@ STOP
Definition: StateMachine.h:37
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:337
Service::m_toolHandles
std::vector< BaseToolHandle * > m_toolHandles
Definition: Service.h:186