The Gaudi Framework  v33r0 (d5ea422b)
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( const std::string& 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( const std::string& svcname, const std::string& svctype ) = 0;
104 
120  virtual SmartIF<IService>& createService( const Gaudi::Utils::TypeNameString& nametype ) = 0;
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( const std::string& name ) const = 0;
190  virtual StatusCode setPriority( const std::string& 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
DeclareInterfaceID(IComponentManager, 1, 0)
InterfaceID.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
virtual StatusCode reinitializeServices()
Reinitializes the list of "active" services.
Definition: ISvcManager.h:180
virtual StatusCode restartServices()
Restarts the list of "active" services.
Definition: ISvcManager.h:186
The ISvcManager is the interface implemented by the Service Factory in the Application Manager to sup...
Definition: ISvcManager.h:38
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
virtual StatusCode stopServices()
Stops the list of "active" services.
Definition: ISvcManager.h:168
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
virtual StatusCode declareSvcFactory(const ISvcFactory &, const std::string &)
Declare an abstract factory for a given service type.
Definition: ISvcManager.h:91
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
STL class.
Helper class to parse a string of format "type/name".
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
virtual StatusCode reinitialize()=0
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
General service interface definition.
Definition: IService.h:28
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
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
virtual StatusCode initializeServices()
Initializes the list of "active" services.
Definition: ISvcManager.h:156
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode finalizeServices()
Finalizes the list of "active" services.
Definition: ISvcManager.h:174
virtual StatusCode getFactory(const std::string &, const ISvcFactory *&) const
Access to service factory by name to create unmanaged services.
Definition: ISvcManager.h:147
virtual StatusCode restart()=0
Initialization (from RUNNING to RUNNING, via INITIALIZED).
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
string s
Definition: gaudirun.py:328
constexpr static const auto FAILURE
Definition: StatusCode.h:97
virtual StatusCode startServices()
Starts the list of "active" services.
Definition: ISvcManager.h:162
#define GAUDI_API
Definition: Kernel.h:81