Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ISvcManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_ISVCMANAGER_H
12 #define GAUDIKERNEL_ISVCMANAGER_H
13 
14 // Include files
16 #include "GaudiKernel/SmartIF.h"
18 #include <string>
19 
20 // Forward class declaration
21 #if defined( GAUDI_V20_COMPAT ) || ( !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR ) )
22 class ISvcFactory;
23 # include "GaudiKernel/IService.h"
24 #else
25 class IService;
26 #endif
27 class ISvcLocator;
28 
38 class GAUDI_API ISvcManager : virtual public IComponentManager {
39 public:
42 
43  static const int DEFAULT_SVC_PRIORITY = 100;
44 
50  virtual StatusCode addService( IService* svc, int prio = DEFAULT_SVC_PRIORITY ) = 0;
51 
52 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
53 
58  virtual StatusCode addService( const std::string& typ, const std::string& nam, int prio ) {
59  return addService( Gaudi::Utils::TypeNameString( nam, typ ), prio );
60  }
61 #endif
62 
68  virtual StatusCode addService( const Gaudi::Utils::TypeNameString& nametype, int prio = DEFAULT_SVC_PRIORITY ) = 0;
69 
75  virtual StatusCode removeService( IService* svc ) = 0;
76 
82  virtual StatusCode removeService( std::string_view nam ) = 0;
83 
84 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
85 
91  virtual StatusCode declareSvcFactory( const ISvcFactory& /*factory*/, const std::string& /*svctype*/ ) {
92  // This function is never used.
93  return StatusCode::FAILURE;
94  }
95 #endif
96 
103  virtual StatusCode declareSvcType( std::string svcname, std::string svctype ) = 0;
104 
121 
122 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
123 
131  virtual StatusCode createService( const std::string& svctype, const std::string& svcname, IService*& svc ) {
132  SmartIF<IService> s = createService( svctype + "/" + svcname );
133  svc = s.get();
134  if ( svc ) {
135  svc->addRef(); // Needed to maintain the correct reference counting.
136  return StatusCode::SUCCESS;
137  }
138  return StatusCode::FAILURE;
139  }
140 
147  virtual StatusCode getFactory( const std::string& /*svc_type*/, const ISvcFactory*& /*fac*/ ) const {
148  // This function is never used.
149  return StatusCode::FAILURE;
150  }
151 
156  virtual StatusCode initializeServices() { return initialize(); }
157 
162  virtual StatusCode startServices() { return start(); }
163 
168  virtual StatusCode stopServices() { return stop(); }
169 
174  virtual StatusCode finalizeServices() { return finalize(); }
175 
181 
186  virtual StatusCode restartServices() { return restart(); }
187 #endif
188 
189  virtual int getPriority( std::string_view name ) const = 0;
190  virtual StatusCode setPriority( std::string_view name, int pri ) = 0;
191 
193  virtual bool loopCheckEnabled() const = 0;
195  virtual void setLoopCheckEnabled( bool en = true ) = 0;
196 };
197 
198 #endif // GAUDIKERNEL_ISVCMANAGER_H
IService
Definition: IService.h:28
ISvcManager::setPriority
virtual StatusCode setPriority(std::string_view name, int pri)=0
IService.h
std::string
STL class.
ISvcManager::declareSvcType
virtual StatusCode declareSvcType(std::string svcname, std::string svctype)=0
Declare the type of the service to be used when crating a given service name.
ISvcManager::addService
virtual StatusCode addService(const Gaudi::Utils::TypeNameString &nametype, int prio=DEFAULT_SVC_PRIORITY)=0
Add a service to the "active" list of services of the factory.
gaudirun.s
string s
Definition: gaudirun.py:348
ISvcLocator
Definition: ISvcLocator.h:46
ISvcManager::reinitializeServices
virtual StatusCode reinitializeServices()
Reinitializes the list of "active" services.
Definition: ISvcManager.h:180
IStateful::start
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
ISvcManager::finalizeServices
virtual StatusCode finalizeServices()
Finalizes the list of "active" services.
Definition: ISvcManager.h:174
ISvcManager::initializeServices
virtual StatusCode initializeServices()
Initializes the list of "active" services.
Definition: ISvcManager.h:156
ISvcManager::getFactory
virtual StatusCode getFactory(const std::string &, const ISvcFactory *&) const
Access to service factory by name to create unmanaged services.
Definition: ISvcManager.h:147
ISvcManager::loopCheckEnabled
virtual bool loopCheckEnabled() const =0
Get the value of the initialization loop check flag.
ISvcManager::addService
virtual StatusCode addService(IService *svc, int prio=DEFAULT_SVC_PRIORITY)=0
Add a service to the "active" list of services of the factory.
ISvcManager
Definition: ISvcManager.h:38
IStateful::stop
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
IStateful::reinitialize
virtual StatusCode reinitialize()=0
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
ISvcManager::removeService
virtual StatusCode removeService(std::string_view nam)=0
Remove a service from the "active" list of services of the factory.
ISvcManager::createService
virtual StatusCode createService(const std::string &svctype, const std::string &svcname, IService *&svc)
Creates and instance of a service type that has been declared beforehand and assigns it a name.
Definition: ISvcManager.h:131
ISvcManager::restartServices
virtual StatusCode restartServices()
Restarts the list of "active" services.
Definition: ISvcManager.h:186
SmartIF.h
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
TimingHistograms.name
name
Definition: TimingHistograms.py:25
StatusCode
Definition: StatusCode.h:65
IStateful::initialize
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
ISvcManager::DeclareInterfaceID
DeclareInterfaceID(ISvcManager, 4, 0)
InterfaceID.
ISvcManager::getPriority
virtual int getPriority(std::string_view name) const =0
SmartIF< IService >
TypeNameString.h
ISvcManager::declareSvcFactory
virtual StatusCode declareSvcFactory(const ISvcFactory &, const std::string &)
Declare an abstract factory for a given service type.
Definition: ISvcManager.h:91
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
IComponentManager.h
ISvcManager::setLoopCheckEnabled
virtual void setLoopCheckEnabled(bool en=true)=0
Set the value of the initialization loop check flag.
ISvcManager::addService
virtual StatusCode addService(const std::string &typ, const std::string &nam, int prio)
Add a service to the "active" list of services of the factory.
Definition: ISvcManager.h:58
ISvcManager::removeService
virtual StatusCode removeService(IService *svc)=0
Remove a service from the "active" list of services of the factory.
ISvcManager::createService
virtual SmartIF< IService > & createService(const Gaudi::Utils::TypeNameString &nametype)=0
Creates and instance of a service type that has been declared beforehand and assigns it a name.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ISvcManager::stopServices
virtual StatusCode stopServices()
Stops the list of "active" services.
Definition: ISvcManager.h:168
IStateful::restart
virtual StatusCode restart()=0
Initialization (from RUNNING to RUNNING, via INITIALIZED).
IStateful::finalize
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
IComponentManager
Definition: IComponentManager.h:21
ISvcManager::startServices
virtual StatusCode startServices()
Starts the list of "active" services.
Definition: ISvcManager.h:162
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81