| The Gaudi Framework v29r1 (5cd95fa2)

- 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/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
29 AlgorithmHistory::AlgorithmHistory( const Algorithm& alg, const JobHistory* job )
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() ) {
40 m_subalgorithm_histories.push_back( new AlgorithmHistory( *ialg, job ) );
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
64 AlgorithmHistory::~AlgorithmHistory()
65 {
66 for ( auto& i : m_subalgorithm_histories ) delete i;
67 }
68
69 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
70
71 const CLID& AlgorithmHistory::classID()
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
137 ostream& operator<<( ostream& lhs, const AlgorithmHistory& rhs )
138 {
139 rhs.dump( lhs, false );
140 return lhs;
141 }
142
143 //**********************************************************************
Algorithm.h
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
AlgorithmHistory::classID
static const CLID & classID()
Definition: AlgorithmHistory.cpp:71
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:26
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:30
AlgorithmHistory::m_algorithm_type
std::string m_algorithm_type
Definition: AlgorithmHistory.h:35
std::vector::end
T end(T...args)
AlgorithmHistory::m_algorithm_version
std::string m_algorithm_version
Definition: AlgorithmHistory.h:38
AlgorithmHistory::properties
const PropertyList & properties() const override
Definition: AlgorithmHistory.h:82
JobHistory
JobHistory class definition.
Definition: JobHistory.h:22
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
AlgorithmHistory::m_subalgorithm_histories
HistoryList m_subalgorithm_histories
Definition: AlgorithmHistory.h:50
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:76
AlgorithmHistory::m_properties
PropertyList m_properties
Definition: AlgorithmHistory.h:47
AlgorithmHistory::m_algorithm
const Algorithm * m_algorithm
Definition: AlgorithmHistory.h:44
AlgorithmHistory::dump
void dump(std::ostream &, const bool isXML=false, int indent=0) const override
Definition: AlgorithmHistory.cpp:80
HistoryObj::indent
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:49
AlgorithmHistory::m_algorithm_name
std::string m_algorithm_name
Definition: AlgorithmHistory.h:41
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Algorithm::subAlgorithms
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Definition: Algorithm.cpp:776
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
DataObject::operator<<
friend std::ostream & operator<<(std::ostream &s, const DataObject &obj)
Output operator (ASCII)
Definition: DataObject.h:88
std::vector< Gaudi::Details::PropertyBase * >
std::vector::begin
T begin(T...args)
HistoryObj::convert_string
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:20
AlgorithmHistory::algorithm_version
const std::string & algorithm_version() const
Definition: AlgorithmHistory.h:73
AlgorithmHistory::AlgorithmHistory
AlgorithmHistory(const Algorithm &alg, const JobHistory *job)
Definition: AlgorithmHistory.cpp:29
AlgorithmHistory::algorithm_type
const std::string & algorithm_type() const
Definition: AlgorithmHistory.h:70
m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:139
AlgorithmHistory::~AlgorithmHistory
virtual ~AlgorithmHistory()
Definition: AlgorithmHistory.cpp:64
getProperties
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
std::ostream
STL class.
AlgorithmHistory::subalgorithm_histories
const HistoryList & subalgorithm_histories() const
Definition: AlgorithmHistory.h:85
AlgorithmHistory.h
AlgorithmHistory::m_jobHistory
const JobHistory * m_jobHistory
Definition: AlgorithmHistory.h:53