Loading [MathJax]/jax/output/HTML-CSS/config.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ServiceHistory.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 \***********************************************************************************/
11 #include <GaudiKernel/IService.h>
12 #include <GaudiKernel/JobHistory.h>
13 #include <GaudiKernel/Service.h>
15 #include <iostream>
16 
17 using namespace std;
19 
20 ServiceHistory::ServiceHistory() : m_pService( nullptr ), m_name( "none" ), m_type( "none" ), m_version( "none" ) {}
21 
23  : m_pService( isv ), m_jobHistory( job ), m_name( isv->name() ), m_version( "none" ) {
24 
25  const Service* svc = dynamic_cast<const Service*>( isv );
26  if ( !svc ) throw GaudiException( "Cannot dynamic cast to Service class", name(), StatusCode::FAILURE );
27  m_type = System::typeinfoName( typeid( *svc ) );
28  m_properties = svc->getProperties();
29 }
30 
32  : m_pService( &isv ), m_jobHistory( job ), m_name( isv.name() ), m_version( "none" ) {
33 
34  const Service* svc = dynamic_cast<const Service*>( &isv );
35  if ( svc ) {
36  m_type = System::typeinfoName( typeid( *svc ) );
37  m_properties = svc->getProperties();
38  } else {
39  throw GaudiException( "Cannot dynamic cast to Service class", name(), StatusCode::FAILURE );
40  }
41 }
42 
44  static const CLID CLID_ServiceHistory = 187225489; // from `clid ServiceHistory`
45  return CLID_ServiceHistory;
46 }
47 
48 std::ostream& ServiceHistory::dump( std::ostream& ost, const bool isXML, int ind ) const {
49 
50  if ( !isXML ) {
51 
52  ost << "Name: " << name() << endl;
53  ost << "Type: " << type() << endl;
54  ost << "Version: " << version() << endl;
55 
56  // Properties
57  ost << "Properties: [" << endl;
58 
59  for ( const auto& ipprop : properties() ) {
60  const PropertyBase& prop = *ipprop;
61  prop.fillStream( ost );
62  ost << endl;
63  }
64  ost << "]" << endl;
65 
66  } else {
67 
68  ind += 2;
69  indent( ost, ind );
70  ost << "<COMPONENT name=\"" << name() << "\" class=\"" << convert_string( type() ) << "\" version=\""
71  << convert_string( version() ) << "\">" << endl;
72 
73  for ( const auto& ipprop : properties() ) {
74  const PropertyBase& prop = *ipprop;
75 
76  indent( ost, ind + 2 );
77  ost << "<PROPERTY name=\"" << prop.name() << "\" value=\"" << convert_string( prop.toString() )
78  << "\" documentation=\"" << convert_string( prop.documentation() ) << "\">" << endl;
79  }
80 
81  indent( ost, ind );
82  ost << "</COMPONENT>" << endl;
83  }
84  return ost;
85 }
IService
Definition: IService.h:26
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:34
ServiceHistory::classID
static const CLID & classID()
Definition: ServiceHistory.cpp:43
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:38
IService.h
ServiceHistory::m_properties
PropertyList m_properties
Definition: ServiceHistory.h:61
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: PropertyBase.h:40
GaudiException
Definition: GaudiException.h:29
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:260
ServiceHistory::ServiceHistory
ServiceHistory()
Definition: ServiceHistory.cpp:20
ServiceHistory.h
ServiceHistory::m_type
std::string m_type
Definition: ServiceHistory.h:60
Gaudi::Details::PropertyBase::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:45
HistoryObj::indent
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:37
ServiceHistory::type
const std::string & type() const override
Definition: ServiceHistory.h:51
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:87
HistoryObj::convert_string
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:14
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:16
JobHistory.h
Service.h
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
ServiceHistory::dump
std::ostream & dump(std::ostream &, const bool isXML, int indent) const override
Definition: ServiceHistory.cpp:48
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
ServiceHistory::name
const std::string & name() const override
Definition: ServiceHistory.h:50
JobHistory
Definition: JobHistory.h:32
ServiceHistory::version
const std::string & version() const override
Definition: ServiceHistory.h:52
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
ServiceHistory::properties
const PropertyList & properties() const override
Definition: ServiceHistory.h:42