1 #ifndef GAUDIKERNEL_SERVICE_H
2 #define GAUDIKERNEL_SERVICE_H
6 #include "GaudiKernel/IService.h"
7 #include "GaudiKernel/ISvcLocator.h"
8 #include "GaudiKernel/ServiceLocatorHelper.h"
9 #include "GaudiKernel/IProperty.h"
10 #include "GaudiKernel/IStateful.h"
11 #include "GaudiKernel/PropertyMgr.h"
12 #include "GaudiKernel/Property.h"
13 #include "GaudiKernel/IAuditorSvc.h"
14 #include "GaudiKernel/CommonMessaging.h"
15 #include "GaudiKernel/SmartIF.h"
16 #include <Gaudi/PluginService.h>
17 #include "GaudiKernel/ToolHandle.h"
45 const std::string&
name()
const override;
79 const std::vector<Property*>& getProperties( )
const override;
122 template <
class TYPE>
124 (
const std::string&
name ,
141 StatusCode service(
const std::string& name,
const T*& psvc,
bool createIf =
true )
const {
148 const_cast<T*
>(psvc)->addRef();
157 StatusCode service(
const std::string& name, T*& psvc,
bool createIf =
true )
const {
158 auto ptr = service<T>(
name,createIf);
159 psvc = ( ptr ? ptr.get() : nullptr );
167 template <
typename IFace = IService>
170 service<IFace>(
name, !createIf,
179 return service(svcType +
"/" + svcName, psvc);
212 (
const std::string& name ,
214 const std::string& doc =
"none" )
const
216 return m_propertyMgr -> declareProperty ( name , property , doc ) ;
228 (
const std::string& name ,
230 const std::string& rname =
"" )
const
232 return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
244 "",
bool createIf =
true) {
246 if (toolTypeAndName ==
"")
254 log <<
MSG::DEBUG <<
"Handle for private tool" << toolTypeAndName
255 <<
" successfully created and stored." <<
endmsg;
258 log <<
MSG::ERROR <<
"Handle for private tool" << toolTypeAndName
259 <<
" could not be created." <<
endmsg;
275 "",
bool createIf =
true) {
277 if (toolTypeAndName ==
"")
285 log <<
MSG::DEBUG <<
"Handle for public tool" << toolTypeAndName
286 <<
" successfully created and stored." <<
endmsg;
289 log <<
MSG::ERROR <<
"Handle for public tool" << toolTypeAndName
290 <<
" could not be created." <<
endmsg;
314 int outputLevel()
const {
return m_outputLevel.
value(); }
330 bool m_auditorInitialize;
333 bool m_auditorFinalize;
334 bool m_auditorReinitialize;
335 bool m_auditorRestart;
338 void initOutputLevel(
Property& prop);
341 #ifndef GAUDI_NEW_PLUGIN_SERVICE
346 template <
typename S,
typename... Args>
347 static typename S::ReturnType
create(Args&&...
args) {
348 return new T(std::forward<Args>(
args)...);
354 #define DECLARE_SERVICE_FACTORY(x) \
355 DECLARE_FACTORY_WITH_CREATOR(x, SvcFactory< x >, Service::Factory)
356 #define DECLARE_NAMED_SERVICE_FACTORY(x, n) \
357 DECLARE_FACTORY_WITH_CREATOR_AND_ID(x, SvcFactory< x >, #n, Service::Factory)
358 #define DECLARE_NAMESPACE_SERVICE_FACTORY(n, x) \
359 DECLARE_SERVICE_FACTORY(n::x)
364 #define DECLARE_SERVICE_FACTORY(x) DECLARE_COMPONENT(x)
365 #define DECLARE_NAMED_SERVICE_FACTORY(x, n) DECLARE_COMPONENT_WITH_ID(x, #n)
366 #define DECLARE_NAMESPACE_SERVICE_FACTORY(n, x) DECLARE_COMPONENT(n::x)
370 #endif // GAUDIKERNEL_SERVICE_H
The ServiceManager class is in charge of the creation of concrete instances of Services.
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 of the MsgStream class used to transmit messages.
an helper to share the implementation of service() among the various kernel base classes ...
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
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.
SmartIF< ISvcLocator > & serviceLocator() const override
Function needed by CommonMessaging.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
static S::ReturnType create(Args &&...args)
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
const char *PyHelper() getProperty(IInterface *p, char *name)
TYPE * get() const
Get interface pointer.
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
General service interface definition.
This class is used for returning status codes from appropriate routines.
The IMessage is the interface implemented by the message service.
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
const TYPE & value() const
explicit conversion
Property base class allowing Property* collections to be "homogeneous".
Class wrapping the signature for a factory with any number of arguments.
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
SmartIF< IService > service(const std::string &name, const bool quiet=false, const bool createIf=true) const
SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
Returns a smart pointer to a service.
The IProperty is the basic interface for all components which have properties that can be set or get...
Base class for all services.