The Gaudi Framework  v29r0 (ff2e7097)
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/Algorithm.h"
14 #include "GaudiKernel/JobHistory.h"
15 #include <assert.h>
16 #include <iostream>
17 
18 using std::ostream;
19 using std::endl;
20 using std::type_info;
21 using std::vector;
22 
23 //**********************************************************************
24 // Member functions.
25 //**********************************************************************
26 
27 // Constructor.
28 
30  : m_algorithm_type( System::typeinfoName( typeid( alg ) ) )
31  , m_algorithm_version( alg.version() )
32  , m_algorithm_name( alg.name() )
33  , m_algorithm( &alg )
34  , m_properties( alg.getProperties() )
35  , m_jobHistory( job )
36 {
37  assert( alg.subAlgorithms() != 0 );
38 
39  for ( const auto& ialg : *alg.subAlgorithms() ) {
41  }
42 }
43 
44 //**********************************************************************
45 
46 AlgorithmHistory::AlgorithmHistory( const std::string& algVersion, const std::string& algName,
47  const std::string& algType, const PropertyList& props,
48  const HistoryList& subHists )
49  : m_algorithm_type( algType )
50  , // FIXME type_info???
51  m_algorithm_version( algVersion )
52  , m_algorithm_name( algName )
53  , m_algorithm( nullptr )
54  , m_properties( props )
55  , m_subalgorithm_histories( subHists )
56  , m_jobHistory( nullptr )
57 {
58 }
59 
60 //**********************************************************************
61 
62 // Destructor.
63 
65 {
66  for ( auto& i : m_subalgorithm_histories ) delete i;
67 }
68 
69 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
70 
72 {
73 
74  static const CLID CLID_AlgorithmHistory = 56809101; // from `clid AlgorithmHistory`
75  return CLID_AlgorithmHistory;
76 }
77 
78 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
79 
80 void AlgorithmHistory::dump( std::ostream& ost, const bool isXML, int ind ) const
81 {
82 
83  if ( !isXML ) {
84  ost << "Type: " << algorithm_type() << endl;
85  ost << "Name: " << algorithm_name() << endl;
86  ost << "Version: " << algorithm_version() << endl;
87  // Properties.
88  ost << "Properties: [" << endl;
89  ;
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(); iphist != subalgorithm_histories().end(); ++iphist ) {
101  if ( iphist == subalgorithm_histories().begin() ) {
102  ost << "----------" << endl;
103  }
104  ost << **iphist << endl;
105  ost << "----------" << endl;
106  }
107  ost << "}";
108  }
109  } else {
110  ind += 2;
111  indent( ost, ind );
112  ost << "<COMPONENT name=\"" << algorithm_name() << "\" class=\"" << convert_string( algorithm_type() )
113  << "\" version=\"" << algorithm_version() << "\">" << std::endl;
114 
115  for ( const auto& iprop : properties() ) {
116  indent( ost, ind + 2 );
117  ost << "<PROPERTY name=\"" << iprop->name() << "\" value=\"" << convert_string( iprop->toString() )
118  << "\" documentation=\"" << convert_string( iprop->documentation() ) << "\">" << std::endl;
119  }
120 
121  // Subalgs
122  for ( const auto& iphist : subalgorithm_histories() ) {
123  iphist->dump( ost, isXML, ind + 2 );
124  }
125 
126  indent( ost, ind );
127  ost << "</COMPONENT>" << std::endl;
128  }
129 }
130 
131 //**********************************************************************
132 // Free functions.
133 //**********************************************************************
134 
135 // Output stream.
136 
138 {
139  rhs.dump( lhs, false );
140  return lhs;
141 }
142 
143 //**********************************************************************
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:329
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:58
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:49
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:776
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:88
T begin(T...args)
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:20
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:139
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