Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Algorithm.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ALGORITHM_H
2 #define GAUDIKERNEL_ALGORITHM_H
3 // ============================================================================
4 // Include files
5 // ============================================================================
8 #include "GaudiKernel/IService.h"
12 #include "GaudiKernel/IStateful.h"
13 
14 #include <string>
15 #include <vector>
16 
17 // Extra include files (forward declarations should be sufficient)
21 #include "GaudiKernel/INTupleSvc.h"
25 #include "GaudiKernel/IToolSvc.h"
29 #include "GaudiKernel/Property.h"
30 #include <Gaudi/PluginService.h>
31 
32 #ifndef PACKAGE_VERSION
33 #define PACKAGE_VERSION "unknown"
34 #endif
35 
61 class GAUDI_API Algorithm: public implements3<IAlgorithm, IProperty, IStateful> {
62 public:
63  typedef Gaudi::PluginService::Factory2<IAlgorithm*,
64  const std::string&,
66 
71  Algorithm( const std::string& name, ISvcLocator *svcloc,
72  const std::string& version=PACKAGE_VERSION );
74  virtual ~Algorithm();
75 
81  virtual StatusCode sysStart();
82 
88  virtual StatusCode sysInitialize();
89 
90 
96  virtual StatusCode sysReinitialize();
97 
102  virtual StatusCode sysRestart();
103 
111  virtual StatusCode sysExecute();
112 
116  virtual StatusCode sysStop();
117 
122  virtual StatusCode sysFinalize();
123 
129  virtual StatusCode sysBeginRun( );
130 
136  virtual StatusCode sysEndRun( );
137 
145  virtual const std::string& name() const;
146 
147  virtual const std::string& version() const;
148 
150  virtual StatusCode configure () { return StatusCode::SUCCESS ; }
152  virtual StatusCode terminate () { return StatusCode::SUCCESS ; }
153 
155  virtual StatusCode initialize () { return StatusCode::SUCCESS ; }
157  virtual StatusCode start () { return StatusCode::SUCCESS ; }
159  virtual StatusCode stop () { return StatusCode::SUCCESS ; }
161  virtual StatusCode finalize () { return StatusCode::SUCCESS ; }
162 
164  virtual StatusCode reinitialize ();
166  virtual StatusCode restart ();
167 
169  virtual bool isExecuted( ) const;
170 
172  virtual void setExecuted( bool state );
173 
177  virtual void resetExecuted( );
178 
182  virtual StatusCode beginRun();
183 
185  virtual StatusCode endRun();
186 
188  virtual Gaudi::StateMachine::State FSMState() const { return m_state; }
189 
191  virtual Gaudi::StateMachine::State targetFSMState() const { return m_targetState; }
192 
194  virtual bool isEnabled( ) const;
195 
197  virtual bool filterPassed( ) const;
198 
200  virtual void setFilterPassed( bool state );
201 
203  template <class T>
204  StatusCode service
205  ( const std::string& name, T*& psvc, bool createIf = true ) const {
206  return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
207  }
208 
210  template <class T>
211  StatusCode service( const std::string& svcType, const std::string& svcName,
212  T*& psvc) const {
213  return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
214  }
215 
217  SmartIF<IService> service(const std::string& name, const bool createIf = true, const bool quiet = false) const;
218 
220  void setOutputLevel( int level );
221 
225  SmartIF<IAuditorSvc>& auditorSvc() const;
226 
230  SmartIF<IChronoStatSvc>& chronoSvc() const;
232  SmartIF<IChronoStatSvc>& chronoStatService() const;
233 
237  SmartIF<IDataProviderSvc>& detSvc() const;
238 
240  SmartIF<IDataProviderSvc>& detDataService() const;
241 
245  SmartIF<IConversionSvc>& detCnvSvc() const;
246 
248  SmartIF<IConversionSvc>& detDataCnvService() const;
249 
253  SmartIF<IDataProviderSvc>& eventSvc() const;
255  SmartIF<IDataProviderSvc>& evtSvc () const { return eventSvc() ; }
257  SmartIF<IDataProviderSvc>& eventDataService() const;
258 
262  SmartIF<IConversionSvc>& eventCnvSvc() const;
264  SmartIF<IConversionSvc>& eventDataCnvService() const;
265 
269  SmartIF<IHistogramSvc>& histoSvc() const;
271  SmartIF<IHistogramSvc>& histogramDataService() const;
272 
277  SmartIF<IMessageSvc>& msgSvc() const;
278 
280  SmartIF<IMessageSvc>& messageService() const;
281 
285  SmartIF<INTupleSvc>& ntupleSvc() const;
286 
288  SmartIF<INTupleSvc>& ntupleService() const;
289 
293  // SmartIF<IAIDATupleSvc>& atupleSvc() const;
294 
295 
299  SmartIF<IRndmGenSvc>& randSvc() const;
300 
302  SmartIF<IToolSvc>& toolSvc() const;
303 
305  SmartIF<IExceptionSvc>& exceptionSvc() const;
306 
308  SmartIF<IAlgContextSvc>& contextSvc() const ;
309 
315  SmartIF<ISvcLocator>& serviceLocator() const;
317  SmartIF<ISvcLocator>& svcLoc () const { return serviceLocator() ; }
318 
320  bool registerContext() const { return m_registerContext ; }
321 
334  StatusCode createSubAlgorithm( const std::string& type,
335  const std::string& name, Algorithm*& pSubAlg );
336 
338  std::vector<Algorithm*>* subAlgorithms() const;
339 
341  virtual StatusCode setProperty( const Property& p );
343  virtual StatusCode setProperty( const std::string& s );
345  virtual StatusCode setProperty( const std::string& n, const std::string& v);
347  virtual StatusCode getProperty(Property* p) const;
349  virtual const Property& getProperty( const std::string& name) const;
351  virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
353  virtual const std::vector<Property*>& getProperties( ) const;
354 
362  StatusCode setProperties();
363  // ==========================================================================
393  template <class T>
394  Property* declareProperty
395  ( const std::string& name ,
396  T& property ,
397  const std::string& doc = "none" ) const
398  {
399  return m_propertyMgr->declareProperty(name, property, doc);
400  }
401  // ==========================================================================
403  Property* declareRemoteProperty
404  ( const std::string& name ,
405  IProperty* rsvc ,
406  const std::string& rname = "" ) const
407  {
408  return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname );
409  }
410  // ==========================================================================
420  inline SmartIF<IMonitorSvc>& monitorSvc() const
421  {
422  // If not already located try to locate it without forcing a creation
423  if ( !m_pMonitorSvc.isValid() ){
424  m_pMonitorSvc = service(m_monitorSvcName, false, true); // do not create and be quiet
425  }
426  return m_pMonitorSvc;
427  }
428 
434  template <class T>
435  void declareInfo( const std::string& name,
436  const T& var,
437  const std::string& desc ) const
438  {
439  IMonitorSvc* mS = monitorSvc().get();
440  if ( mS ) mS->declareInfo(name, var, desc, this);
441  }
442 
450  void declareInfo( const std::string& name,
451  const std::string& format,
452  const void* var,
453  int size,
454  const std::string& desc ) const
455  {
456  IMonitorSvc* mS = monitorSvc().get();
457  if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
458  }
459 
460  // ==========================================================================
461 public:
462  // ==========================================================================
504  template <class TYPE>
506  ( const std::string& name ,
507  const TYPE& value )
508  { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }
509  // ==========================================================================
510 protected:
511 
513  bool isInitialized( ) const { return Gaudi::StateMachine::INITIALIZED == m_state; }
514 
516  bool isFinalized( ) const { return Gaudi::StateMachine::CONFIGURED == m_state; }
517 
519  int outputLevel() const { return (int)m_outputLevel ; }
520 
522  IntegerProperty & outputLevelProperty() { return m_outputLevel; }
523 
525  void initOutputLevel(Property& prop);
526 
527 
528 private:
529 
533 
541  // mutable SmartIF<IAIDATupleSvc> m_ATS; ///< AIDA tuple service
567  bool m_isEnabled;
572 
574  StatusCode service_i(const std::string& svcName,
575  bool createIf,
576  const InterfaceID& iid,
577  void** ppSvc) const;
578  StatusCode service_i(const std::string& svcType,
579  const std::string& svcName,
580  const InterfaceID& iid,
581  void** ppSvc) const;
582 
584  Algorithm(const Algorithm& a);
585 
587  Algorithm& operator=(const Algorithm& rhs);
588 };
589 
590 #ifndef GAUDI_NEW_PLUGIN_SERVICE
591 template <class T>
592 class AlgFactory {
593 public:
594  template <typename S>
595  static typename S::ReturnType create(typename S::Arg1Type a1,
596  typename S::Arg2Type a2) {
597  return new T(a1, a2);
598  }
599 };
600 
601 // Macros to declare component factories
602 #define DECLARE_ALGORITHM_FACTORY(x) \
603  DECLARE_FACTORY_WITH_CREATOR(x, AlgFactory< x >, Algorithm::Factory)
604 #define DECLARE_NAMED_ALGORITHM_FACTORY(x, n) \
605  DECLARE_FACTORY_WITH_CREATOR_AND_ID(x, AlgFactory< x >, \
606  #n, Algorithm::Factory)
607 #define DECLARE_NAMESPACE_ALGORITHM_FACTORY(n, x) \
608  DECLARE_ALGORITHM_FACTORY(n::x)
609 
610 #else
611 
612 // Macros to declare component factories
613 #define DECLARE_ALGORITHM_FACTORY(x) DECLARE_COMPONENT(x)
614 #define DECLARE_NAMED_ALGORITHM_FACTORY(x, n) DECLARE_COMPONENT_WITH_ID(x, #n)
615 #define DECLARE_NAMESPACE_ALGORITHM_FACTORY(n, x) DECLARE_COMPONENT(n::x)
616 
617 #endif
618 
619 #endif //GAUDIKERNEL_ALGORITHM_H

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