The Gaudi Framework  master (1304469f)
Loading...
Searching...
No Matches
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>
22
23#include <GaudiKernel/ClassID.h>
25#include <fstream>
26#include <map>
27#include <set>
28#include <string>
29#include <vector>
30
31class StoreGateSvc;
32class IAlgContextSvc;
33class IIncidentSvc;
34class HistoryObj;
35class DataHistory;
37class ServiceHistory;
38struct DHH;
39
45
46class HistorySvc : public extends<Service, IHistorySvc, IIncidentListener> {
47public:
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
84private:
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
128};
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
AlgToolHistory class definition.
AlgorithmHistory class definition.
DataHistory class definition.
Definition DataHistory.h:32
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:87
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Base class for History Objects.
Definition HistoryObj.h:30
HistorySvc class definition.
Definition HistorySvc.h:46
DataHistMap::iterator DHMitr
Definition HistorySvc.h:91
Gaudi::Property< bool > m_activate
Definition HistorySvc.h:95
std::multimap< DHH, DataHistory * > DataHistMap
Definition HistorySvc.h:90
virtual StatusCode registerDataHistory(const CLID &id, const std::string &key, const std::string &store)
StatusCode listProperties() const override
StatusCode registerAlgTool(const IAlgTool &) override
Gaudi::Property< std::string > m_outputFile
Definition HistorySvc.h:96
ServiceHandle< IAlgContextSvc > p_algCtxSvc
Definition HistorySvc.h:97
bool m_isInitialized
Definition HistorySvc.h:101
virtual StatusCode captureState()
void dumpState(std::ofstream &) const
void clearState()
StatusCode registerJob() override
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition HistorySvc.h:103
IVersHistoryObj::PropertyList PropertyList
Definition HistorySvc.h:88
Gaudi::Property< bool > m_dump
Definition HistorySvc.h:94
std::set< const IAlgTool * > m_ialgtools
Definition HistorySvc.h:105
StatusCode initialize() override
DataHistMap::const_iterator DHMCitr
Definition HistorySvc.h:92
DataHistory * getDataHistory(const CLID &id, const std::string &key, const std::string &store) const override
IAlgorithm * getCurrentIAlg() const
StatusCode registerSvc(const IService &) override
std::multimap< DHH, DataHistory * > m_datMap
Definition HistorySvc.h:109
ServiceHistory * getServiceHistory(const IService &) const override
JobHistory * getJobHistory() const override
StatusCode registerAlg(const Gaudi::Algorithm &) override
std::unique_ptr< JobHistory > m_jobHistory
Definition HistorySvc.h:111
std::map< const IService *, ServiceHistory * > m_svcmap
Definition HistorySvc.h:107
DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store) override
StatusCode stop() override
StatusCode reinitialize() override
void dumpProperties(std::ofstream &) const
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition HistorySvc.h:106
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
bool m_outputFileTypeXML
Definition HistorySvc.h:127
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
StatusCode finalize() override
SmartIF< IToolSvc > m_toolSvc
Definition HistorySvc.h:125
void handle(const Incident &inc) override
An abstract interface for Algorithm Context Service.
The interface implemented by the AlgTool base class.
Definition IAlgTool.h:29
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:36
The interface implemented by the IncidentSvc service.
IInterface compliant class extending IInterface with the name() method.
General service interface definition.
Definition IService.h:26
std::vector< Gaudi::Details::PropertyBase * > PropertyList
Base class for all Incidents (computing events).
Definition Incident.h:24
JobHistory class definition.
Definition JobHistory.h:32
Handle to be used in lieu of naked pointers to services.
ServiceHistory class definition.
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19