Gaudi Framework, version v21r9

Home   Generated: 3 May 2010

DataOnDemandSvc.h

Go to the documentation of this file.
00001 // $Id: DataOnDemandSvc.h,v 1.10 2008/10/01 14:33:07 marcocle Exp $
00002 // ============================================================================
00003 #ifndef GAUDISVC_DATAONDEMANDSVC_H
00004 #define GAUDISVC_DATAONDEMANDSVC_H
00005 // ============================================================================
00006 // Include Files
00007 // ============================================================================
00008 // STD & STL
00009 // ============================================================================
00010 #include <map>
00011 #include <vector>
00012 // ============================================================================
00013 // GaudiKernel
00014 // ============================================================================
00015 #include "GaudiKernel/Service.h"
00016 #include "GaudiKernel/SvcFactory.h"
00017 #include "GaudiKernel/IIncidentListener.h"
00018 #include "GaudiKernel/ChronoEntity.h"
00019 #include "GaudiKernel/StatEntity.h"
00020 #include "GaudiKernel/StringKey.h"
00021 // ============================================================================
00022 // Reflex
00023 // ============================================================================
00024 #include "Reflex/Reflex.h"
00025 // ============================================================================
00026 // Forward declarations
00027 // ============================================================================
00028 class IAlgTool;
00029 class IAlgorithm;
00030 class IAlgManager;
00031 class IIncidentSvc;
00032 class IDataProviderSvc;
00033 // ============================================================================
00090 class DataOnDemandSvc: public extends1<Service, IIncidentListener> 
00091 {
00092 public:
00093   // ==========================================================================
00094   // Typedefs
00095   typedef std::vector<std::string> Setup;
00096   typedef ROOT::Reflex::Type       ClassH;
00097   // ==========================================================================
00102   struct Protection
00103   {
00104     bool& m_bool;
00105     Protection(bool& b) : m_bool(b) { m_bool = true;  }
00106     ~Protection()                   { m_bool = false; }
00107   };
00108   // ==========================================================================
00114   struct Node
00115   {
00116     // ========================================================================
00118     ClassH        clazz      ;                              // the actual class
00119     bool          executing  ;
00120     std::string   name       ;
00121     unsigned long num        ;
00123     bool          dataObject ;                  // trivial object? DataObject?
00124     // =======================================================================
00125     Node() 
00126       : clazz      (       ) 
00127       , executing  ( false ) 
00128       , name       (       )
00129       , num        ( 0     )  
00130       , dataObject ( false ) 
00131     {}
00132     // ========================================================================
00133     Node ( ClassH             c , 
00134            bool               e , 
00135            const std::string& n )
00136       : clazz     ( c )
00137       , executing ( e )
00138       , name      ( n )
00139       , num       ( 0 )
00140       , dataObject ( "DataObject" == n ) 
00141     {}
00142     //
00143     Node( const Node& c )
00144       : clazz      ( c.clazz      )
00145       , executing  ( c.executing  )
00146       , name       ( c.name       ) 
00147       , num        ( c.num        )  
00148       , dataObject ( c.dataObject ) 
00149     {}
00150     // ========================================================================
00151   };
00152   // ==========================================================================
00154   struct Leaf
00155   {
00156     IAlgorithm*   algorithm ;
00157     bool          executing ;
00158     std::string   name      ;
00159     std::string   type      ;
00160     unsigned long num       ;
00161     Leaf() : algorithm ( 0 ) , executing (false ) , name() , type() , num ( 0 ) {}
00162     Leaf(const Leaf& l)
00163       : algorithm(l.algorithm),
00164         executing(l.executing), name(l.name), type(l.type), num(l.num)  {}
00165     Leaf(const std::string& t, const std::string& n)
00166       : algorithm(0), executing(false), name(n), type(t), num(0)  {}
00167   };
00168   // ==========================================================================
00169 public:
00170   // ==========================================================================
00171   typedef GaudiUtils::HashMap<Gaudi::StringKey, Node>  NodeMap;
00172   typedef GaudiUtils::HashMap<Gaudi::StringKey, Leaf>  AlgMap;
00174   virtual StatusCode initialize();
00176   virtual StatusCode finalize();
00178   virtual StatusCode reinitialize();
00180   virtual void handle(const Incident& incident);
00186   DataOnDemandSvc 
00187   ( const std::string& name ,                    //       Service instance name
00188     ISvcLocator*       svc  ) ;                  //  Pointer to service locator
00190   virtual ~DataOnDemandSvc();                            // Standard destructor
00191   // ==========================================================================
00192 protected:
00193   // ==========================================================================
00198    StatusCode configureHandler(Leaf& leaf);
00199   // ==========================================================================
00205   StatusCode execHandler(const std::string& tag, Leaf& leaf);
00206   // ==========================================================================
00212   StatusCode execHandler(const std::string& tag, Node& node);
00213   // ==========================================================================
00215   StatusCode setupNodeHandlers();
00216   // ==========================================================================
00218   StatusCode setupAlgHandlers();
00219   // ==========================================================================
00221   StatusCode setup();
00222   // ==========================================================================
00223 public:
00224   // ==========================================================================
00225   void update_1 ( Property& p ) ;
00226   void update_2 ( Property& p ) ;
00227   void update_3 ( Property& p ) ;
00229   void update_dump ( Property& /* p */ ) ;// update handler for 'Dump' property 
00230   // ==========================================================================
00231 protected:
00232   // ==========================================================================
00234   StatusCode update() ;
00236   inline MsgStream& stream () const
00237   {
00238     if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
00239     return *m_log;
00240   }
00245   void dump ( const MSG::Level level , const bool mode = true ) const ;
00246   // ==========================================================================
00247 private:
00248   // ==========================================================================
00250   IIncidentSvc*     m_incSvc;
00252   IAlgManager*      m_algMgr;
00254   IDataProviderSvc* m_dataSvc;
00256   std::string       m_trapType;
00258   std::string       m_dataSvcName;
00260   bool              m_partialPath;
00262   bool              m_dump ;
00264   bool              m_init ;
00266   Setup             m_algMapping;
00268   Setup             m_nodeMapping;
00270   AlgMap            m_algs;
00272   NodeMap           m_nodes;
00273   //
00274   typedef std::map<std::string,std::string> Map ;
00276   Map                m_algMap          ; // { 'data' : 'algorithm' }
00278   Map                m_nodeMap         ; // { 'data' : 'type' }
00279   bool               m_updateRequired  ;
00280   std::string        m_prefix          ;
00281   mutable MsgStream* m_log             ;
00282   // ==========================================================================
00283   ChronoEntity       m_total           ;
00284   ulonglong          m_statAlg         ;
00285   ulonglong          m_statNode        ;
00286   ulonglong          m_stat            ;
00287   // ==========================================================================  
00288   ChronoEntity       m_timer_nodes     ;
00289   ChronoEntity       m_timer_algs      ;
00290   ChronoEntity       m_timer_all       ;
00291   bool               m_locked_nodes    ;
00292   bool               m_locked_algs     ;
00293   bool               m_locked_all      ;
00294   // ==========================================================================
00295 } ;
00296 // ============================================================================
00297 
00298 // ============================================================================
00299 // The END
00300 // ============================================================================
00301 #endif // GAUDISVC_DATAONDEMANDSVC_H
00302 // ============================================================================
00303 

Generated at Mon May 3 12:14:48 2010 for Gaudi Framework, version v21r9 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004