| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AlgorithmHistory.cpp
Go to the documentation of this file.
1 //
3 // GaudiHistory/AlgorithmHistory.cpp
4 //
5 // Contains history information for an Algorithm
6 //
7 //
8 // @author: Charles Leggett
9 //
11
12 #include "GaudiKernel/AlgorithmHistory.h"
13 #include "GaudiKernel/JobHistory.h"
14 #include "GaudiKernel/Algorithm.h"
15 #include <iostream>
16 #include <assert.h>
17
18
19 using std::ostream;
20 using std::endl;
21 using std::type_info;
22 using std::vector;
23
24 //**********************************************************************
25 // Member functions.
26 //**********************************************************************
27
28 // Constructor.
29
30 AlgorithmHistory::AlgorithmHistory(const Algorithm& alg, const JobHistory* job)
31 :
32 m_algorithm_type(System::typeinfoName(typeid(alg))),
33 m_algorithm_version(alg.version()),
34 m_algorithm_name(alg.name()),
35 m_algorithm( &alg ),
36 m_properties(alg.getProperties()),
37 m_jobHistory(job)
38 {
39 assert( alg.subAlgorithms() != 0 );
40
41 for ( const auto& ialg : *alg.subAlgorithms() ) {
42 m_subalgorithm_histories.push_back(new AlgorithmHistory(*ialg, job));
43 }
44 }
45
46 //**********************************************************************
47
48 AlgorithmHistory::AlgorithmHistory(const std::string& algVersion,
49 const std::string& algName,
50 const std::string& algType,
51 const PropertyList& props,
52 const HistoryList& subHists) :
53 m_algorithm_type(algType), // FIXME type_info???
54 m_algorithm_version(algVersion),
55 m_algorithm_name(algName),
56 m_algorithm(nullptr),
57 m_properties(props),
58 m_subalgorithm_histories(subHists),
59 m_jobHistory(nullptr) {}
60
61 //**********************************************************************
62
63 // Destructor.
64
65 AlgorithmHistory::~AlgorithmHistory() {
66 for ( auto &i : m_subalgorithm_histories ) delete i;
67 }
68
69 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
70
71 const CLID&
72 AlgorithmHistory::classID() {
73
74 static const CLID CLID_AlgorithmHistory = 56809101; //from `clid AlgorithmHistory`
75 return CLID_AlgorithmHistory;
76
77 }
78
79 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
80
81 void
82 AlgorithmHistory::dump(std::ostream& ost, const bool isXML, int ind) const {
83
84 if (!isXML) {
85 ost << "Type: " << algorithm_type() << endl;
86 ost << "Name: " << algorithm_name() << endl;
87 ost << "Version: " << algorithm_version() << endl;
88 // Properties.
89 ost << "Properties: [" << endl;;
90 for ( const auto& iprop : properties() ) {
91 iprop->fillStream(ost);
92 ost << endl;
93 }
94 ost << "]" << endl;
95 // Subalgorithms.
96 if ( subalgorithm_histories().size() == 0 ) {
97 ost << "No subalgorithms.";
98 } else {
99 ost << "Subalgorithms: {" << endl;
100 for ( auto iphist=subalgorithm_histories().begin();
101 iphist!=subalgorithm_histories().end(); ++iphist ) {
102 if ( iphist==subalgorithm_histories().begin() ) {
103 ost << "----------" << endl;
104 }
105 ost << **iphist << endl;
106 ost << "----------" << endl;
107 }
108 ost << "}";
109 }
110 } else {
111 ind += 2;
112 indent(ost,ind);
113 ost << "<COMPONENT name=\"" << algorithm_name()
114 << "\" class=\"" << convert_string(algorithm_type())
115 << "\" version=\"" << algorithm_version()
116 << "\">" << std::endl;
117
118 for ( const auto& iprop : properties() ) {
119 indent(ost,ind+2);
120 ost << "<PROPERTY name=\"" << iprop->name()
121 << "\" value=\"" << convert_string(iprop->toString())
122 << "\" documentation=\"" << convert_string(iprop->documentation())
123 << "\">" << std::endl;
124 }
125
126 // Subalgs
127 for ( const auto& iphist : subalgorithm_histories() ) {
128 iphist->dump(ost,isXML,ind+2);
129 }
130
131 indent(ost,ind);
132 ost << "</COMPONENT>" << std::endl;
133
134 }
135 }
136
137
138 //**********************************************************************
139 // Free functions.
140 //**********************************************************************
141
142 // Output stream.
143
144 ostream& operator<<(ostream& lhs, const AlgorithmHistory& rhs) {
145 rhs.dump(lhs,false);
146 return lhs;
147 }
148
149 //**********************************************************************
Algorithm.h
AlgorithmHistory::dump
void dump(std::ostream &, const bool isXML=false, int indent=0) const
Definition: AlgorithmHistory.cpp:82
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
AlgorithmHistory::classID
static const CLID & classID()
Definition: AlgorithmHistory.cpp:72
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
operator<<
ostream & operator<<(ostream &lhs, const AlgorithmHistory &rhs)
Definition: AlgorithmHistory.cpp:144
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:27
System
Note: OS specific details for environment resolution.
Definition: Debugger.h:19
std::endl
T endl(T...args)
Containers::vector
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
Definition: KeyedObjectManager.h:29
std::vector::end
T end(T...args)
JobHistory
JobHistory class definition.
Definition: JobHistory.h:24
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
AlgorithmHistory::m_subalgorithm_histories
HistoryList m_subalgorithm_histories
Definition: AlgorithmHistory.h:52
std::type_info
std::string
STL class.
std::vector::push_back
T push_back(T...args)
JobHistory.h
AlgorithmHistory::algorithm_name
const std::string & algorithm_name() const
Definition: AlgorithmHistory.h:82
HistoryObj::indent
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:43
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
AlgorithmHistory::properties
const PropertyList & properties() const
Definition: AlgorithmHistory.h:88
Algorithm::subAlgorithms
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Definition: Algorithm.cpp:865
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
std::vector< Property * >
std::vector::begin
T begin(T...args)
HistoryObj::convert_string
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:21
AlgorithmHistory::algorithm_version
const std::string & algorithm_version() const
Definition: AlgorithmHistory.h:79
AlgorithmHistory::AlgorithmHistory
AlgorithmHistory(const Algorithm &alg, const JobHistory *job)
Definition: AlgorithmHistory.cpp:30
AlgorithmHistory::algorithm_type
const std::string & algorithm_type() const
Definition: AlgorithmHistory.h:76
AlgorithmHistory::~AlgorithmHistory
virtual ~AlgorithmHistory()
Definition: AlgorithmHistory.cpp:65
ana.i
list i
Definition: ana.py:128
std::ostream
STL class.
AlgorithmHistory::subalgorithm_histories
const HistoryList & subalgorithm_histories() const
Definition: AlgorithmHistory.h:91
AlgorithmHistory.h