The Gaudi Framework  v33r1 (b1225454)
ServiceHistory.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/ServiceHistory.cpp
14 //
15 // Contains history information for a Service
16 //
17 //
18 // @author: Charles Leggett
19 //
21 
23 #include "GaudiKernel/IService.h"
24 #include "GaudiKernel/JobHistory.h"
25 #include "GaudiKernel/Service.h"
26 #include <iostream>
27 
28 using namespace std;
30 
31 //
33 //
34 
36  : // HistoryObj(),
37  m_pService( nullptr )
38  , m_name( "none" )
39  , m_type( "none" )
40  , m_version( "none" ) {}
41 
42 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
44  : // HistoryObj(),
45  m_pService( isv )
46  , m_jobHistory( job )
47  , m_name( isv->name() )
48  , m_version( "none" ) {
49 
50  const Service* svc = dynamic_cast<const Service*>( isv );
51  if ( !svc ) throw GaudiException( "Cannot dynamic cast to Service class", name(), StatusCode::FAILURE );
52  m_type = System::typeinfoName( typeid( *svc ) );
53  m_properties = svc->getProperties();
54 }
55 
56 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
57 
59  : // HistoryObj(),
60  m_pService( &isv )
61  , m_jobHistory( job )
62  , m_name( isv.name() )
63  , m_version( "none" ) {
64 
65  const Service* svc = dynamic_cast<const Service*>( &isv );
66  if ( svc ) {
67  m_type = System::typeinfoName( typeid( *svc ) );
68  m_properties = svc->getProperties();
69  } else {
70  throw GaudiException( "Cannot dynamic cast to Service class", name(), StatusCode::FAILURE );
71  }
72 }
73 
74 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
75 
77 
78  static const CLID CLID_ServiceHistory = 187225489; // from `clid ServiceHistory`
79  return CLID_ServiceHistory;
80 }
81 
82 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
83 
84 std::ostream& ServiceHistory::dump( std::ostream& ost, const bool isXML, int ind ) const {
85 
86  if ( !isXML ) {
87 
88  ost << "Name: " << name() << endl;
89  ost << "Type: " << type() << endl;
90  ost << "Version: " << version() << endl;
91 
92  // Properties
93  ost << "Properties: [" << endl;
94 
95  for ( const auto& ipprop : properties() ) {
96  const PropertyBase& prop = *ipprop;
97  prop.fillStream( ost );
98  ost << endl;
99  }
100  ost << "]" << endl;
101 
102  } else {
103 
104  ind += 2;
105  indent( ost, ind );
106  ost << "<COMPONENT name=\"" << name() << "\" class=\"" << convert_string( type() ) << "\" version=\""
107  << convert_string( version() ) << "\">" << endl;
108 
109  for ( const auto& ipprop : properties() ) {
110  const PropertyBase& prop = *ipprop;
111 
112  indent( ost, ind + 2 );
113  ost << "<PROPERTY name=\"" << prop.name() << "\" value=\"" << convert_string( prop.toString() )
114  << "\" documentation=\"" << convert_string( prop.documentation() ) << "\">" << endl;
115  }
116 
117  indent( ost, ind );
118  ost << "</COMPONENT>" << endl;
119  }
120  return ost;
121 }
Define general base for Gaudi exception.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
T endl(T... args)
STL namespace.
const std::string name() const
property name
Definition: Property.h:46
JobHistory class definition.
Definition: JobHistory.h:32
PropertyList m_properties
const std::string & type() const override
std::string m_type
General service interface definition.
Definition: IService.h:28
std::ostream & dump(std::ostream &, const bool isXML, int indent) const override
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:42
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:59
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:56
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:30
constexpr static const auto FAILURE
Definition: StatusCode.h:101
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
const std::string & name() const override
const std::string & version() const override
Base class for all services.
Definition: Service.h:46
STL class.
virtual std::string toString() const =0
value -> string
static const CLID & classID()
std::string documentation() const
property documentation
Definition: Property.h:48
const PropertyList & properties() const override