![]() |
|
|
Generated: 24 Nov 2008 |
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 // ============================================================================ 00021 // Reflex 00022 // ============================================================================ 00023 #include "Reflex/Reflex.h" 00024 // ============================================================================ 00025 // Forward declarations 00026 // ============================================================================ 00027 class IAlgTool; 00028 class IAlgorithm; 00029 class IAlgManager; 00030 class IIncidentSvc; 00031 class IDataProviderSvc; 00032 // ============================================================================ 00089 class DataOnDemandSvc 00090 : public Service 00091 , virtual public IIncidentListener 00092 { 00093 public: 00094 // ========================================================================== 00095 // Typedefs 00096 typedef std::vector<std::string> Setup; 00097 typedef ROOT::Reflex::Type ClassH; 00098 // ========================================================================== 00103 struct Protection 00104 { 00105 bool& m_bool; 00106 Protection(bool& b) : m_bool(b) { m_bool = true; } 00107 ~Protection() { m_bool = false; } 00108 }; 00109 // ========================================================================== 00115 struct Node 00116 { 00117 ClassH clazz ; 00118 bool executing ; 00119 std::string name ; 00120 unsigned long num ; 00121 Node() : clazz() , executing(false) , name (), num(0) {} 00122 Node(ClassH c, bool e, const std::string& n) 00123 : clazz(c), executing(e), name(n), num(0) {} 00124 Node(const Node& c) 00125 : clazz(c.clazz), executing(c.executing), name(c.name), num(c.num) {} 00126 }; 00127 // ========================================================================== 00129 struct Leaf 00130 { 00131 IAlgorithm* algorithm ; 00132 bool executing ; 00133 std::string name ; 00134 std::string type ; 00135 unsigned long num ; 00136 Leaf() : algorithm ( 0 ) , executing (false ) , name() , type() , num ( 0 ) {} 00137 Leaf(const Leaf& l) 00138 : algorithm(l.algorithm), 00139 executing(l.executing), name(l.name), type(l.type), num(l.num) {} 00140 Leaf(const std::string& t, const std::string& n) 00141 : algorithm(0), executing(false), name(n), type(t), num(0) {} 00142 }; 00143 // ========================================================================== 00145 struct Timer 00146 { 00147 public: 00148 // ======================================================================== 00150 Timer ( ChronoEntity& c ) : m_timer ( c ) { m_timer.start () ; } 00152 ~Timer ( ) { m_timer.stop () ; } 00153 // ======================================================================== 00154 private: 00155 // ======================================================================== 00157 Timer() ; // no default constructor 00158 // ======================================================================== 00159 private: 00160 // ======================================================================== 00162 ChronoEntity& m_timer ; // the actual timer 00163 // ======================================================================== 00164 } ; 00165 // ========================================================================== 00166 public: 00167 // ========================================================================== 00168 typedef std::map<std::string, Node> NodeMap; 00169 typedef std::map<std::string, Leaf> AlgMap; 00171 virtual StatusCode initialize(); 00173 virtual StatusCode finalize(); 00175 virtual StatusCode reinitialize(); 00177 virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ); 00179 virtual void handle(const Incident& incident); 00185 DataOnDemandSvc( const std::string& name, ISvcLocator* svc ); 00187 virtual ~DataOnDemandSvc(); 00188 // ========================================================================== 00189 protected: 00190 // ========================================================================== 00195 StatusCode configureHandler(Leaf& leaf); 00196 // ========================================================================== 00202 StatusCode execHandler(const std::string& tag, Leaf& leaf); 00203 // ========================================================================== 00209 StatusCode execHandler(const std::string& tag, Node& node); 00210 // ========================================================================== 00212 StatusCode setupNodeHandlers(); 00213 // ========================================================================== 00215 StatusCode setupAlgHandlers(); 00216 // ========================================================================== 00218 StatusCode setup(); 00219 // ========================================================================== 00220 public: 00221 // ========================================================================== 00222 void update_1 ( Property& p ) ; 00223 void update_2 ( Property& p ) ; 00224 void update_3 ( Property& p ) ; 00225 // ========================================================================== 00226 protected: 00227 // ========================================================================== 00229 StatusCode update() ; 00231 inline MsgStream& stream () const 00232 { 00233 if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; } 00234 return *m_log; 00235 } 00240 void dump ( const MSG::Level level , const bool mode = true ) const ; 00241 // ========================================================================== 00242 private: 00243 // ========================================================================== 00245 IIncidentSvc* m_incSvc; 00247 IAlgManager* m_algMgr; 00249 IDataProviderSvc* m_dataSvc; 00251 std::string m_trapType; 00253 std::string m_dataSvcName; 00255 bool m_partialPath; 00257 bool m_dump; 00259 Setup m_algMapping; 00261 Setup m_nodeMapping; 00263 AlgMap m_algs; 00265 NodeMap m_nodes; 00266 // 00267 typedef std::map<std::string,std::string> Map ; 00269 Map m_algMap ; // { 'data' : 'algorithm' } 00271 Map m_nodeMap ; // { 'data' : 'type' } 00272 bool m_updateRequired ; 00273 std::string m_prefix ; 00274 mutable MsgStream* m_log ; 00275 // ========================================================================== 00276 ChronoEntity m_total ; 00277 ulonglong m_statAlg ; 00278 ulonglong m_statNode ; 00279 ulonglong m_stat ; 00280 // ========================================================================== 00281 } ; 00282 // ============================================================================ 00283 00284 // ============================================================================ 00285 // The END 00286 // ============================================================================ 00287 #endif // GAUDISVC_DATAONDEMANDSVC_H 00288 // ============================================================================ 00289