The Gaudi Framework  master (37c0b60a)
ISvcManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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  [[deprecated( "use addService(type_name, prio) instead" )]] virtual StatusCode
59  addService( const std::string& typ, const std::string& nam, int prio ) {
60  return addService( Gaudi::Utils::TypeNameString( nam, typ ), prio );
61  }
62 #endif
63 
69  virtual StatusCode addService( const Gaudi::Utils::TypeNameString& nametype, int prio = DEFAULT_SVC_PRIORITY ) = 0;
70 
76  virtual StatusCode removeService( IService* svc ) = 0;
77 
83  virtual StatusCode removeService( std::string_view nam ) = 0;
84 
85 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
86 
92  [[deprecated]] virtual StatusCode declareSvcFactory( const ISvcFactory& /*factory*/,
93  const std::string& /*svctype*/ ) {
94  // This function is never used.
95  return StatusCode::FAILURE;
96  }
97 #endif
98 
105  virtual StatusCode declareSvcType( std::string svcname, std::string svctype ) = 0;
106 
123 
124 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
125 
133  [[deprecated( "use createService(type_name) instead" )]] virtual StatusCode
134  createService( const std::string& svctype, const std::string& svcname, IService*& svc ) {
135  SmartIF<IService> s = createService( svctype + "/" + svcname );
136  svc = s.get();
137  if ( svc ) {
138  svc->addRef(); // Needed to maintain the correct reference counting.
139  return StatusCode::SUCCESS;
140  }
141  return StatusCode::FAILURE;
142  }
143 
150  [[deprecated]] virtual StatusCode getFactory( const std::string& /*svc_type*/, const ISvcFactory*& /*fac*/ ) const {
151  // This function is never used.
152  return StatusCode::FAILURE;
153  }
154 
159  [[deprecated]] virtual StatusCode initializeServices() { return initialize(); }
160 
165  [[deprecated]] virtual StatusCode startServices() { return start(); }
166 
171  [[deprecated]] virtual StatusCode stopServices() { return stop(); }
172 
177  [[deprecated]] virtual StatusCode finalizeServices() { return finalize(); }
178 
183  [[deprecated]] virtual StatusCode reinitializeServices() { return reinitialize(); }
184 
189  [[deprecated]] virtual StatusCode restartServices() { return restart(); }
190 #endif
191 
192  virtual int getPriority( std::string_view name ) const = 0;
193  virtual StatusCode setPriority( std::string_view name, int pri ) = 0;
194 
196  virtual bool loopCheckEnabled() const = 0;
198  virtual void setLoopCheckEnabled( bool en = true ) = 0;
199 };
200 
201 #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:346
ISvcLocator
Definition: ISvcLocator.h:46
ISvcManager::reinitializeServices
virtual StatusCode reinitializeServices()
Reinitializes the list of "active" services.
Definition: ISvcManager.h:183
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:177
ISvcManager::initializeServices
virtual StatusCode initializeServices()
Initializes the list of "active" services.
Definition: ISvcManager.h:159
ISvcManager::getFactory
virtual StatusCode getFactory(const std::string &, const ISvcFactory *&) const
Access to service factory by name to create unmanaged services.
Definition: ISvcManager.h:150
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:134
ISvcManager::restartServices
virtual StatusCode restartServices()
Restarts the list of "active" services.
Definition: ISvcManager.h:189
SmartIF.h
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
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:92
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
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:59
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:171
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:165
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81