All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HistorySvc.h
Go to the documentation of this file.
1 // $Id: HistorySvc.h,v 1.8 2008/06/04 12:35:15 marcocle Exp $
2 
3 #ifndef GAUDISVC_FASTHISTORYSVC_H
4 #define GAUDISVC_FASTHISTORYSVC_H
5 
6 #include "GaudiKernel/IHistorySvc.h"
7 
8 #ifndef GAUDIKERNEL_SERVICE_H
9  #include "GaudiKernel/Service.h"
10 #endif
11 #ifndef KERNEL_STATUSCODES_H
12  #include "GaudiKernel/StatusCode.h"
13 #endif
14 
15 #include "GaudiKernel/Algorithm.h"
16 #include "GaudiKernel/AlgTool.h"
17 #include "GaudiKernel/IIncidentListener.h"
18 #include "GaudiKernel/IVersHistoryObj.h"
19 
20 #include <vector>
21 #include <string>
22 #include <set>
23 #include <map>
24 #include <fstream>
25 #include "GaudiKernel/ClassID.h"
26 #include "GaudiKernel/MsgStream.h"
27 
28 class StoreGateSvc;
29 class IAlgContextSvc;
30 class IIncidentSvc;
31 class HistoryObj;
32 class DataHistory;
33 class AlgorithmHistory;
34 class ServiceHistory;
35 struct DHH;
36 
43 class HistorySvc: public extends2<Service, IHistorySvc, IIncidentListener> {
44 public:
45 
46  virtual StatusCode initialize();
47  virtual StatusCode reinitialize();
48  virtual StatusCode finalize();
49  virtual StatusCode stop();
50 
51  virtual StatusCode captureState();
52 
53  virtual StatusCode registerJob();
54  virtual StatusCode listProperties() const;
55  virtual JobHistory* getJobHistory() const;
56 
57  virtual StatusCode registerSvc(const IService&);
58  virtual StatusCode listProperties(const IService&) const;
59  virtual ServiceHistory* getServiceHistory(const IService&) const;
60  virtual void getServiceHistory(std::set<ServiceHistory*>&) const;
61 
62  virtual StatusCode registerAlg(const Algorithm&);
63  virtual StatusCode listProperties(const Algorithm&) const;
64  virtual AlgorithmHistory* getAlgHistory(const Algorithm&) const;
65  virtual void getAlgHistory(std::set<AlgorithmHistory*>&) const;
66 
67  virtual StatusCode registerAlgTool(const IAlgTool&);
68  virtual StatusCode listProperties(const IAlgTool&) const;
69  virtual AlgToolHistory* getAlgToolHistory(const IAlgTool&) const;
70  virtual void getAlgToolHistory(std::set<AlgToolHistory*>&) const;
71 
72  virtual DataHistory* createDataHistoryObj(const CLID& id,
73  const std::string& key,
74  const std::string& store);
75  virtual StatusCode registerDataHistory(const CLID& id,
76  const std::string& key,
77  const std::string& store);
78  virtual DataHistory* getDataHistory(const CLID& id, const std::string& key,
79  const std::string& store) const;
80  virtual int getDataHistory(const CLID& id, const std::string& key,
81  const std::string& storeName,
82  std::list<DataHistory*>& dhlist) const;
83 
84  HistorySvc( const std::string& name, ISvcLocator* svc );
85 
86  virtual void handle(const Incident& inc);
87 
88  // Destructor.
89  virtual ~HistorySvc();
90 
91 private:
92 
93 // typedef std::map<const CLID, std::map<const std::string, DataHistory*> >
94 // DataHistMap;
95 
97 
98  typedef std::multimap<DHH,DataHistory*> DataHistMap;
99  typedef DataHistMap::iterator DHMitr;
100  typedef DataHistMap::const_iterator DHMCitr;
101 
102  void clearState();
103 
105  bool m_dump;
107 
109 
110  std::set<const Algorithm*> m_algs;
111  std::map<const Algorithm*, AlgorithmHistory*> m_algmap;
112 
113  std::set<const IAlgTool*> m_ialgtools;
114  std::set<const AlgTool*> m_algtools;
115  std::map<const AlgTool*, AlgToolHistory*> m_algtoolmap;
116 
117  std::set<const IService*> m_svcs;
118  std::map<const IService*, ServiceHistory*> m_svcmap;
119 
120  std::multimap<DHH, DataHistory*> m_datMap;
121 
122 // std::set<DataHistory*, DataHistory::DataHistoryOrder> m_datMap;
123 
125 
126  std::string m_outputFile;
127 
128  void dumpProperties(std::ofstream&) const;
129  void dumpProperties(const IService&, std::ofstream&) const;
130  void dumpProperties(const Algorithm&, std::ofstream&) const;
131  void dumpProperties(const IAlgTool&, std::ofstream&) const;
132 
133  void dumpState(std::ofstream&) const;
134  void dumpState(const INamedInterface*, std::ofstream&) const;
135 
136  std::string dumpProp(const Property*, const bool isXML=false,
137  int indent=0) const;
138 
139  IAlgorithm* getCurrentIAlg() const;
140 
143 
144  mutable MsgStream m_log;
146 
147 };
148 
149 #endif