The Gaudi Framework  master (37c0b60a)
ServiceHistory.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 
22 #include <GaudiKernel/IService.h>
23 #include <GaudiKernel/JobHistory.h>
24 #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 }
IService
Definition: IService.h:28
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
ServiceHistory::classID
static const CLID & classID()
Definition: ServiceHistory.cpp:76
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:39
IService.h
ServiceHistory::m_properties
PropertyList m_properties
Definition: ServiceHistory.h:62
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: PropertyBase.h:41
GaudiException
Definition: GaudiException.h:31
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:315
ServiceHistory::ServiceHistory
ServiceHistory()
Definition: ServiceHistory.cpp:35
ServiceHistory.h
ServiceHistory::m_type
std::string m_type
Definition: ServiceHistory.h:61
Gaudi::Details::PropertyBase::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:60
std::ostream
STL class.
HistoryObj::indent
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:56
ServiceHistory::type
const std::string & type() const override
Definition: ServiceHistory.h:52
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:87
HistoryObj::convert_string
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:30
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
JobHistory.h
Service.h
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
std::endl
T endl(T... args)
ServiceHistory::dump
std::ostream & dump(std::ostream &, const bool isXML, int indent) const override
Definition: ServiceHistory.cpp:84
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
std
STL namespace.
ServiceHistory::name
const std::string & name() const override
Definition: ServiceHistory.h:51
JobHistory
Definition: JobHistory.h:33
ServiceHistory::version
const std::string & version() const override
Definition: ServiceHistory.h:53
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ServiceHistory::properties
const PropertyList & properties() const override
Definition: ServiceHistory.h:43