The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
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\***********************************************************************************/
13#include <GaudiKernel/Service.h>
15#include <iostream>
16
17using namespace std;
19
20ServiceHistory::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 ) );
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 ) );
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
48std::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}
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
std::string documentation() const
property documentation
virtual std::string toString() const =0
value -> string
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition Property.cpp:45
const std::string name() const
property name
Define general base for Gaudi exception.
virtual void indent(std::ostream &, int) const
static std::string convert_string(const std::string &)
General service interface definition.
Definition IService.h:26
JobHistory class definition.
Definition JobHistory.h:32
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
std::string m_type
const std::string & type() const override
PropertyList m_properties
const PropertyList & properties() const override
const JobHistory * m_jobHistory
std::string m_name
const std::string & name() const override
std::string m_version
static const CLID & classID()
std::ostream & dump(std::ostream &, const bool isXML, int indent) const override
const IService * m_pService
const std::string & version() const override
Base class for all services.
Definition Service.h:39
constexpr static const auto FAILURE
Definition StatusCode.h:100
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260
STL namespace.