All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlgorithmHistory.cpp
Go to the documentation of this file.
1 //
3 // $Id: AlgorithmHistory.cpp,v 1.1 2006/11/09 10:24:05 mato Exp $
4 //
5 // GaudiHistory/AlgorithmHistory.cpp
6 //
7 // Contains history information for an Algorithm
8 //
9 //
10 // @author: Charles Leggett
11 //
13 
15 #include "GaudiKernel/JobHistory.h"
16 #include "GaudiKernel/Algorithm.h"
17 #include <iostream>
18 #include <assert.h>
19 
20 
21 using std::ostream;
22 using std::endl;
23 using std::type_info;
24 using std::vector;
25 
26 //**********************************************************************
27 // Member functions.
28 //**********************************************************************
29 
30 // Constructor.
31 
33 :
34  m_algorithm_type(System::typeinfoName(typeid(alg))),
35  m_algorithm_version(alg.version()),
36  m_algorithm_name(alg.name()),
37  m_algorithm( &alg ),
38  m_properties(alg.getProperties()),
39  m_jobHistory(job)
40 {
41  assert( alg.subAlgorithms() != 0 );
42 
43  for ( vector<Algorithm*>::const_iterator
44  ialg=alg.subAlgorithms()->begin();
45  ialg!=alg.subAlgorithms()->end(); ++ ialg ) {
46  m_subalgorithm_histories.push_back(new AlgorithmHistory(**ialg, job));
47  }
48 }
49 
50 //**********************************************************************
51 
52 AlgorithmHistory::AlgorithmHistory(const std::string& algVersion,
53  const std::string& algName,
54  const std::string& algType,
55  const PropertyList& props,
56  const HistoryList& subHists) :
57  m_algorithm_type(algType), // FIXME type_info???
58  m_algorithm_version(algVersion),
59  m_algorithm_name(algName),
60  m_algorithm(0),
61  m_properties(props),
62  m_subalgorithm_histories(subHists),
63  m_jobHistory(0) {}
64 
65 //**********************************************************************
66 
67 // Destructor.
68 
70  for ( HistoryList::const_iterator
71  iphist=m_subalgorithm_histories.begin();
72  iphist!=m_subalgorithm_histories.end(); ++iphist ) {
73  delete *iphist;
74  }
75 }
76 
77 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
78 
79 const CLID&
81 
82  static CLID CLID_AlgorithmHistory = 56809101; //from `clid AlgorithmHistory`
83  return CLID_AlgorithmHistory;
84 
85 }
86 
87 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
88 
89 void
90 AlgorithmHistory::dump(std::ostream& ost, const bool isXML, int ind) const {
91 
92  if (!isXML) {
93  ost << "Type: " << algorithm_type() << endl;
94  ost << "Name: " << algorithm_name() << endl;
95  ost << "Version: " << algorithm_version() << endl;
96  // Properties.
97  ost << "Properties: [" << endl;;
98  for ( AlgorithmHistory::PropertyList::const_iterator
99  ipprop=properties().begin();
100  ipprop!=properties().end(); ++ipprop ) {
101  const Property& prop = **ipprop;
102  prop.fillStream(ost);
103  ost << endl;
104  }
105  ost << "]" << endl;
106  // Subalgorithms.
107  if ( subalgorithm_histories().size() == 0 ) {
108  ost << "No subalgorithms.";
109  } else {
110  ost << "Subalgorithms: {" << endl;
111  for ( AlgorithmHistory::HistoryList::const_iterator
112  iphist=subalgorithm_histories().begin();
113  iphist!=subalgorithm_histories().end(); ++iphist ) {
114  if ( iphist==subalgorithm_histories().begin() ) {
115  ost << "----------" << endl;
116  }
117  ost << **iphist << endl;
118  ost << "----------" << endl;
119  }
120  ost << "}";
121  }
122  } else {
123  ind += 2;
124  indent(ost,ind);
125  ost << "<COMPONENT name=\"" << algorithm_name()
126  << "\" class=\"" << convert_string(algorithm_type())
127  << "\" version=\"" << algorithm_version()
128  << "\">" << std::endl;
129 
130  for ( AlgorithmHistory::PropertyList::const_iterator
131  ipprop=properties().begin();
132  ipprop!=properties().end(); ++ipprop ) {
133  const Property& prop = **ipprop;
134  indent(ost,ind+2);
135  ost << "<PROPERTY name=\"" << prop.name()
136  << "\" value=\"" << convert_string(prop.toString())
137  << "\" documentation=\"" << convert_string(prop.documentation())
138  << "\">" << std::endl;
139  }
140 
141  // Subalgs
142  if ( subalgorithm_histories().size() != 0 ) {
143  for ( AlgorithmHistory::HistoryList::const_iterator
144  iphist=subalgorithm_histories().begin();
145  iphist!=subalgorithm_histories().end(); ++iphist ) {
146  (*iphist)->dump(ost,isXML,ind+2);
147  }
148 
149  }
150 
151  indent(ost,ind);
152  ost << "</COMPONENT>" << std::endl;
153 
154 
155 
156 
157 
158  }
159 }
160 
161 
162 //**********************************************************************
163 // Free functions.
164 //**********************************************************************
165 
166 // Output stream.
167 
168 ostream& operator<<(ostream& lhs, const AlgorithmHistory& rhs) {
169 
170  rhs.dump(lhs,false);
171 
172  return lhs;
173 }
174 
175 //**********************************************************************
std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Definition: Algorithm.cpp:870
void dump(std::ostream &, const bool isXML=false, int indent=0) const
static const CLID & classID()
virtual std::string toString() const =0
value -> string
const std::string & name() const
property name
Definition: Property.h:47
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
ostream & operator<<(ostream &lhs, const AlgorithmHistory &rhs)
AlgorithmHistory class definition.
std::vector< const AlgorithmHistory * > HistoryList
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
std::vector< Property * > PropertyList
const std::string & documentation() const
property documentation
Definition: Property.h:49
JobHistory class definition.
Definition: JobHistory.h:25
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:182
HistoryList m_subalgorithm_histories
const std::string & algorithm_name() const
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:52
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
const PropertyList & properties() const
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:29
const std::string & algorithm_version() const
AlgorithmHistory(const Algorithm &alg, const JobHistory *job)
const std::string & algorithm_type() const
virtual ~AlgorithmHistory()
const HistoryList & subalgorithm_histories() const