Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Service.h
Go to the documentation of this file.
1 // $Id: Service.h,v 1.23 2008/06/02 14:20:37 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIKERNEL_SERVICE_H
4 #define GAUDIKERNEL_SERVICE_H
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 #include "GaudiKernel/IService.h"
11 #include "GaudiKernel/IProperty.h"
12 #include "GaudiKernel/IStateful.h"
14 #include "GaudiKernel/Property.h"
17 #include "GaudiKernel/SmartIF.h"
18 // ============================================================================
19 #include <vector>
20 // ============================================================================
21 // Forward declarations
22 // ============================================================================
23 class IMessageSvc;
24 class ISvcManager;
25 class ServiceManager;
26 // ============================================================================
34 class GAUDI_API Service: public CommonMessaging<implements3<IService, IProperty, IStateful> > {
35 public:
36  friend class ServiceManager;
37 
40  virtual unsigned long release();
41 
43  virtual const std::string& name() const;
44 
45  // State machine implementation
47  virtual StatusCode initialize();
48  virtual StatusCode start();
49  virtual StatusCode stop();
50  virtual StatusCode finalize();
52  virtual Gaudi::StateMachine::State FSMState() const { return m_state; }
53  virtual Gaudi::StateMachine::State targetFSMState() const { return m_targetState; }
54  virtual StatusCode reinitialize();
55  virtual StatusCode restart();
56 
58  virtual StatusCode sysInitialize();
60  virtual StatusCode sysStart();
62  virtual StatusCode sysStop();
64  virtual StatusCode sysFinalize();
66  virtual StatusCode sysReinitialize();
68  virtual StatusCode sysRestart();
69 
70  // Default implementations for ISetProperty
71  virtual StatusCode setProperty(const Property& p);
72  virtual StatusCode setProperty( const std::string& s );
73  virtual StatusCode setProperty( const std::string& n, const std::string& v);
74  virtual StatusCode getProperty(Property* p) const;
75  virtual const Property& getProperty( const std::string& name) const;
76  virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
77  virtual const std::vector<Property*>& getProperties( ) const;
78 
119  template <class TYPE>
121  ( const std::string& name ,
122  const TYPE& value )
123  { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }
124 
126  Service( const std::string& name, ISvcLocator* svcloc);
129 
133  StatusCode setProperties();
134 
137  template <class T>
138  StatusCode service( const std::string& name, const T*& psvc, bool createIf = true ) const {
139  ISvcLocator& svcLoc = *serviceLocator();
140  SmartIF<T> ptr(
141  ServiceLocatorHelper(svcLoc, *this).service(name, !createIf, // quiet
142  createIf));
143  if (ptr.isValid()) {
144  psvc = ptr.get();
145  const_cast<T*>(psvc)->addRef();
146  return StatusCode::SUCCESS;
147  }
148  // else
149  psvc = 0;
150  return StatusCode::FAILURE;
151  }
152 
153  template <class T>
154  StatusCode service( const std::string& name, T*& psvc, bool createIf = true ) const {
155  ISvcLocator& svcLoc = *serviceLocator();
156  SmartIF<T> ptr(
157  ServiceLocatorHelper(svcLoc, *this).service(name, !createIf, // quiet
158  createIf));
159  if (ptr.isValid()) {
160  psvc = ptr.get();
161  psvc->addRef();
162  return StatusCode::SUCCESS;
163  }
164  // else
165  psvc = 0;
166  return StatusCode::FAILURE;
167  }
168 
171  template <class T>
172  StatusCode service( const std::string& svcType, const std::string& svcName,
173  T*& psvc) const {
174  return service(svcType + "/" + svcName, psvc);
175  }
176  // ==========================================================================
205  template <class T>
206  Property* declareProperty
207  ( const std::string& name ,
208  T& property ,
209  const std::string& doc = "none" ) const
210  {
211  return m_propertyMgr -> declareProperty ( name , property , doc ) ;
212  }
213  // ==========================================================================
222  Property* declareRemoteProperty
223  ( const std::string& name ,
224  IProperty* rsvc ,
225  const std::string& rname = "" ) const
226  {
227  return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
228  }
229  // ==========================================================================
233  SmartIF<IAuditorSvc>& auditorSvc() const;
234 
235 protected:
237  virtual ~Service();
244 
246  int outputLevel() const { return m_outputLevel.value(); }
247 
248 private:
256 
257  void setServiceManager(ISvcManager* ism);
258 
268 
270  void initOutputLevel(Property& prop);
271 };
272 
273 #endif // GAUDIKERNEL_SERVICE_H

Generated at Wed Dec 4 2013 14:33:09 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004