The Gaudi Framework  master (37c0b60a)
HistorySvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDISVC_FASTHISTORYSVC_H
12 #define GAUDISVC_FASTHISTORYSVC_H
13 
15 
16 #include <Gaudi/Algorithm.h>
17 #include <GaudiKernel/AlgTool.h>
20 #include <GaudiKernel/Service.h>
21 #include <GaudiKernel/SmartIF.h>
22 #include <GaudiKernel/StatusCode.h>
23 
24 #include <GaudiKernel/ClassID.h>
25 #include <GaudiKernel/MsgStream.h>
26 #include <fstream>
27 #include <map>
28 #include <set>
29 #include <string>
30 #include <vector>
31 
32 class StoreGateSvc;
33 class IAlgContextSvc;
34 class IIncidentSvc;
35 class HistoryObj;
36 class DataHistory;
37 class AlgorithmHistory;
38 class ServiceHistory;
39 struct DHH;
40 
47 class HistorySvc : public extends<Service, IHistorySvc, IIncidentListener> {
48 public:
49  using extends::extends;
50 
51  StatusCode initialize() override;
52  StatusCode reinitialize() override;
53  StatusCode finalize() override;
54  StatusCode stop() override;
55 
56  virtual StatusCode captureState();
57 
58  StatusCode registerJob() override;
59  StatusCode listProperties() const override;
60  JobHistory* getJobHistory() const override;
61 
62  StatusCode registerSvc( const IService& ) override;
63  StatusCode listProperties( const IService& ) const override;
64  ServiceHistory* getServiceHistory( const IService& ) const override;
65  void getServiceHistory( std::set<ServiceHistory*>& ) const override;
66 
67  StatusCode registerAlg( const Gaudi::Algorithm& ) override;
68  StatusCode listProperties( const Gaudi::Algorithm& ) const override;
69  AlgorithmHistory* getAlgHistory( const Gaudi::Algorithm& ) const override;
70  void getAlgHistory( std::set<AlgorithmHistory*>& ) const override;
71 
72  StatusCode registerAlgTool( const IAlgTool& ) override;
73  StatusCode listProperties( const IAlgTool& ) const override;
74  AlgToolHistory* getAlgToolHistory( const IAlgTool& ) const override;
75  void getAlgToolHistory( std::set<AlgToolHistory*>& ) const override;
76 
77  DataHistory* createDataHistoryObj( const CLID& id, const std::string& key, const std::string& store ) override;
78  virtual StatusCode registerDataHistory( const CLID& id, const std::string& key, const std::string& store );
79  DataHistory* getDataHistory( const CLID& id, const std::string& key, const std::string& store ) const override;
80  virtual int getDataHistory( const CLID& id, const std::string& key, const std::string& storeName,
81  std::list<DataHistory*>& dhlist ) const;
82 
83  void handle( const Incident& inc ) override;
84 
85 private:
86  // typedef std::map<const CLID, std::map<const std::string, DataHistory*> >
87  // DataHistMap;
88 
90 
92  typedef DataHistMap::iterator DHMitr;
93  typedef DataHistMap::const_iterator DHMCitr;
94 
95  Gaudi::Property<bool> m_dump{ this, "Dump", false };
96  Gaudi::Property<bool> m_activate{ this, "Activate", true };
98  ServiceHandle<IAlgContextSvc> p_algCtxSvc{ this, "AlgContextSvc", "AlgContextSvc" };
99 
100  void clearState();
101 
102  bool m_isInitialized = false;
103 
105 
109 
111 
113 
114  void dumpProperties( std::ofstream& ) const;
115  void dumpProperties( const IService&, std::ofstream& ) const;
116  void dumpProperties( const Gaudi::Algorithm&, std::ofstream& ) const;
117  void dumpProperties( const IAlgTool&, std::ofstream& ) const;
118 
119  void dumpState( std::ofstream& ) const;
120  void dumpState( const INamedInterface*, std::ofstream& ) const;
121 
122  std::string dumpProp( const Gaudi::Details::PropertyBase*, const bool isXML = false, int indent = 0 ) const;
123 
124  IAlgorithm* getCurrentIAlg() const;
125 
127 
128  bool m_outputFileTypeXML = false;
129 };
130 
131 #endif
HistorySvc
Definition: HistorySvc.h:47
IService
Definition: IService.h:28
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
HistorySvc::DHMitr
DataHistMap::iterator DHMitr
Definition: HistorySvc.h:92
HistorySvc::m_outputFileTypeXML
bool m_outputFileTypeXML
Definition: HistorySvc.h:128
HistorySvc::m_activate
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:96
HistorySvc::listProperties
StatusCode listProperties() const override
Definition: HistorySvc.cpp:344
HistorySvc::initialize
StatusCode initialize() override
Definition: HistorySvc.cpp:120
DHH
Definition: HistorySvc.cpp:69
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
HistorySvc::reinitialize
StatusCode reinitialize() override
Definition: HistorySvc.cpp:86
HistorySvc::registerDataHistory
virtual StatusCode registerDataHistory(const CLID &id, const std::string &key, const std::string &store)
Definition: HistorySvc.cpp:437
HistorySvc::getJobHistory
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:398
std::list
STL class.
HistorySvc::stop
StatusCode stop() override
Definition: HistorySvc.cpp:237
ServiceHandle< IAlgContextSvc >
HistorySvc::createDataHistoryObj
DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store) override
Definition: HistorySvc.cpp:410
std::vector< Gaudi::Details::PropertyBase * >
HistorySvc::DHMCitr
DataHistMap::const_iterator DHMCitr
Definition: HistorySvc.h:93
ClassID.h
HistorySvc::registerSvc
StatusCode registerSvc(const IService &) override
Definition: HistorySvc.cpp:498
HistorySvc::m_datMap
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:110
HistorySvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:126
HistorySvc::getCurrentIAlg
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:401
HistorySvc::registerJob
StatusCode registerJob() override
Definition: HistorySvc.cpp:341
HistorySvc::DataHistMap
std::multimap< DHH, DataHistory * > DataHistMap
Definition: HistorySvc.h:91
AlgToolHistory
Definition: AlgToolHistory.h:32
HistorySvc::m_algmap
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
HistorySvc::dumpProp
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:659
HistorySvc::getServiceHistory
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:525
StatusCode.h
HistorySvc::m_outputFile
Gaudi::Property< std::string > m_outputFile
Definition: HistorySvc.h:97
HistorySvc::clearState
void clearState()
Definition: HistorySvc.cpp:109
HistorySvc::m_dump
Gaudi::Property< bool > m_dump
Definition: HistorySvc.h:95
HistorySvc::PropertyList
IVersHistoryObj::PropertyList PropertyList
Definition: HistorySvc.h:89
HistorySvc::m_isInitialized
bool m_isInitialized
Definition: HistorySvc.h:102
SmartIF.h
HistorySvc::getAlgHistory
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:327
HistoryObj
Definition: HistoryObj.h:31
AlgorithmHistory
Definition: AlgorithmHistory.h:38
StatusCode
Definition: StatusCode.h:65
IAlgorithm
Definition: IAlgorithm.h:38
IVersHistoryObj.h
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:112
std::ofstream
STL class.
ServiceHistory
Definition: ServiceHistory.h:31
HistorySvc::getDataHistory
DataHistory * getDataHistory(const CLID &id, const std::string &key, const std::string &store) const override
Definition: HistorySvc.cpp:470
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108
HistorySvc::finalize
StatusCode finalize() override
Definition: HistorySvc.cpp:260
Algorithm.h
SmartIF< IToolSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
IHistorySvc.h
std::map< const Gaudi::Algorithm *, AlgorithmHistory * >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
HistorySvc::dumpState
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:676
HistorySvc::registerAlgTool
StatusCode registerAlgTool(const IAlgTool &) override
Definition: HistorySvc.cpp:566
Service.h
INamedInterface
Definition: INamedInterface.h:25
IIncidentListener.h
HistorySvc::registerAlg
StatusCode registerAlg(const Gaudi::Algorithm &) override
Definition: HistorySvc.cpp:279
JobHistory
Definition: JobHistory.h:33
DataHistory
Definition: DataHistory.h:33
IAlgContextSvc
Definition: IAlgContextSvc.h:33
HistorySvc::m_ialgtools
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:106
std::multimap< DHH, DataHistory * >
AlgTool.h
HistorySvc::getAlgToolHistory
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:631
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
HistorySvc::handle
void handle(const Incident &inc) override
Definition: HistorySvc.cpp:648
HistorySvc::dumpProperties
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:380
HistorySvc::p_algCtxSvc
ServiceHandle< IAlgContextSvc > p_algCtxSvc
Definition: HistorySvc.h:98
IIncidentSvc
Definition: IIncidentSvc.h:33
Incident
Definition: Incident.h:27
std::unique_ptr< JobHistory >
ProduceConsume.key
key
Definition: ProduceConsume.py:84
std::set
STL class.
Gaudi::Property< bool >
MsgStream.h
HistorySvc::captureState
virtual StatusCode captureState()
Definition: HistorySvc.cpp:168