2 #include "GaudiKernel/Service.h"
3 #include "GaudiKernel/PropertyMgr.h"
4 #include "GaudiKernel/IMessageSvc.h"
5 #include "GaudiKernel/MsgStream.h"
6 #include "GaudiKernel/ISvcLocator.h"
7 #include "GaudiKernel/ISvcManager.h"
8 #include "GaudiKernel/IAuditorSvc.h"
9 #include "GaudiKernel/IJobOptionsSvc.h"
10 #include "GaudiKernel/GaudiException.h"
11 #include "GaudiKernel/ServiceLocatorHelper.h"
12 #include "GaudiKernel/ThreadGaudi.h"
13 #include "GaudiKernel/Guards.h"
17 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
18 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
24 const unsigned long count = (m_refCount) ? --m_refCount : m_refCount;
44 if ((
name() !=
"MessageSvc") &&
msgSvc().isValid())
52 fatal() <<
"in sysInitialize(): exception with tag=" << Exception.
tag()
57 catch(
const std::exception& Exception ) {
58 fatal() <<
"in sysInitialize(): standard std::exception is caught" <<
endmsg;
63 fatal() <<
"in sysInitialize(): UNKNOWN Exception is caught" <<
endmsg;
96 fatal() <<
"in sysStart(): exception with tag=" << Exception.
tag()
101 catch(
const std::exception& Exception ) {
102 fatal() <<
"in sysStart(): standard std::exception is caught" <<
endmsg;
107 fatal() <<
"in sysStart(): UNKNOWN Exception is caught" <<
endmsg;
130 fatal() <<
"in sysStop(): exception with tag=" << Exception.
tag()
131 <<
" is caught" <<
endmsg;
135 catch(
const std::exception& Exception ) {
136 fatal() <<
"in sysStop(): standard std::exception is caught" <<
endmsg;
141 fatal() <<
"in sysStop(): UNKNOWN Exception is caught" <<
endmsg;
177 fatal() <<
" Exception with tag=" << Exception.
tag()
178 <<
" is caught " <<
endmsg;
182 catch(
const std::exception& Exception ) {
183 fatal() <<
" Standard std::exception is caught " <<
endmsg;
188 fatal() <<
"UNKNOWN Exception is caught " <<
endmsg;
212 <<
"sysReinitialize(): cannot reinitialize service not initialized"
228 fatal() <<
" Exception with tag=" << Exception.
tag()
229 <<
" is caught " <<
endmsg;
233 catch(
const std::exception& Exception ) {
235 fatal() <<
" Standard std::exception is caught " <<
endmsg;
241 fatal() <<
"UNKNOWN Exception is caught " <<
endmsg;
257 <<
"sysRestart(): cannot restart service in state " <<
FSMState()
258 <<
" -- must be RUNNING "
273 fatal() <<
" Exception with tag=" << Exception.
tag()
274 <<
" is caught " <<
endmsg;
278 catch(
const std::exception& Exception ) {
279 fatal() <<
" Standard std::exception is caught " <<
endmsg;
284 fatal() <<
"UNKNOWN Exception is caught " <<
endmsg;
317 error() <<
"restart(): cannot be stopped" <<
endmsg;
322 error() <<
"restart(): cannot be started" <<
endmsg;
374 const bool CREATEIF(
true);
403 if ( (name !=
"MessageSvc") &&
msgSvc().isValid() ) {
417 if (
m_name !=
"IncidentSvc") {
435 if ( (
name() !=
"MessageSvc") &&
msgSvc().isValid() ) {
virtual ~Service()
Standard Destructor.
virtual StatusCode restart()
Initialization (from RUNNING to RUNNING, via INITIALIZED).
BooleanProperty m_auditInit
Gaudi::StateMachine::State m_targetState
Service state.
SmartIF< ISvcManager > m_svcManager
Definition of the MsgStream class used to transmit messages.
IntegerProperty m_outputLevel
Service output level.
StatusCode setProperty(const Property &p)
set the property form another property
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode getProperty(Property *p) const =0
Get the property by property.
Gaudi::StateMachine::State m_state
Service state.
virtual StatusCode stop()
Stop (from RUNNING to INITIALIZED).
virtual StatusCode setProperty(const Property &p)
Set the property by property.
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
GAUDI_API bool isGaudiThreaded(const std::string &name)
test if current Gaudi object is running /will run in a thread
The ISvcManager is the interface implemented by the Service Factory in the Application Manager to sup...
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
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...
virtual StatusCode getProperty(Property *p) const
Get the property by property.
std::string m_name
Service Name.
GAUDI_API std::string getGaudiThreadGenericName(const std::string &name)
helper function to extract Gaudi instance name from thread copy name
virtual StatusCode sysFinalize()
Finalize Service.
Property manager helper class.
bool hasProperty(const std::string &name) const
Return true if we have a property with the given name.
bool isFailure() const
Test for a status code of FAILURE.
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
virtual int outputLevel() const =0
Retrieve the current output level threshold.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
This class is used for returning status codes from appropriate routines.
virtual StatusCode setMyProperties(const std::string &client, IProperty *me)=0
Override default properties of the calling client.
StatusCode getProperty(Property *p) const
get the property
virtual const std::string & tag() const
name tag for the exception, or exception type
virtual StatusCode sysStop()
Initialize Service.
bool m_auditorReinitialize
virtual Gaudi::StateMachine::State FSMState() const
Get the current state.
const TYPE & value() const
explicit conversion
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
virtual const std::string & name() const
Retrieve name of the service.
virtual StatusCode sysInitialize()
Initialize Service.
virtual StatusCode reinitialize()
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
const std::vector< Property * > & getProperties() const
get all properties
Property base class allowing Property* collections to be "homogeneous".
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
bool isValid() const
Allow for check if smart pointer is valid.
virtual unsigned long release()
Release Interface instance.
virtual StatusCode sysRestart()
Re-initialize the Service.
void initOutputLevel(Property &prop)
callback for output level property
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
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.
virtual bool hasProperty(const std::string &name) const
Return true if we have a property with the given name.
virtual StatusCode sysReinitialize()
Re-initialize the Service.
PropertyMgr * m_propertyMgr
Property Manager.
virtual StatusCode start()
Start (from INITIALIZED to RUNNING).
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
virtual StatusCode removeService(IService *svc)=0
Remove a service from the "active" list of services of the factory.
Service(const std::string &name, ISvcLocator *svcloc)
Standard Constructor.
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
virtual StatusCode sysStart()
Initialize Service.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
void setServiceManager(ISvcManager *ism)
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
virtual const std::vector< Property * > & getProperties() const
Get list of properties.
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.