Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Algorithm.h
Go to the documentation of this file.
1 // $Id: Algorithm.h,v 1.34 2008/06/02 14:20:38 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIKERNEL_ALGORITHM_H
4 #define GAUDIKERNEL_ALGORITHM_H
5 // ============================================================================
6 // Include files
7 // ============================================================================
10 #include "GaudiKernel/IService.h"
14 #include "GaudiKernel/IStateful.h"
15 
16 #include <string>
17 #include <vector>
18 
19 // Extra include files (forward declarations should be sufficient)
23 #include "GaudiKernel/INTupleSvc.h"
27 #include "GaudiKernel/IToolSvc.h"
31 #include "GaudiKernel/Property.h"
32 
33 #ifndef PACKAGE_VERSION
34 #define PACKAGE_VERSION "unknown"
35 #endif
36 
62 class GAUDI_API Algorithm: public implements3<IAlgorithm, IProperty, IStateful> {
63 public:
64 
69  Algorithm( const std::string& name, ISvcLocator *svcloc,
70  const std::string& version=PACKAGE_VERSION );
72  virtual ~Algorithm();
73 
79  virtual StatusCode sysStart();
80 
86  virtual StatusCode sysInitialize();
87 
88 
94  virtual StatusCode sysReinitialize();
95 
100  virtual StatusCode sysRestart();
101 
109  virtual StatusCode sysExecute();
110 
114  virtual StatusCode sysStop();
115 
120  virtual StatusCode sysFinalize();
121 
127  virtual StatusCode sysBeginRun( );
128 
134  virtual StatusCode sysEndRun( );
135 
143  virtual const std::string& name() const;
144 
145  virtual const std::string& version() const;
146 
148  virtual StatusCode configure () { return StatusCode::SUCCESS ; }
150  virtual StatusCode terminate () { return StatusCode::SUCCESS ; }
151 
153  virtual StatusCode initialize () { return StatusCode::SUCCESS ; }
155  virtual StatusCode start () { return StatusCode::SUCCESS ; }
157  virtual StatusCode stop () { return StatusCode::SUCCESS ; }
159  virtual StatusCode finalize () { return StatusCode::SUCCESS ; }
160 
162  virtual StatusCode reinitialize ();
164  virtual StatusCode restart ();
165 
167  virtual bool isExecuted( ) const;
168 
170  virtual void setExecuted( bool state );
171 
175  virtual void resetExecuted( );
176 
180  virtual StatusCode beginRun();
181 
183  virtual StatusCode endRun();
184 
186  virtual Gaudi::StateMachine::State FSMState() const { return m_state; }
187 
189  virtual Gaudi::StateMachine::State targetFSMState() const { return m_targetState; }
190 
192  virtual bool isEnabled( ) const;
193 
195  virtual bool filterPassed( ) const;
196 
198  virtual void setFilterPassed( bool state );
199 
201  template <class T>
202  StatusCode service
203  ( const std::string& name, T*& psvc, bool createIf = true ) const {
204  return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
205  }
206 
208  template <class T>
209  StatusCode service( const std::string& svcType, const std::string& svcName,
210  T*& psvc) const {
211  return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
212  }
213 
215  SmartIF<IService> service(const std::string& name, const bool createIf = true, const bool quiet = false) const;
216 
218  void setOutputLevel( int level );
219 
223  SmartIF<IAuditorSvc>& auditorSvc() const;
224 
228  SmartIF<IChronoStatSvc>& chronoSvc() const;
230  SmartIF<IChronoStatSvc>& chronoStatService() const;
231 
235  SmartIF<IDataProviderSvc>& detSvc() const;
236 
238  SmartIF<IDataProviderSvc>& detDataService() const;
239 
243  SmartIF<IConversionSvc>& detCnvSvc() const;
244 
246  SmartIF<IConversionSvc>& detDataCnvService() const;
247 
251  SmartIF<IDataProviderSvc>& eventSvc() const;
253  SmartIF<IDataProviderSvc>& evtSvc () const { return eventSvc() ; }
255  SmartIF<IDataProviderSvc>& eventDataService() const;
256 
260  SmartIF<IConversionSvc>& eventCnvSvc() const;
262  SmartIF<IConversionSvc>& eventDataCnvService() const;
263 
267  SmartIF<IHistogramSvc>& histoSvc() const;
269  SmartIF<IHistogramSvc>& histogramDataService() const;
270 
275  SmartIF<IMessageSvc>& msgSvc() const;
276 
278  SmartIF<IMessageSvc>& messageService() const;
279 
283  SmartIF<INTupleSvc>& ntupleSvc() const;
284 
286  SmartIF<INTupleSvc>& ntupleService() const;
287 
291  // SmartIF<IAIDATupleSvc>& atupleSvc() const;
292 
293 
297  SmartIF<IRndmGenSvc>& randSvc() const;
298 
300  SmartIF<IToolSvc>& toolSvc() const;
301 
303  SmartIF<IExceptionSvc>& exceptionSvc() const;
304 
306  SmartIF<IAlgContextSvc>& contextSvc() const ;
307 
313  SmartIF<ISvcLocator>& serviceLocator() const;
315  SmartIF<ISvcLocator>& svcLoc () const { return serviceLocator() ; }
316 
318  bool registerContext() const { return m_registerContext ; }
319 
332  StatusCode createSubAlgorithm( const std::string& type,
333  const std::string& name, Algorithm*& pSubAlg );
334 
336  std::vector<Algorithm*>* subAlgorithms() const;
337 
339  virtual StatusCode setProperty( const Property& p );
341  virtual StatusCode setProperty( const std::string& s );
343  virtual StatusCode setProperty( const std::string& n, const std::string& v);
345  virtual StatusCode getProperty(Property* p) const;
347  virtual const Property& getProperty( const std::string& name) const;
349  virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
351  virtual const std::vector<Property*>& getProperties( ) const;
352 
360  StatusCode setProperties();
361  // ==========================================================================
391  template <class T>
392  Property* declareProperty
393  ( const std::string& name ,
394  T& property ,
395  const std::string& doc = "none" ) const
396  {
397  return m_propertyMgr->declareProperty(name, property, doc);
398  }
399  // ==========================================================================
401  Property* declareRemoteProperty
402  ( const std::string& name ,
403  IProperty* rsvc ,
404  const std::string& rname = "" ) const
405  {
406  return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname );
407  }
408  // ==========================================================================
418  inline SmartIF<IMonitorSvc>& monitorSvc() const
419  {
420  // If not already located try to locate it without forcing a creation
421  if ( !m_pMonitorSvc.isValid() ){
422  m_pMonitorSvc = service(m_monitorSvcName, false, true); // do not create and be quiet
423  }
424  return m_pMonitorSvc;
425  }
426 
432  template <class T>
433  void declareInfo( const std::string& name,
434  const T& var,
435  const std::string& desc ) const
436  {
437  IMonitorSvc* mS = monitorSvc().get();
438  if ( mS ) mS->declareInfo(name, var, desc, this);
439  }
440 
448  void declareInfo( const std::string& name,
449  const std::string& format,
450  const void* var,
451  int size,
452  const std::string& desc ) const
453  {
454  IMonitorSvc* mS = monitorSvc().get();
455  if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
456  }
457 
458  // ==========================================================================
459 public:
460  // ==========================================================================
502  template <class TYPE>
504  ( const std::string& name ,
505  const TYPE& value )
506  { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }
507  // ==========================================================================
508 protected:
509 
511  bool isInitialized( ) const { return Gaudi::StateMachine::INITIALIZED == m_state; }
512 
514  bool isFinalized( ) const { return Gaudi::StateMachine::CONFIGURED == m_state; }
515 
517  int outputLevel() const { return (int)m_outputLevel ; }
518 
520  IntegerProperty & outputLevelProperty() { return m_outputLevel; }
521 
523  void initOutputLevel(Property& prop);
524 
525 
526 private:
527 
531 
539  // mutable SmartIF<IAIDATupleSvc> m_ATS; ///< AIDA tuple service
565  bool m_isEnabled;
570 
572  StatusCode service_i(const std::string& svcName,
573  bool createIf,
574  const InterfaceID& iid,
575  void** ppSvc) const;
576  StatusCode service_i(const std::string& svcType,
577  const std::string& svcName,
578  const InterfaceID& iid,
579  void** ppSvc) const;
580 
582  Algorithm(const Algorithm& a);
583 
585  Algorithm& operator=(const Algorithm& rhs);
586 };
587 
588 #endif //GAUDIKERNEL_ALGORITHM_H

Generated at Wed Nov 28 2012 12:17:12 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004