Go to the documentation of this file.00001 #ifndef GAUDISVC_DATAONDEMANDSVC_H
00002 #define GAUDISVC_DATAONDEMANDSVC_H
00003
00004
00005
00006
00007
00008 #include <map>
00009 #include <vector>
00010
00011
00012
00013 #include "GaudiKernel/Service.h"
00014 #include "GaudiKernel/SvcFactory.h"
00015 #include "GaudiKernel/IIncidentListener.h"
00016 #include "GaudiKernel/ChronoEntity.h"
00017 #include "GaudiKernel/StatEntity.h"
00018 #include "GaudiKernel/StringKey.h"
00019 #include "GaudiKernel/IDODAlgMapper.h"
00020 #include "GaudiKernel/IDODNodeMapper.h"
00021
00022
00023
00024 #include "Reflex/Reflex.h"
00025
00026
00027
00028 class IAlgTool;
00029 class IAlgorithm;
00030 class IAlgManager;
00031 class IIncidentSvc;
00032 class IDataProviderSvc;
00033 class IToolSvc;
00034
00091 class DataOnDemandSvc: public extends1<Service, IIncidentListener>
00092 {
00093 public:
00094
00095
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
00119 ClassH clazz ;
00120 bool executing ;
00121 std::string name ;
00122 unsigned long num ;
00124 bool dataObject ;
00125
00126 Node()
00127 : clazz ( )
00128 , executing ( false )
00129 , name ( )
00130 , num ( 0 )
00131 , dataObject ( false )
00132 {}
00133
00134 Node ( ClassH c ,
00135 bool e ,
00136 const std::string& n )
00137 : clazz ( c )
00138 , executing ( e )
00139 , name ( n )
00140 , num ( 0 )
00141 , dataObject ( "DataObject" == n )
00142 {}
00143
00144 Node( const Node& c )
00145 : clazz ( c.clazz )
00146 , executing ( c.executing )
00147 , name ( c.name )
00148 , num ( c.num )
00149 , dataObject ( c.dataObject )
00150 {}
00151
00152 };
00153
00155 struct Leaf
00156 {
00157 IAlgorithm* algorithm ;
00158 bool executing ;
00159 std::string name ;
00160 std::string type ;
00161 unsigned long num ;
00162 Leaf() : algorithm ( 0 ) , executing (false ) , name() , type() , num ( 0 ) {}
00163 Leaf(const Leaf& l)
00164 : algorithm(l.algorithm),
00165 executing(l.executing), name(l.name), type(l.type), num(l.num) {}
00166 Leaf(const std::string& t, const std::string& n)
00167 : algorithm(0), executing(false), name(n), type(t), num(0) {}
00168 };
00169
00170 public:
00171
00172 typedef GaudiUtils::HashMap<Gaudi::StringKey, Node> NodeMap;
00173 typedef GaudiUtils::HashMap<Gaudi::StringKey, Leaf> AlgMap;
00175 virtual StatusCode initialize();
00177 virtual StatusCode finalize();
00179 virtual StatusCode reinitialize();
00181 virtual void handle(const Incident& incident);
00187 DataOnDemandSvc
00188 ( const std::string& name ,
00189 ISvcLocator* svc ) ;
00191 virtual ~DataOnDemandSvc();
00192
00193 protected:
00194
00199 StatusCode configureHandler(Leaf& leaf);
00200
00206 StatusCode execHandler(const std::string& tag, Leaf& leaf);
00207
00213 StatusCode execHandler(const std::string& tag, Node& node);
00214
00216 StatusCode setupNodeHandlers();
00217
00219 StatusCode setupAlgHandlers();
00220
00222 StatusCode setup();
00224 void i_setNodeHandler(const std::string &name, const std::string &type);
00226 StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg);
00227
00228 public:
00229
00230 void update_1 ( Property& p ) ;
00231 void update_2 ( Property& p ) ;
00232 void update_3 ( Property& p ) ;
00234 void update_dump ( Property& ) ;
00235
00236 protected:
00237
00239 StatusCode update() ;
00241 inline MsgStream& stream () const
00242 {
00243 if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
00244 return *m_log;
00245 }
00250 void dump ( const MSG::Level level , const bool mode = true ) const ;
00251
00252 private:
00253
00255 SmartIF<IIncidentSvc> m_incSvc;
00257 SmartIF<IAlgManager> m_algMgr;
00259 SmartIF<IDataProviderSvc> m_dataSvc;
00261 SmartIF<IToolSvc> m_toolSvc;
00263 std::string m_trapType;
00265 std::string m_dataSvcName;
00267 bool m_partialPath;
00269 bool m_dump ;
00271 bool m_init ;
00274 bool m_allowInitFailure;
00276 Setup m_algMapping;
00278 Setup m_nodeMapping;
00280 AlgMap m_algs;
00282 NodeMap m_nodes;
00283
00284 typedef std::map<std::string,std::string> Map ;
00286 Map m_algMap ;
00288 Map m_nodeMap ;
00289 bool m_updateRequired ;
00290 std::string m_prefix ;
00291 mutable MsgStream* m_log ;
00292
00293 ChronoEntity m_total ;
00294 ulonglong m_statAlg ;
00295 ulonglong m_statNode ;
00296 ulonglong m_stat ;
00297
00298 ChronoEntity m_timer_nodes ;
00299 ChronoEntity m_timer_algs ;
00300 ChronoEntity m_timer_all ;
00301 bool m_locked_nodes ;
00302 bool m_locked_algs ;
00303 bool m_locked_all ;
00304
00305 std::vector<std::string> m_nodeMapTools;
00306 std::list<IDODNodeMapper *> m_nodeMappers;
00307 std::vector<std::string> m_algMapTools;
00308 std::list<IDODAlgMapper *> m_algMappers;
00309 };
00310
00311
00312
00313
00314
00315 #endif // GAUDISVC_DATAONDEMANDSVC_H
00316
00317