| The Gaudi Framework v32r1 (f65d50dc)

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