The Gaudi Framework  master (d98a2936)
HistorySvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
14 
15 #include <Gaudi/Algorithm.h>
16 #include <GaudiKernel/AlgTool.h>
19 #include <GaudiKernel/Service.h>
20 #include <GaudiKernel/SmartIF.h>
21 #include <GaudiKernel/StatusCode.h>
22 
23 #include <GaudiKernel/ClassID.h>
24 #include <GaudiKernel/MsgStream.h>
25 #include <fstream>
26 #include <map>
27 #include <set>
28 #include <string>
29 #include <vector>
30 
31 class StoreGateSvc;
32 class IAlgContextSvc;
33 class IIncidentSvc;
34 class HistoryObj;
35 class DataHistory;
36 class AlgorithmHistory;
37 class ServiceHistory;
38 struct DHH;
39 
46 class HistorySvc : public extends<Service, IHistorySvc, IIncidentListener> {
47 public:
48  using extends::extends;
49 
50  StatusCode initialize() override;
51  StatusCode reinitialize() override;
52  StatusCode finalize() override;
53  StatusCode stop() override;
54 
55  virtual StatusCode captureState();
56 
57  StatusCode registerJob() override;
58  StatusCode listProperties() const override;
59  JobHistory* getJobHistory() const override;
60 
61  StatusCode registerSvc( const IService& ) override;
62  StatusCode listProperties( const IService& ) const override;
63  ServiceHistory* getServiceHistory( const IService& ) const override;
64  void getServiceHistory( std::set<ServiceHistory*>& ) const override;
65 
66  StatusCode registerAlg( const Gaudi::Algorithm& ) override;
67  StatusCode listProperties( const Gaudi::Algorithm& ) const override;
68  AlgorithmHistory* getAlgHistory( const Gaudi::Algorithm& ) const override;
69  void getAlgHistory( std::set<AlgorithmHistory*>& ) const override;
70 
71  StatusCode registerAlgTool( const IAlgTool& ) override;
72  StatusCode listProperties( const IAlgTool& ) const override;
73  AlgToolHistory* getAlgToolHistory( const IAlgTool& ) const override;
74  void getAlgToolHistory( std::set<AlgToolHistory*>& ) const override;
75 
76  DataHistory* createDataHistoryObj( const CLID& id, const std::string& key, const std::string& store ) override;
77  virtual StatusCode registerDataHistory( const CLID& id, const std::string& key, const std::string& store );
78  DataHistory* getDataHistory( const CLID& id, const std::string& key, const std::string& store ) const override;
79  virtual int getDataHistory( const CLID& id, const std::string& key, const std::string& storeName,
80  std::list<DataHistory*>& dhlist ) const;
81 
82  void handle( const Incident& inc ) override;
83 
84 private:
85  // typedef std::map<const CLID, std::map<const std::string, DataHistory*> >
86  // DataHistMap;
87 
89 
90  typedef std::multimap<DHH, DataHistory*> DataHistMap;
91  typedef DataHistMap::iterator DHMitr;
92  typedef DataHistMap::const_iterator DHMCitr;
93 
94  Gaudi::Property<bool> m_dump{ this, "Dump", false };
95  Gaudi::Property<bool> m_activate{ this, "Activate", true };
97  ServiceHandle<IAlgContextSvc> p_algCtxSvc{ this, "AlgContextSvc", "AlgContextSvc" };
98 
99  void clearState();
100 
101  bool m_isInitialized = false;
102 
103  std::map<const Gaudi::Algorithm*, AlgorithmHistory*> m_algmap;
104 
105  std::set<const IAlgTool*> m_ialgtools;
106  std::map<const AlgTool*, AlgToolHistory*> m_algtoolmap;
107  std::map<const IService*, ServiceHistory*> m_svcmap;
108 
109  std::multimap<DHH, DataHistory*> m_datMap;
110 
111  std::unique_ptr<JobHistory> m_jobHistory;
112 
113  void dumpProperties( std::ofstream& ) const;
114  void dumpProperties( const IService&, std::ofstream& ) const;
115  void dumpProperties( const Gaudi::Algorithm&, std::ofstream& ) const;
116  void dumpProperties( const IAlgTool&, std::ofstream& ) const;
117 
118  void dumpState( std::ofstream& ) const;
119  void dumpState( const INamedInterface*, std::ofstream& ) const;
120 
121  std::string dumpProp( const Gaudi::Details::PropertyBase*, const bool isXML = false, int indent = 0 ) const;
122 
123  IAlgorithm* getCurrentIAlg() const;
124 
126 
127  bool m_outputFileTypeXML = false;
128 };
HistorySvc
Definition: HistorySvc.h:46
IService
Definition: IService.h:26
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:34
HistorySvc::DHMitr
DataHistMap::iterator DHMitr
Definition: HistorySvc.h:91
HistorySvc::m_outputFileTypeXML
bool m_outputFileTypeXML
Definition: HistorySvc.h:127
HistorySvc::m_activate
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:95
HistorySvc::listProperties
StatusCode listProperties() const override
Definition: HistorySvc.cpp:344
HistorySvc::initialize
StatusCode initialize() override
Definition: HistorySvc.cpp:120
DHH
Definition: HistorySvc.cpp:69
IAlgTool
Definition: IAlgTool.h:29
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
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
HistorySvc::DHMCitr
DataHistMap::const_iterator DHMCitr
Definition: HistorySvc.h:92
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:109
HistorySvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:125
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:90
AlgToolHistory
Definition: AlgToolHistory.h:31
HistorySvc::m_algmap
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:103
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:96
HistorySvc::clearState
void clearState()
Definition: HistorySvc.cpp:109
HistorySvc::m_dump
Gaudi::Property< bool > m_dump
Definition: HistorySvc.h:94
HistorySvc::PropertyList
IVersHistoryObj::PropertyList PropertyList
Definition: HistorySvc.h:88
HistorySvc::m_isInitialized
bool m_isInitialized
Definition: HistorySvc.h:101
SmartIF.h
HistorySvc::getAlgHistory
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:327
HistoryObj
Definition: HistoryObj.h:30
AlgorithmHistory
Definition: AlgorithmHistory.h:37
StatusCode
Definition: StatusCode.h:64
IAlgorithm
Definition: IAlgorithm.h:36
IVersHistoryObj.h
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:111
ServiceHistory
Definition: ServiceHistory.h:30
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:87
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:107
HistorySvc::finalize
StatusCode finalize() override
Definition: HistorySvc.cpp:260
IVersHistoryObj::PropertyList
std::vector< Gaudi::Details::PropertyBase * > PropertyList
Definition: IVersHistoryObj.h:29
Algorithm.h
SmartIF< IToolSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:16
IHistorySvc.h
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:19
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:23
IIncidentListener.h
HistorySvc::registerAlg
StatusCode registerAlg(const Gaudi::Algorithm &) override
Definition: HistorySvc.cpp:279
JobHistory
Definition: JobHistory.h:32
DataHistory
Definition: DataHistory.h:32
IAlgContextSvc
Definition: IAlgContextSvc.h:25
HistorySvc::m_ialgtools
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:105
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:106
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:97
IIncidentSvc
Definition: IIncidentSvc.h:30
Incident
Definition: Incident.h:24
ProduceConsume.key
key
Definition: ProduceConsume.py:84
Gaudi::Property< bool >
MsgStream.h
HistorySvc::captureState
virtual StatusCode captureState()
Definition: HistorySvc.cpp:168