Gaudi Framework, version v20r2

Generated: 18 Jul 2008

GaudiAlgorithm.h

Go to the documentation of this file.
00001 // $Id: GaudiAlgorithm.h,v 1.17 2007/09/25 16:12:41 marcocle Exp $
00002 // ============================================================================
00003 #ifndef GAUDIALG_GaudiAlgorithm_H
00004 #define GAUDIALG_GaudiAlgorithm_H 1
00005 // ============================================================================
00006 // Include files
00007 // ============================================================================
00008 // GaudiKernel
00009 // ============================================================================
00010 #include "GaudiKernel/Algorithm.h"
00011 // ============================================================================
00012 // GaudiAlg
00013 // ============================================================================
00014 #include "GaudiAlg/GaudiAlg.h"
00015 #include "GaudiAlg/GaudiCommon.h"
00016 // ============================================================================
00017 // forward declarations:
00018 // ============================================================================
00019 class                   INTupleSvc     ; // GaudiKernel
00020 class                   IAlgContextSvc ; // GaudiKernel
00021 template<class T> class  AlgFactory    ; // GaudiKernel
00022 // ============================================================================
00023 /* @file GaudiAlgorithm.h
00024  *
00025  * Header file for class GaudiAlgorithm.
00026  * The actual code is mainly imported from
00027  *   - LHCb Calorimeter software and
00028  *   - LHCb C++ toolkit for smart and friendly physics analysis "LoKi"
00029  *
00030  *  This base class allows "easy"(=="1 line") access to tools
00031  *  and services. This access is safe in the sense that there
00032  *  is no need to worry about the reference counts for tools
00033  *  and services.
00034  *
00035  *  The base class allows "easy" (=="1 line") access to data in
00036  *  Gaudi Transient Stores. The functionality includes the checking
00037  *  of the presence of the data at the given location, checking the
00038  *  validity of the data, retrieval of valid data and "forced" retrive
00039  *  of valid data (create if there is no data).
00040  *
00041  *  The base class allows to perform an easy error, warning and exception
00042  *  treatments, including the accumulated statistics of exceptions, errors
00043  *  and warnings.
00044  *
00045  *  The base class also includes utilities for general statistical counters.
00046  *
00047  *  It has been reported that usage of this base class results in
00048  *  significant shrinkage of existing code lines.
00049  *
00050  *  @attention
00051  *  See also the class GaudiCommon, which implements some of the common
00052  *  functionality between GaudiTool and GaudiAlgorithm.
00053  *
00054  *  @author Vanya BELYAEV Ivan.Belyaev@itep.ru
00055  *  @author Chris Jones   Christopher.Rob.Jones@cern.ch
00056  *  @date 30/06/2001
00057  */
00058 // ============================================================================
00092 // ============================================================================
00093 class GaudiAlgorithm : public GaudiCommon<Algorithm>
00094 {
00095   // friend factory for instantiation
00096   friend class AlgFactory<GaudiAlgorithm>;
00097 public:
00098   // ==========================================================================
00104   virtual StatusCode initialize();
00105   // ==========================================================================
00111   virtual StatusCode execute   ();
00112   // ==========================================================================
00118   virtual StatusCode finalize  ();
00119   // ==========================================================================
00126   virtual StatusCode sysExecute () ;
00127   // ==========================================================================  
00128 public:
00129 
00130   // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
00131   // and detDvc() ) that are not members of AlgTool.
00132   // Also some methods seem which are members of the base class do not seem
00133   // to be found unless forwarding methods are put here ??
00134 
00167   inline void put ( IDataProviderSvc*  svc     ,
00168                     DataObject*        object  ,
00169                     const std::string& address ,
00170                     const bool useRootInTES = true ) const
00171   {
00172     GaudiCommon<Algorithm>::put ( svc , object , address , useRootInTES ) ;
00173   }
00174 
00206   inline void put ( DataObject*        object   ,
00207                     const std::string& address  ,
00208                     const bool useRootInTES = true ) const
00209   {
00210     GaudiCommon<Algorithm>::put ( evtSvc() , object , address , useRootInTES ) ;
00211   }
00212 
00245   template < class TYPE  >
00246   inline TYPE* get  ( IDataProviderSvc*  svc       ,
00247                       const std::string& location  ,
00248                       const bool useRootInTES = true ) const
00249   {
00250     return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , useRootInTES ) ;
00251   }
00252 
00279   template < class TYPE  >
00280   inline TYPE* get  ( const std::string& location,
00281                       const bool useRootInTES = true ) const
00282   {
00283     return GaudiCommon<Algorithm>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
00284   }
00285 
00304   template < class TYPE  >
00305   inline TYPE* getDet ( IDataProviderSvc*  svc        ,
00306                         const std::string& location   ) const
00307   {
00308     return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , false ) ;
00309   }
00310 
00328   template < class TYPE  >
00329   inline TYPE* getDet ( const std::string& location   ) const
00330   {
00331     return GaudiCommon<Algorithm>::get<TYPE> ( detSvc() , location , false ) ;
00332   }
00333 
00360   template < class TYPE  >
00361   inline bool  exist    ( IDataProviderSvc*  svc      ,
00362                           const std::string& location ,
00363                           const bool useRootInTES = true ) const
00364   {
00365     return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , useRootInTES ) ;
00366   }
00367 
00393   template < class TYPE  >
00394   inline bool  exist    ( const std::string& location ,
00395                           const bool useRootInTES = true ) const
00396   {
00397     return GaudiCommon<Algorithm>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
00398   }
00399 
00416   template < class TYPE  >
00417   inline bool  existDet    ( IDataProviderSvc*  svc      ,
00418                              const std::string& location ) const
00419   {
00420     return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , false ) ;
00421   }
00422 
00438   template < class TYPE  >
00439   inline bool  existDet    ( const std::string& location ) const
00440   {
00441     return GaudiCommon<Algorithm>::exist<TYPE> ( detSvc() , location , false ) ;
00442   }
00443 
00471   template < class TYPE , class TYPE2 >
00472   inline TYPE* getOrCreate ( IDataProviderSvc*  svc      ,
00473                              const std::string& location ,
00474                              const bool useRootInTES = true ) const
00475   {
00476     return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
00477   }
00478 
00505   template < class TYPE , class TYPE2 >
00506   inline TYPE* getOrCreate ( const std::string& location ,
00507                              const bool useRootInTES = true ) const
00508   {
00509     return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
00510   }
00511 public:
00512   // ==========================================================================
00518   GaudiAlgorithm ( const std::string& name        ,
00519                    ISvcLocator*       pSvcLocator );
00520   // ==========================================================================
00522   virtual ~GaudiAlgorithm();
00523   // ==========================================================================
00524 public:
00525   // ==========================================================================
00527   inline bool registerContext() const { return m_registerContext ; }
00528   // ==========================================================================  
00529 public:
00530   // ==========================================================================
00534   INTupleSvc*     evtColSvc  () const;
00535   // ==========================================================================
00539   IAlgContextSvc* contextSvc () const;
00540   // ==========================================================================
00541 private:
00542   // ==========================================================================
00543   // no public default constructor
00544   GaudiAlgorithm(); 
00545   // ==========================================================================
00546   // no public copy constructor
00547   GaudiAlgorithm             ( const GaudiAlgorithm& ); 
00548   // ==========================================================================
00549   // no public assignment operator
00550   GaudiAlgorithm& operator = ( const GaudiAlgorithm& ); 
00551   // ==========================================================================
00552 private:
00553   // ==========================================================================
00554   // Pointer to the Event Tag Collection Service
00555   mutable INTupleSvc*     m_evtColSvc      ; 
00556   // Pointer to the Algorithm Context Service 
00557   mutable IAlgContextSvc* m_contextSvc     ; 
00558   // The name of the Algorithm Context Service 
00559   std::string             m_contextSvcName ; 
00560   // enforce the algorithm registration for Algorithm Context Service
00561   bool    m_registerContext ; 
00562   // ==========================================================================
00563 };
00564 // ============================================================================
00565 // The END
00566 // ============================================================================
00567 #endif // GAUDIALG_GaudiAlgorithm_H
00568 // ============================================================================
00569 
00570 

Generated at Fri Jul 18 11:59:19 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004