All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
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 
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 ),
37  m_jobHistory(job)
38 {
39  assert( alg.subAlgorithms() != 0 );
40 
41  for ( const auto& ialg : *alg.subAlgorithms() ) {
43  }
44 }
45 
46 //**********************************************************************
47 
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 
66  for ( auto &i : m_subalgorithm_histories ) delete i;
67 }
68 
69 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
70 
71 const CLID&
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 
145  rhs.dump(lhs,false);
146  return lhs;
147 }
148 
149 //**********************************************************************
static const CLID & classID()
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
AlgorithmHistory class definition.
Note: OS specific details for environment resolution.
Definition: Debugger.h:19
T endl(T...args)
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
std::string m_algorithm_type
T end(T...args)
std::string m_algorithm_version
const PropertyList & properties() const override
JobHistory class definition.
Definition: JobHistory.h:22
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:47
HistoryList m_subalgorithm_histories
STL class.
T push_back(T...args)
const std::string & algorithm_name() const
PropertyList m_properties
const Algorithm * m_algorithm
void dump(std::ostream &, const bool isXML=false, int indent=0) const override
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:43
std::string m_algorithm_name
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Definition: Algorithm.cpp:801
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
friend std::ostream & operator<<(std::ostream &s, const DataObject &obj)
Output operator (ASCII)
Definition: DataObject.h:99
T begin(T...args)
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:21
const std::string & algorithm_version() const
AlgorithmHistory(const Algorithm &alg, const JobHistory *job)
const std::string & algorithm_type() const
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:159
virtual ~AlgorithmHistory()
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
STL class.
const HistoryList & subalgorithm_histories() const
const JobHistory * m_jobHistory