Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlgTool.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ALGTOOL_H
2 #define GAUDIKERNEL_ALGTOOL_H
3 // ============================================================================
4 // Include files
5 #include "GaudiKernel/IAlgTool.h"
7 #include "GaudiKernel/IService.h"
10 #include "GaudiKernel/IToolSvc.h"
14 #include "GaudiKernel/IStateful.h"
15 
16 #include <vector>
17 #include <list>
18 
19 // Forward declarations
20 
33 class GAUDI_API AlgTool: public implements3<IAlgTool, IProperty, IStateful> {
34  friend class ToolSvc;
35 public:
36 
38  virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
39 
41  virtual const std::string& name() const;
42 
44  virtual const std::string& type() const;
45 
47  virtual const IInterface* parent() const;
48 
49  // State machine implementation
51  virtual StatusCode initialize();
52  virtual StatusCode start();
53  virtual StatusCode stop();
54  virtual StatusCode finalize();
56  virtual StatusCode reinitialize();
57  virtual StatusCode restart();
58  virtual Gaudi::StateMachine::State FSMState() const { return m_state; }
60 
62  virtual StatusCode sysInitialize();
63 
65  virtual StatusCode sysStart();
66 
68  virtual StatusCode sysStop();
69 
71  virtual StatusCode sysFinalize();
72 
74  virtual StatusCode sysReinitialize();
75 
77  virtual StatusCode sysRestart();
78 
80  virtual StatusCode setProperty( const Property& p );
81  virtual StatusCode setProperty( const std::string& s );
82  virtual StatusCode setProperty( const std::string& n, const std::string& v);
83  virtual StatusCode getProperty(Property* p) const;
84  virtual const Property& getProperty( const std::string& name) const;
85  virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
86  virtual const std::vector<Property*>& getProperties( ) const;
87 
88  inline PropertyMgr * getPropertyMgr() { return m_propertyMgr; }
89 
90 public:
91 
132  template <class TYPE>
134  ( const std::string& name ,
135  const TYPE& value )
136  { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }
137 
138 
144  AlgTool( const std::string& type,
145  const std::string& name,
146  const IInterface* parent);
147 
149  ISvcLocator* serviceLocator() const;
150 
152  ISvcLocator* svcLoc() const { return serviceLocator() ; }
153 
155  IMessageSvc* msgSvc() const;
156 
158  IToolSvc* toolSvc() const;
159 
166 
170  template <class T>
172  ( const std::string& name, T*& svc, bool createIf = true ) const {
173  return service_i(name, createIf, T::interfaceID(), (void**)&svc);
174  }
175 
178  template <class T>
179  StatusCode service( const std::string& type, const std::string& name, T*& svc) const {
180  return service_i(type, name, T::interfaceID(), (void**)&svc);
181  }
182 
184  SmartIF<IService> service(const std::string& name, const bool createIf = true, const bool quiet = false) const;
185 
187  void declInterface( const InterfaceID&, void*);
188 
189  template <class I> class declareInterface {
190  public:
191  template <class T> declareInterface(T* tool) {
192  tool->declInterface( I::interfaceID(), (I*)tool);
193  }
194  };
195  // ==========================================================================
225  template <class T>
226  Property* declareProperty
227  ( const std::string& name ,
228  T& property ,
229  const std::string& doc = "none" ) const
230  {
231  return m_propertyMgr -> declareProperty ( name , property , doc ) ;
232  }
234  Property* declareRemoteProperty
235  ( const std::string& name ,
236  IProperty* rsvc ,
237  const std::string& rname = "" ) const
238  {
239  return m_propertyMgr-> declareRemoteProperty ( name , rsvc , rname ) ;
240  }
241  // ==========================================================================
243  IAuditorSvc* auditorSvc() const;
244 
254  inline IMonitorSvc* monitorSvc() const
255  {
256  // If not already located try to locate it without forcing a creation
257  if ( !m_pMonitorSvc ){
258  service_i( m_monitorSvcName, false,
259  IMonitorSvc::interfaceID(), pp_cast<void>(&m_pMonitorSvc) ).ignore();
260  }
261  return m_pMonitorSvc;
262  }
263 
269  template <class T>
270  void declareInfo( const std::string& name,
271  const T& var,
272  const std::string& desc ) const
273  {
274  IMonitorSvc* mS = monitorSvc();
275  if ( mS ) mS->declareInfo(name, var, desc, this);
276  }
277 
285  void declareInfo( const std::string& name,
286  const std::string& format,
287  const void* var,
288  int size,
289  const std::string& desc ) const
290  {
291  IMonitorSvc* mS = monitorSvc();
292  if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
293  }
294 
295 protected:
296 
298  int outputLevel () const { return (int)m_outputLevel ; }
299 
301  IntegerProperty & outputLevelProperty() { return m_outputLevel; }
302 
304  void initOutputLevel(Property& prop);
305 
306 
307 
308 protected:
309 
310  // Standard destructor.
311  virtual ~AlgTool();
312 
313 private:
321  mutable IToolSvc* m_ptoolSvc;
327 
329  StatusCode service_i(const std::string& algName,
330  bool createIf,
331  const InterfaceID& iid,
332  void** ppSvc) const;
333  StatusCode service_i(const std::string& svcType,
334  const std::string& svcName,
335  const InterfaceID& iid,
336  void** ppS) const;
337 
339 
347 
350 };
351 
352 #endif // GAUDIKERNEL_ALGTOOL_H

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