The Gaudi Framework  v33r0 (d5ea422b)
AlgorithmHistory.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
12 //
13 // GaudiHistory/AlgorithmHistory.cpp
14 //
15 // Contains history information for an Algorithm
16 //
17 //
18 // @author: Charles Leggett
19 //
21 
23 #include "GaudiKernel/JobHistory.h"
24 #include <Gaudi/Algorithm.h>
25 #include <assert.h>
26 #include <iostream>
27 
28 using std::endl;
29 using std::ostream;
30 using std::type_info;
31 using std::vector;
32 
33 //**********************************************************************
34 // Member functions.
35 //**********************************************************************
36 
37 // Constructor.
38 
40  : m_algorithm_type( System::typeinfoName( typeid( alg ) ) )
41  , m_algorithm_version( alg.version() )
42  , m_algorithm_name( alg.name() )
43  , m_algorithm( &alg )
44  , m_properties( alg.getProperties() )
45  , m_jobHistory( job ) {}
46 
47 //**********************************************************************
48 
49 AlgorithmHistory::AlgorithmHistory( const std::string& algVersion, const std::string& algName,
50  const std::string& algType, const PropertyList& props,
51  const HistoryList& subHists )
52  : m_algorithm_type( algType )
53  , // 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 
72 
73  static const CLID CLID_AlgorithmHistory = 56809101; // from `clid AlgorithmHistory`
74  return CLID_AlgorithmHistory;
75 }
76 
77 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
78 
79 void AlgorithmHistory::dump( std::ostream& ost, const bool isXML, int ind ) const {
80 
81  if ( !isXML ) {
82  ost << "Type: " << algorithm_type() << endl;
83  ost << "Name: " << algorithm_name() << endl;
84  ost << "Version: " << algorithm_version() << endl;
85  // Properties.
86  ost << "Properties: [" << endl;
87  ;
88  for ( const auto& iprop : properties() ) {
89  iprop->fillStream( ost );
90  ost << endl;
91  }
92  ost << "]" << endl;
93  } else {
94  ind += 2;
95  indent( ost, ind );
96  ost << "<COMPONENT name=\"" << algorithm_name() << "\" class=\"" << convert_string( algorithm_type() )
97  << "\" version=\"" << algorithm_version() << "\">" << std::endl;
98 
99  for ( const auto& iprop : properties() ) {
100  indent( ost, ind + 2 );
101  ost << "<PROPERTY name=\"" << iprop->name() << "\" value=\"" << convert_string( iprop->toString() )
102  << "\" documentation=\"" << convert_string( iprop->documentation() ) << "\">" << std::endl;
103  }
104 
105  indent( ost, ind );
106  ost << "</COMPONENT>" << std::endl;
107  }
108 }
109 
110 //**********************************************************************
111 // Free functions.
112 //**********************************************************************
113 
114 // Output stream.
115 
117  rhs.dump( lhs, false );
118  return lhs;
119 }
120 
121 //**********************************************************************
const std::string & algorithm_version() const
const std::string & algorithm_type() const
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:308
ostream & operator<<(ostream &lhs, const AlgorithmHistory &rhs)
AlgorithmHistory(const Gaudi::Algorithm &alg, const JobHistory *job)
AlgorithmHistory class definition.
Note: OS specific details for environment resolution.
Definition: Debugger.h:29
T endl(T... args)
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
void dump(std::ostream &, const bool isXML=false, int indent=0) const override
JobHistory class definition.
Definition: JobHistory.h:32
HistoryList m_subalgorithm_histories
STL class.
const std::string & algorithm_name() const
const PropertyList & properties() const override
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:56
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:30
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
virtual ~AlgorithmHistory()
STL class.