All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ISvcManager.h
Go to the documentation of this file.
1 // $Id: ISvcManager.h,v 1.7 2008/11/10 15:29:09 marcocle Exp $
2 #ifndef GAUDIKERNEL_ISVCMANAGER_H
3 #define GAUDIKERNEL_ISVCMANAGER_H
4 
5 // Include files
7 #include "GaudiKernel/SmartIF.h"
9 #include <string>
10 
11 // Forward class declaration
12 #if defined(GAUDI_V20_COMPAT) || (!defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR))
13 class ISvcFactory;
14 #include "GaudiKernel/IService.h"
15 #else
16 class IService;
17 #endif
18 class ISvcLocator;
19 
29 class GAUDI_API ISvcManager: virtual public IComponentManager {
30 public:
33 
34  static const int DEFAULT_SVC_PRIORITY = 100;
35 
41  virtual StatusCode addService( IService* svc, int prio = DEFAULT_SVC_PRIORITY) = 0;
42 
43 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
44 
49  virtual StatusCode addService( const std::string& typ, const std::string& nam, int prio ){
50  return addService(Gaudi::Utils::TypeNameString(nam,typ), prio);
51  }
52 #endif
53 
59  virtual StatusCode addService( const Gaudi::Utils::TypeNameString& nametype, int prio = DEFAULT_SVC_PRIORITY) = 0;
60 
66  virtual StatusCode removeService( IService* svc ) = 0;
67 
73  virtual StatusCode removeService( const std::string& nam ) = 0;
74 
75 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
76 
82  virtual StatusCode declareSvcFactory( const ISvcFactory& /*factory*/,
83  const std::string& /*svctype*/ ) {
84  // This function is never used.
85  return StatusCode::FAILURE;
86  }
87 #endif
88 
95  virtual StatusCode declareSvcType( const std::string& svcname,
96  const std::string& svctype ) = 0;
97 
104  virtual SmartIF<IService>& createService(const Gaudi::Utils::TypeNameString& nametype) = 0;
105 
106 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
107 
115  virtual StatusCode createService( const std::string& svctype,
116  const std::string& svcname,
117  IService*& svc ){
118  SmartIF<IService> s = createService(svctype + "/" + svcname);
119  svc = s.get();
120  if (svc) {
121  svc->addRef(); // Needed to maintain the correct reference counting.
122  return StatusCode::SUCCESS;
123  }
124  return StatusCode::FAILURE;
125  }
126 
133  virtual StatusCode getFactory( const std::string& /*svc_type*/,
134  const ISvcFactory*& /*fac*/) const {
135  // This function is never used.
136  return StatusCode::FAILURE;
137  }
138 
143  virtual StatusCode initializeServices() { return initialize(); }
144 
149  virtual StatusCode startServices() { return start(); }
150 
155  virtual StatusCode stopServices() { return stop(); }
156 
161  virtual StatusCode finalizeServices() { return finalize(); }
162 
168 
173  virtual StatusCode restartServices() { return restart(); }
174 #endif
175 
176  virtual int getPriority(const std::string& name) const = 0;
177  virtual StatusCode setPriority(const std::string& name, int pri) = 0;
178 
180  virtual bool loopCheckEnabled() const = 0;
182  virtual void setLoopCheckEnabled(bool en = true) = 0;
183 
184 };
185 
186 #endif // GAUDIKERNEL_ISVCMANAGER_H
187 
DeclareInterfaceID(IComponentManager, 1, 0)
InterfaceID.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
virtual StatusCode reinitializeServices()
Reinitializes the list of "active" services.
Definition: ISvcManager.h:167
virtual StatusCode restartServices()
Restarts the list of "active" services.
Definition: ISvcManager.h:173
The ISvcManager is the interface implemented by the Service Factory in the Application Manager to sup...
Definition: ISvcManager.h:29
virtual StatusCode stopServices()
Stops the list of "active" services.
Definition: ISvcManager.h:155
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:115
virtual StatusCode declareSvcFactory(const ISvcFactory &, const std::string &)
Declare an abstract factory for a given service type.
Definition: ISvcManager.h:82
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
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:19
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
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:49
virtual StatusCode initializeServices()
Initializes the list of "active" services.
Definition: ISvcManager.h:143
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:62
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode finalizeServices()
Finalizes the list of "active" services.
Definition: ISvcManager.h:161
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:210
virtual StatusCode startServices()
Starts the list of "active" services.
Definition: ISvcManager.h:149
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
#define GAUDI_API
Definition: Kernel.h:108
virtual StatusCode getFactory(const std::string &, const ISvcFactory *&) const
Access to service factory by name to create unmanaged services.
Definition: ISvcManager.h:133