Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ServiceManager.h
Go to the documentation of this file.
1 // $Id: ServiceManager.h,v 1.9 2008/11/10 15:29:09 marcocle Exp $
2 #ifndef GAUDISVC_ServiceManager_H
3 #define GAUDISVC_ServiceManager_H
4 
5 // Include files
6 #include "GaudiKernel/Kernel.h"
10 #include "GaudiKernel/SmartIF.h"
12 #include "GaudiKernel/Map.h"
13 #include <string>
14 #include <list>
15 #include <map>
16 #include <algorithm>
17 #include "boost/thread.hpp"
18 
19 // Forward declarations
20 class IService;
21 class IMessageSvc;
22 class Property;
23 
36 class ServiceManager : public extends2<ComponentManager, ISvcManager, ISvcLocator>{
37 public:
38 
39  struct ServiceItem {
40  ServiceItem(IService *s, long p = 0, bool act = false):
41  service(s), priority(p), active(act) {}
43  long priority;
44  bool active;
45  inline bool operator==(const std::string &name) const {
46  return service->name() == name;
47  }
48  inline bool operator==(const IService *ptr) const {
49  return service.get() == ptr;
50  }
51  inline bool operator<(const ServiceItem& rhs) const {
52  return priority < rhs.priority;
53  }
54  };
55 
56  // typedefs and classes
59 
61  ServiceManager(IInterface* application);
62 
65  return m_svcLocator;
66  }
67 
69  virtual ~ServiceManager();
70 
72  virtual const std::list<IService*>& getServices() const;
73 
75  virtual bool existsService(const std::string& name) const;
76 
78  virtual StatusCode addService(IService* svc, int prio = DEFAULT_SVC_PRIORITY);
80  virtual StatusCode addService(const Gaudi::Utils::TypeNameString& typeName, int prio = DEFAULT_SVC_PRIORITY);
82  virtual StatusCode removeService(IService* svc);
84  virtual StatusCode removeService(const std::string& name);
85 
87  virtual StatusCode declareSvcType(const std::string& svcname, const std::string& svctype);
88 
90  virtual SmartIF<IService>& createService(const Gaudi::Utils::TypeNameString& nametype);
91 
93  virtual StatusCode initialize();
95  virtual StatusCode start();
97  virtual StatusCode stop();
99  virtual StatusCode finalize();
100 
102  virtual StatusCode reinitialize();
104  virtual StatusCode restart();
105 
107  virtual int getPriority(const std::string& name) const;
108  virtual StatusCode setPriority(const std::string& name, int pri);
109 
111  virtual bool loopCheckEnabled() const;
113  virtual void setLoopCheckEnabled(bool en);
114 
116  const std::string &name() const {
117  static std::string _name = "ServiceManager";
118  return _name;
119  }
120 
122  virtual SmartIF<IService> &service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf = true);
123 
124 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
127 #endif
128 
129 private:
130 
132  return std::find(m_listsvc.begin(), m_listsvc.end(), name);
133  }
135  return std::find(m_listsvc.begin(), m_listsvc.end(), name);
136  }
137  inline ListSvc::iterator find(const IService *ptr) {
138  return std::find(m_listsvc.begin(), m_listsvc.end(), ptr);
139  }
140  inline ListSvc::const_iterator find(const IService *ptr) const {
141  return std::find(m_listsvc.begin(), m_listsvc.end(), ptr);
142  }
143 
144 private:
147  bool m_loopCheck;
148 
151 
154 
156 
158  boost::recursive_mutex m_svcinitmutex;
159 
160 private:
161  void dump() const;
162 
163 };
164 #endif // GAUDISVC_ServiceManager_H
165 

Generated at Mon Feb 17 2014 14:37:40 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004