DataOnDemandSvc.h
Go to the documentation of this file.00001
00002
00003 #ifndef GAUDISVC_DATAONDEMANDSVC_H
00004 #define GAUDISVC_DATAONDEMANDSVC_H
00005
00006
00007
00008
00009
00010 #include <map>
00011 #include <vector>
00012
00013
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
00022
00023 #include "Reflex/Reflex.h"
00024
00025
00026
00027 class IAlgTool;
00028 class IAlgorithm;
00029 class IAlgManager;
00030 class IIncidentSvc;
00031 class IDataProviderSvc;
00032
00089 class DataOnDemandSvc: public extends1<Service, IIncidentListener> {
00090 public:
00091
00092
00093 typedef std::vector<std::string> Setup;
00094 typedef ROOT::Reflex::Type ClassH;
00095
00100 struct Protection
00101 {
00102 bool& m_bool;
00103 Protection(bool& b) : m_bool(b) { m_bool = true; }
00104 ~Protection() { m_bool = false; }
00105 };
00106
00112 struct Node
00113 {
00114 ClassH clazz ;
00115 bool executing ;
00116 std::string name ;
00117 unsigned long num ;
00118 Node() : clazz() , executing(false) , name (), num(0) {}
00119 Node(ClassH c, bool e, const std::string& n)
00120 : clazz(c), executing(e), name(n), num(0) {}
00121 Node(const Node& c)
00122 : clazz(c.clazz), executing(c.executing), name(c.name), num(c.num) {}
00123 };
00124
00126 struct Leaf
00127 {
00128 IAlgorithm* algorithm ;
00129 bool executing ;
00130 std::string name ;
00131 std::string type ;
00132 unsigned long num ;
00133 Leaf() : algorithm ( 0 ) , executing (false ) , name() , type() , num ( 0 ) {}
00134 Leaf(const Leaf& l)
00135 : algorithm(l.algorithm),
00136 executing(l.executing), name(l.name), type(l.type), num(l.num) {}
00137 Leaf(const std::string& t, const std::string& n)
00138 : algorithm(0), executing(false), name(n), type(t), num(0) {}
00139 };
00140
00142 struct Timer
00143 {
00144 public:
00145
00147 Timer ( ChronoEntity& c ) : m_timer ( c ) { m_timer.start () ; }
00149 ~Timer ( ) { m_timer.stop () ; }
00150
00151 private:
00152
00154 Timer() ;
00155
00156 private:
00157
00159 ChronoEntity& m_timer ;
00160
00161 } ;
00162
00163 public:
00164
00165 typedef std::map<std::string, Node> NodeMap;
00166 typedef std::map<std::string, Leaf> AlgMap;
00168 virtual StatusCode initialize();
00170 virtual StatusCode finalize();
00172 virtual StatusCode reinitialize();
00174 virtual void handle(const Incident& incident);
00180 DataOnDemandSvc( const std::string& name, ISvcLocator* svc );
00182 virtual ~DataOnDemandSvc();
00183
00184 protected:
00185
00190 StatusCode configureHandler(Leaf& leaf);
00191
00197 StatusCode execHandler(const std::string& tag, Leaf& leaf);
00198
00204 StatusCode execHandler(const std::string& tag, Node& node);
00205
00207 StatusCode setupNodeHandlers();
00208
00210 StatusCode setupAlgHandlers();
00211
00213 StatusCode setup();
00214
00215 public:
00216
00217 void update_1 ( Property& p ) ;
00218 void update_2 ( Property& p ) ;
00219 void update_3 ( Property& p ) ;
00220
00221 protected:
00222
00224 StatusCode update() ;
00226 inline MsgStream& stream () const
00227 {
00228 if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
00229 return *m_log;
00230 }
00235 void dump ( const MSG::Level level , const bool mode = true ) const ;
00236
00237 private:
00238
00240 IIncidentSvc* m_incSvc;
00242 IAlgManager* m_algMgr;
00244 IDataProviderSvc* m_dataSvc;
00246 std::string m_trapType;
00248 std::string m_dataSvcName;
00250 bool m_partialPath;
00252 bool m_dump;
00254 Setup m_algMapping;
00256 Setup m_nodeMapping;
00258 AlgMap m_algs;
00260 NodeMap m_nodes;
00261
00262 typedef std::map<std::string,std::string> Map ;
00264 Map m_algMap ;
00266 Map m_nodeMap ;
00267 bool m_updateRequired ;
00268 std::string m_prefix ;
00269 mutable MsgStream* m_log ;
00270
00271 ChronoEntity m_total ;
00272 ulonglong m_statAlg ;
00273 ulonglong m_statNode ;
00274 ulonglong m_stat ;
00275
00276 } ;
00277
00278
00279
00280
00281
00282 #endif // GAUDISVC_DATAONDEMANDSVC_H
00283
00284