| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- File List
- File Members

# Algorithm.h

Go to the documentation of this file.

    00001 // $Id: Algorithm.h,v 1.34 2008/06/02 14:20:38 marcocle Exp $
    00002 // ============================================================================
    00003 #ifndef GAUDIKERNEL_ALGORITHM_H
    00004 #define GAUDIKERNEL_ALGORITHM_H
    00005 // ============================================================================
    00006 // Include files
    00007 // ============================================================================
    00008 #include "GaudiKernel/IProperty.h"
    00009 #include "GaudiKernel/IAlgorithm.h"
    00010 #include "GaudiKernel/IService.h"
    00011 #include "GaudiKernel/PropertyMgr.h"
    00012 #include "GaudiKernel/ISvcLocator.h"
    00013 #include "GaudiKernel/IMessageSvc.h"
    00014 #include "GaudiKernel/IStateful.h"
    00015
    00016 #include <string>
    00017 #include <vector>
    00018
    00019 // Extra include files (forward declarations should be sufficient)
    00020 #include "GaudiKernel/IDataProviderSvc.h"
    00021 #include "GaudiKernel/IHistogramSvc.h"
    00022 #include "GaudiKernel/IConversionSvc.h"
    00023 #include "GaudiKernel/INTupleSvc.h"
    00024 #include "GaudiKernel/IChronoStatSvc.h"
    00025 #include "GaudiKernel/IRndmGenSvc.h"
    00026 #include "GaudiKernel/IAuditorSvc.h"
    00027 #include "GaudiKernel/IToolSvc.h"
    00028 #include "GaudiKernel/IMonitorSvc.h"
    00029 #include "GaudiKernel/IExceptionSvc.h"
    00030 #include "GaudiKernel/Property.h"
    00031
    00032 #ifndef PACKAGE_VERSION
    00033 #define PACKAGE_VERSION "unknown"
    00034 #endif
    00035
    00061 class Algorithm : virtual public IAlgorithm,
    00062                   virtual public IProperty,
    00063                   virtual public IStateful {
    00064 public:
    00065
    00070   Algorithm( const std::string& name, ISvcLocator *svcloc,
    00071              const std::string& version=PACKAGE_VERSION );
    00073   virtual ~Algorithm();
    00074
    00080   virtual StatusCode sysStart();
    00081
    00087   virtual StatusCode sysInitialize();
    00088
    00089
    00095   virtual StatusCode sysReinitialize();
    00096
    00101   virtual StatusCode sysRestart();
    00102
    00110   virtual StatusCode sysExecute();
    00111
    00115   virtual StatusCode sysStop();
    00116
    00121   virtual StatusCode sysFinalize();
    00122
    00128   virtual StatusCode sysBeginRun( );
    00129
    00135   virtual StatusCode sysEndRun( );
    00136
    00144   virtual const std::string& name() const;
    00145
    00146   virtual const std::string& version() const;
    00147
    00149   virtual StatusCode configure () { return StatusCode::SUCCESS ; }
    00151   virtual StatusCode terminate () { return StatusCode::SUCCESS ; }
    00152
    00154   virtual StatusCode initialize () { return StatusCode::SUCCESS ; }
    00156   virtual StatusCode start () { return StatusCode::SUCCESS ; }
    00158   virtual StatusCode stop () { return StatusCode::SUCCESS ; }
    00160   virtual StatusCode finalize   () { return StatusCode::SUCCESS ; }
    00161
    00163   virtual StatusCode reinitialize ();
    00165   virtual StatusCode restart ();
    00166
    00168   virtual bool isExecuted( ) const;
    00169
    00171   virtual void setExecuted( bool state );
    00172
    00176   virtual void resetExecuted( );
    00177
    00181   virtual StatusCode beginRun();
    00182
    00184   virtual StatusCode endRun();
    00185
    00187   virtual Gaudi::StateMachine::State FSMState() const { return m_state; }
    00188
    00190   virtual Gaudi::StateMachine::State targetFSMState() const { return m_targetState; }
    00191
    00193   virtual bool isEnabled( ) const;
    00194
    00196   virtual bool filterPassed( ) const;
    00197
    00199   virtual void setFilterPassed( bool state );
    00200
    00202   template <class T>
    00203   StatusCode service
    00204   ( const std::string& name, T*& psvc, bool createIf = true ) const {
    00205     return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
    00206   }
    00207
    00209   template <class T>
    00210   StatusCode service( const std::string& svcType, const std::string& svcName,
    00211                       T*& psvc) const {
    00212     return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
    00213   }
    00214
    00216   void setOutputLevel( int level );
    00217
    00221   IAuditorSvc* auditorSvc() const;
    00222
    00226   IChronoStatSvc* chronoSvc() const;
    00228   IChronoStatSvc* chronoStatService() const;
    00229
    00233   IDataProviderSvc* detSvc() const;
    00234
    00236   IDataProviderSvc* detDataService() const;
    00237
    00241   IConversionSvc* detCnvSvc() const;
    00242
    00244   IConversionSvc* detDataCnvService() const;
    00245
    00249   IDataProviderSvc* eventSvc() const;
    00251   IDataProviderSvc* evtSvc  () const { return eventSvc() ; }
    00253   IDataProviderSvc* eventDataService() const;
    00254
    00258   IConversionSvc*   eventCnvSvc() const;
    00260   IConversionSvc*   eventDataCnvService() const;
    00261
    00265   IHistogramSvc* histoSvc() const;
    00267   IHistogramSvc* histogramDataService() const;
    00268
    00273   IMessageSvc*      msgSvc() const;
    00274
    00276   IMessageSvc*      messageService() const;
    00277
    00281   INTupleSvc* ntupleSvc() const;
    00282
    00284   INTupleSvc* ntupleService() const;
    00285
    00289   // IAIDATupleSvc* atupleSvc() const;
    00290
    00291
    00295   IRndmGenSvc* randSvc() const;
    00296
    00298   IToolSvc* toolSvc() const;
    00299
    00301   IExceptionSvc* exceptionSvc() const;
    00302
    00308   ISvcLocator* serviceLocator() const;
    00310   ISvcLocator* svcLoc        () const { return serviceLocator() ; }
    00311
    00324   StatusCode createSubAlgorithm( const std::string& type,
    00325                                  const std::string& name, Algorithm*& pSubAlg );
    00326
    00328   std::vector<Algorithm*>* subAlgorithms() const;
    00329
    00331   virtual StatusCode setProperty( const Property& p );
    00333   virtual StatusCode setProperty( const std::string& s );
    00335   virtual StatusCode setProperty( const std::string& n, const std::string& v);
    00337   virtual StatusCode getProperty(Property* p) const;
    00339   virtual const Property& getProperty( const std::string& name) const;
    00341   virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
    00343   virtual const std::vector<Property*>& getProperties( ) const;
    00344
    00352   StatusCode setProperties();
    00353   // ==========================================================================
    00383   template <class T>
    00384   Property* declareProperty
    00385   ( const std::string& name              ,
    00386     T&                 property          ,
    00387     const std::string& doc      = "none" ) const
    00388   {
    00389     return m_propertyMgr->declareProperty(name, property, doc);
    00390   }
    00391   // ==========================================================================
    00393   Property* declareRemoteProperty
    00394   ( const std::string& name       ,
    00395     IProperty*         rsvc       ,
    00396     const std::string& rname = "" ) const
    00397   {
    00398     return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname );
    00399   }
    00400   // ==========================================================================
    00410   inline IMonitorSvc* monitorSvc() const
    00411   {
    00412     // If not already located try to locate it without forcing a creation
    00413     if ( !m_pMonitorSvc ){
    00414       service_i( m_monitorSvcName, false,
    00415                  IMonitorSvc::interfaceID(), pp_cast<void>(&m_pMonitorSvc) );
    00416     }
    00417     return m_pMonitorSvc;
    00418   }
    00419
    00425   template <class T>
    00426   void declareInfo( const std::string& name,
    00427                     const T& var,
    00428                     const std::string& desc ) const
    00429   {
    00430     IMonitorSvc* mS = monitorSvc();
    00431     if ( mS ) mS->declareInfo(name, var, desc, this);
    00432   }
    00433
    00441   void declareInfo( const std::string& name,
    00442                     const std::string& format,
    00443                     const void* var,
    00444                     int size,
    00445                     const std::string& desc ) const
    00446   {
    00447     IMonitorSvc* mS = monitorSvc();
    00448     if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
    00449   }
    00450
    00452   unsigned long addRef();
    00454   unsigned long release();
    00456   StatusCode queryInterface(const InterfaceID& riid, void**);
    00457   // ==========================================================================
    00458 public:
    00459   // ==========================================================================
    00501   template <class TYPE>
    00502   StatusCode setProperty
    00503   ( const std::string& name  ,
    00504     const TYPE&        value )
    00505   { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }
    00506   // ==========================================================================
    00507 protected:
    00508
    00510   bool isInitialized( ) const { return Gaudi::StateMachine::INITIALIZED == m_state; }
    00511
    00513   bool isFinalized( ) const { return Gaudi::StateMachine::CONFIGURED == m_state; }
    00514
    00516   int  outputLevel() const { return (int)m_outputLevel ; }
    00517
    00519   IntegerProperty & outputLevelProperty() { return m_outputLevel; }
    00520
    00522   void initOutputLevel(Property& prop);
    00523
    00524
    00525 private:
    00526
    00527   long m_refCount;
    00528   std::string m_name;
    00529   std::string m_version;
    00530   std::vector<Algorithm *>* m_subAlgms;
    00531
    00532   mutable IMessageSvc*      m_MS;
    00533   mutable IDataProviderSvc* m_EDS;
    00534   mutable IConversionSvc*   m_ECS;
    00535   mutable IDataProviderSvc* m_DDS;
    00536   mutable IConversionSvc*   m_DCS;
    00537   mutable IHistogramSvc*    m_HDS;
    00538   mutable INTupleSvc*       m_NTS;
    00539   //  mutable IAIDATupleSvc*    m_ATS;      ///< AIDA tuple service
    00540   mutable IChronoStatSvc*   m_CSS;
    00541   mutable IRndmGenSvc*      m_RGS;
    00542   mutable IExceptionSvc*    m_EXS;
    00543   mutable IAuditorSvc*      m_pAuditorSvc;
    00544   mutable IToolSvc*         m_ptoolSvc;
    00545   mutable IMonitorSvc*      m_pMonitorSvc;
    00546   std::string               m_monitorSvcName;
    00547   ISvcLocator* m_pSvcLocator;
    00548   PropertyMgr* m_propertyMgr;
    00549   IntegerProperty m_outputLevel;
    00550   int          m_errorMax;
    00551   int          m_errorCount;
    00552   BooleanProperty m_auditInit;
    00553   bool         m_auditorInitialize;
    00554   bool         m_auditorReinitialize;
    00555   bool         m_auditorRestart;
    00556   bool         m_auditorExecute;
    00557   bool         m_auditorFinalize;
    00558   bool         m_auditorBeginRun;
    00559   bool         m_auditorEndRun;
    00560   bool         m_auditorStart;
    00561   bool         m_auditorStop;
    00562   bool         m_filterPassed;
    00563   bool         m_isEnabled;
    00564   bool         m_isExecuted;
    00565   Gaudi::StateMachine::State m_state;
    00566   Gaudi::StateMachine::State m_targetState;
    00567   bool         m_isFinalized;
    00568
    00570   StatusCode service_i(const std::string& svcName,
    00571                        bool createIf,
    00572                        const InterfaceID& iid,
    00573                        void** ppSvc) const;
    00574   StatusCode service_i(const std::string& svcType,
    00575                        const std::string& svcName,
    00576                        const InterfaceID& iid,
    00577                        void** ppSvc) const;
    00578
    00580   Algorithm(const Algorithm& a);
    00581
    00583   Algorithm& operator=(const Algorithm& rhs);
    00584 };
    00585
    00586 #endif //GAUDIKERNEL_ALGORITHM_H