HistorySvc.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_FASTHISTORYSVC_H
2 #define GAUDISVC_FASTHISTORYSVC_H
3 
4 #include "GaudiKernel/IHistorySvc.h"
5 
6 #ifndef GAUDIKERNEL_SERVICE_H
7  #include "GaudiKernel/Service.h"
8 #endif
9 #ifndef KERNEL_STATUSCODES_H
10  #include "GaudiKernel/StatusCode.h"
11 #endif
12 
13 #include "GaudiKernel/Algorithm.h"
14 #include "GaudiKernel/AlgTool.h"
15 #include "GaudiKernel/IIncidentListener.h"
16 #include "GaudiKernel/IVersHistoryObj.h"
17 
18 #include <vector>
19 #include <string>
20 #include <set>
21 #include <map>
22 #include <fstream>
23 #include "GaudiKernel/ClassID.h"
24 #include "GaudiKernel/MsgStream.h"
25 
26 class StoreGateSvc;
27 class IAlgContextSvc;
28 class IIncidentSvc;
29 class HistoryObj;
30 class DataHistory;
31 class AlgorithmHistory;
32 class ServiceHistory;
33 struct DHH;
34 
41 class HistorySvc: public extends2<Service, IHistorySvc, IIncidentListener> {
42 public:
43 
44  virtual StatusCode initialize();
45  virtual StatusCode reinitialize();
46  virtual StatusCode finalize();
47  virtual StatusCode stop();
48 
49  virtual StatusCode captureState();
50 
51  virtual StatusCode registerJob();
52  virtual StatusCode listProperties() const;
53  virtual JobHistory* getJobHistory() const;
54 
55  virtual StatusCode registerSvc(const IService&);
56  virtual StatusCode listProperties(const IService&) const;
57  virtual ServiceHistory* getServiceHistory(const IService&) const;
58  virtual void getServiceHistory(std::set<ServiceHistory*>&) const;
59 
60  virtual StatusCode registerAlg(const Algorithm&);
61  virtual StatusCode listProperties(const Algorithm&) const;
62  virtual AlgorithmHistory* getAlgHistory(const Algorithm&) const;
63  virtual void getAlgHistory(std::set<AlgorithmHistory*>&) const;
64 
65  virtual StatusCode registerAlgTool(const IAlgTool&);
66  virtual StatusCode listProperties(const IAlgTool&) const;
67  virtual AlgToolHistory* getAlgToolHistory(const IAlgTool&) const;
68  virtual void getAlgToolHistory(std::set<AlgToolHistory*>&) const;
69 
70  virtual DataHistory* createDataHistoryObj(const CLID& id,
71  const std::string& key,
72  const std::string& store);
73  virtual StatusCode registerDataHistory(const CLID& id,
74  const std::string& key,
75  const std::string& store);
76  virtual DataHistory* getDataHistory(const CLID& id, const std::string& key,
77  const std::string& store) const;
78  virtual int getDataHistory(const CLID& id, const std::string& key,
79  const std::string& storeName,
80  std::list<DataHistory*>& dhlist) const;
81 
82  HistorySvc( const std::string& name, ISvcLocator* svc );
83 
84  virtual void handle(const Incident& inc);
85 
86  // Destructor.
87  virtual ~HistorySvc() = default;
88 
89 private:
90 
91 // typedef std::map<const CLID, std::map<const std::string, DataHistory*> >
92 // DataHistMap;
93 
95 
96  typedef std::multimap<DHH,DataHistory*> DataHistMap;
97  typedef DataHistMap::iterator DHMitr;
98  typedef DataHistMap::const_iterator DHMCitr;
99 
100  void clearState();
101 
102  bool m_isInitialized = false;
103  bool m_dump = false;
104  bool m_activate = true;
105 
107 
108  std::map<const Algorithm*, AlgorithmHistory*> m_algmap;
109 
110  std::set<const IAlgTool*> m_ialgtools;
111  std::map<const AlgTool*, AlgToolHistory*> m_algtoolmap;
112  std::map<const IService*, ServiceHistory*> m_svcmap;
113 
114  std::multimap<DHH, DataHistory*> m_datMap;
115 
116 // std::set<DataHistory*, DataHistory::DataHistoryOrder> m_datMap;
117 
118  std::unique_ptr<JobHistory> m_jobHistory;
119 
120  std::string m_outputFile;
121 
122  void dumpProperties(std::ofstream&) const;
123  void dumpProperties(const IService&, std::ofstream&) const;
124  void dumpProperties(const Algorithm&, std::ofstream&) const;
125  void dumpProperties(const IAlgTool&, std::ofstream&) const;
126 
127  void dumpState(std::ofstream&) const;
128  void dumpState(const INamedInterface*, std::ofstream&) const;
129 
130  std::string dumpProp(const Property*, const bool isXML=false,
131  int indent=0) const;
132 
133  IAlgorithm* getCurrentIAlg() const;
134 
137 
138  mutable MsgStream m_log;
139  bool m_outputFileTypeXML = false;
140 
141 };
142 
143 #endif
virtual StatusCode stop()
Definition: HistorySvc.cpp:271
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:632
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:136
AlgorithmHistory class definition.
virtual StatusCode registerDataHistory(const CLID &id, const std::string &key, const std::string &store)
Definition: HistorySvc.cpp:529
virtual StatusCode listProperties() const
Definition: HistorySvc.cpp:412
virtual StatusCode registerJob()
Definition: HistorySvc.cpp:401
std::vector< Property * > PropertyList
HistorySvc class definition.
Definition: HistorySvc.h:41
Base class for History Objects.
Definition: HistoryObj.h:22
std::multimap< DHH, DataHistory * > DataHistMap
Definition: HistorySvc.h:96
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:114
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:111
JobHistory class definition.
Definition: JobHistory.h:24
std::string m_outputFile
Definition: HistorySvc.h:120
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:484
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:759
virtual void handle(const Incident &inc)
Definition: HistorySvc.cpp:782
bool m_activate
Definition: HistorySvc.h:104
bool m_isInitialized
Definition: HistorySvc.h:102
General service interface definition.
Definition: IService.h:18
virtual StatusCode registerSvc(const IService &)
Definition: HistorySvc.cpp:600
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc(const std::string &name, ISvcLocator *svc)
Definition: HistorySvc.cpp:76
bool m_outputFileTypeXML
Definition: HistorySvc.h:139
virtual StatusCode registerAlgTool(const IAlgTool &)
Definition: HistorySvc.cpp:684
DataHistory class definition.
Definition: DataHistory.h:23
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:106
virtual StatusCode registerAlg(const Algorithm &)
Definition: HistorySvc.cpp:320
virtual StatusCode initialize()
Definition: HistorySvc.cpp:127
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:381
virtual StatusCode finalize()
Definition: HistorySvc.cpp:298
DataHistMap::const_iterator DHMCitr
Definition: HistorySvc.h:98
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:23
MsgStream m_log
Definition: HistorySvc.h:138
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:797
AlgToolHistory class definition.
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:817
IIncidentSvc * m_incidentSvc
Definition: HistorySvc.h:135
virtual DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store)
Definition: HistorySvc.cpp:495
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:77
IInterface compliant class extending IInterface with the name() method.
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
virtual DataHistory * getDataHistory(const CLID &id, const std::string &key, const std::string &store) const
Definition: HistorySvc.cpp:566
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:456
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
Base class for all Incidents (computing events).
Definition: Incident.h:16
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ServiceHistory class definition.
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:108
IVersHistoryObj::PropertyList PropertyList
Definition: HistorySvc.h:94
An abstract interface for Algorithm Context Service.
bool m_dump
Definition: HistorySvc.h:103
virtual ~HistorySvc()=default
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:110
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
DataHistMap::iterator DHMitr
Definition: HistorySvc.h:97
void clearState()
Definition: HistorySvc.cpp:115
virtual StatusCode captureState()
Definition: HistorySvc.cpp:184
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:112
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
virtual StatusCode reinitialize()
Definition: HistorySvc.cpp:91
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:476
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:118