![]() |
|
|
Generated: 8 Jan 2009 |
00001 // $Id: HistorySvc.h,v 1.8 2008/06/04 12:35:15 marcocle Exp $ 00002 00003 #ifndef GAUDISVC_FASTHISTORYSVC_H 00004 #define GAUDISVC_FASTHISTORYSVC_H 00005 00006 #include "GaudiKernel/IHistorySvc.h" 00007 00008 #ifndef GAUDIKERNEL_SERVICE_H 00009 #include "GaudiKernel/Service.h" 00010 #endif 00011 #ifndef KERNEL_STATUSCODES_H 00012 #include "GaudiKernel/StatusCode.h" 00013 #endif 00014 00015 #include "GaudiKernel/Algorithm.h" 00016 #include "GaudiKernel/AlgTool.h" 00017 #include "GaudiKernel/IIncidentListener.h" 00018 00019 #include <vector> 00020 #include <string> 00021 #include <set> 00022 #include <map> 00023 #include <fstream> 00024 #include "GaudiKernel/ClassID.h" 00025 #include "GaudiKernel/MsgStream.h" 00026 00027 class StoreGateSvc; 00028 class IAlgContextSvc; 00029 class IIncidentSvc; 00030 class HistoryObj; 00031 class DataHistory; 00032 class AlgorithmHistory; 00033 class ServiceHistory; 00034 struct DHH; 00035 00036 // Forward declarations 00037 template <class TYPE> class SvcFactory; 00038 00045 class HistorySvc: public Service, 00046 virtual public IHistorySvc, 00047 virtual public IIncidentListener 00048 { 00049 00050 public: 00051 00052 virtual StatusCode initialize(); 00053 virtual StatusCode reinitialize(); 00054 virtual StatusCode finalize(); 00055 00056 virtual StatusCode captureState(); 00057 00058 // Query the interfaces. 00059 virtual StatusCode queryInterface( const InterfaceID& riid, 00060 void** ppvInterface ); 00061 00062 virtual StatusCode registerJob(); 00063 virtual StatusCode listProperties() const; 00064 virtual JobHistory* getJobHistory() const; 00065 00066 virtual StatusCode registerSvc(const IService&); 00067 virtual StatusCode listProperties(const IService&) const; 00068 virtual ServiceHistory* getServiceHistory(const IService&) const; 00069 virtual void getServiceHistory(std::set<ServiceHistory*>&) const; 00070 00071 virtual StatusCode registerAlg(const Algorithm&); 00072 virtual StatusCode listProperties(const Algorithm&) const; 00073 virtual AlgorithmHistory* getAlgHistory(const Algorithm&) const; 00074 virtual void getAlgHistory(std::set<AlgorithmHistory*>&) const; 00075 00076 virtual StatusCode registerAlgTool(const IAlgTool&); 00077 virtual StatusCode listProperties(const IAlgTool&) const; 00078 virtual AlgToolHistory* getAlgToolHistory(const IAlgTool&) const; 00079 virtual void getAlgToolHistory(std::set<AlgToolHistory*>&) const; 00080 00081 virtual DataHistory* createDataHistoryObj(const CLID& id, 00082 const std::string& key, 00083 const std::string& store); 00084 virtual StatusCode registerDataHistory(const CLID& id, 00085 const std::string& key, 00086 const std::string& store); 00087 virtual DataHistory* getDataHistory(const CLID& id, const std::string& key, 00088 const std::string& store) const; 00089 virtual int getDataHistory(const CLID& id, const std::string& key, 00090 const std::string& storeName, 00091 std::list<DataHistory*>& dhlist) const; 00092 00093 HistorySvc( const std::string& name, ISvcLocator* svc ); 00094 00095 virtual void handle(const Incident& inc); 00096 00097 // Destructor. 00098 virtual ~HistorySvc(); 00099 00100 private: 00101 00102 // typedef std::map<const CLID, std::map<const std::string, DataHistory*> > 00103 // DataHistMap; 00104 00105 typedef std::multimap<DHH,DataHistory*> DataHistMap; 00106 typedef DataHistMap::iterator DHMitr; 00107 typedef DataHistMap::const_iterator DHMCitr; 00108 00109 void clearState(); 00110 00111 // Allow SvcFactory to instantiate the service. 00112 friend class SvcFactory<HistorySvc>; 00113 00114 bool m_isInitialized; 00115 bool m_dump; 00116 bool m_activate; 00117 00118 IAlgContextSvc *p_algCtxSvc; 00119 00120 std::set<const Algorithm*> m_algs; 00121 std::map<const Algorithm*, AlgorithmHistory*> m_algmap; 00122 00123 std::set<const IAlgTool*> m_ialgtools; 00124 std::set<const AlgTool*> m_algtools; 00125 std::map<const AlgTool*, AlgToolHistory*> m_algtoolmap; 00126 00127 std::set<const IService*> m_svcs; 00128 std::map<const IService*, ServiceHistory*> m_svcmap; 00129 00130 std::multimap<DHH, DataHistory*> m_datMap; 00131 00132 // std::set<DataHistory*, DataHistory::DataHistoryOrder> m_datMap; 00133 00134 JobHistory *m_jobHistory; 00135 00136 std::string m_outputFile; 00137 00138 void dumpProperties(std::ofstream&) const; 00139 void dumpProperties(const IService&, std::ofstream&) const; 00140 void dumpProperties(const Algorithm&, std::ofstream&) const; 00141 void dumpProperties(const IAlgTool&, std::ofstream&) const; 00142 00143 void dumpState(std::ofstream&) const; 00144 void dumpState(const IService&, std::ofstream&) const; 00145 void dumpState(const Algorithm&, std::ofstream&) const; 00146 void dumpState(const IAlgTool&, std::ofstream&) const; 00147 00148 std::string dumpProp(const Property*) const; 00149 00150 IAlgorithm* getCurrentIAlg() const; 00151 00152 IIncidentSvc *m_incidentSvc; 00153 00154 mutable MsgStream m_log; 00155 00156 }; 00157 00158 #endif