| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
34 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
35 ServiceHistory::ServiceHistory( const IService* isv, const JobHistory* job )
36 : // HistoryObj(),
37 m_pService( isv )
38 , m_jobHistory( job )
39 , m_name( isv->name() )
40 , m_version( "none" )
41 {
42
43 const Service* svc = dynamic_cast<const Service*>( isv );
44 m_type = System::typeinfoName( typeid( *svc ) );
45 m_properties = svc->getProperties();
46 }
47
48 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49
50 ServiceHistory::ServiceHistory( const IService& isv, const JobHistory* job )
51 : // HistoryObj(),
52 m_pService( &isv )
53 , m_jobHistory( job )
54 , m_name( isv.name() )
55 , m_version( "none" )
56 {
57
58 const Service* svc = dynamic_cast<const Service*>( &isv );
59 m_type = System::typeinfoName( typeid( *svc ) );
60 m_properties = svc->getProperties();
61 }
62
63 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
64
65 const CLID& ServiceHistory::classID()
66 {
67
68 static const CLID CLID_ServiceHistory = 187225489; // from `clid ServiceHistory`
69 return CLID_ServiceHistory;
70 }
71
72 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
73
74 void ServiceHistory::dump( std::ostream& ost, const bool isXML, int ind ) const
75 {
76
77 if ( !isXML ) {
78
79 ost << "Name: " << name() << endl;
80 ost << "Type: " << type() << endl;
81 ost << "Version: " << version() << endl;
82
83 // Properties
84 ost << "Properties: [" << endl;
85
86 for ( const auto& ipprop : properties() ) {
87 const PropertyBase& prop = *ipprop;
88 prop.fillStream( ost );
89 ost << endl;
90 }
91 ost << "]" << endl;
92
93 } else {
94
95 ind += 2;
96 indent( ost, ind );
97 ost << "<COMPONENT name=\"" << name() << "\" class=\"" << convert_string( type() ) << "\" version=\""
98 << convert_string( version() ) << "\">" << endl;
99
100 for ( const auto& ipprop : properties() ) {
101 const PropertyBase& prop = *ipprop;
102
103 indent( ost, ind + 2 );
104 ost << "<PROPERTY name=\"" << prop.name() << "\" value=\"" << convert_string( prop.toString() )
105 << "\" documentation=\"" << convert_string( prop.documentation() ) << "\">" << endl;
106 }
107
108 indent( ost, ind );
109 ost << "</COMPONENT>" << endl;
110 }
111 }
112
113 //**********************************************************************
114 // Free functions.
115 //**********************************************************************
116
117 // Output stream.
118
119 ostream& operator<<( ostream& lhs, const ServiceHistory& rhs )
120 {
121
122 rhs.dump( lhs, false );
123
124 return lhs;
125 }
PropertyHolder::getProperties
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
Definition: PropertyHolder.h:331
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
std::endl
T endl(T...args)
std
STL namespace.
ServiceHistory::m_name
std::string m_name
Definition: ServiceHistory.h:51
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
JobHistory
JobHistory class definition.
Definition: JobHistory.h:22
ServiceHistory::m_properties
PropertyList m_properties
Definition: ServiceHistory.h:52
ServiceHistory::ServiceHistory
ServiceHistory()
Definition: ServiceHistory.cpp:25
Service.h
ServiceHistory::dump
void dump(std::ostream &, const bool isXML=false, int indent=0) const override
Definition: ServiceHistory.cpp:74
JobHistory.h
ServiceHistory::m_type
std::string m_type
Definition: ServiceHistory.h:51
IService
General service interface definition.
Definition: IService.h:18
ServiceHistory::properties
const PropertyList & properties() const override
Definition: ServiceHistory.h:36
ServiceHistory::name
const std::string & name() const override
Definition: ServiceHistory.h:44
HistoryObj::indent
virtual void indent(std::ostream &, int) const
Definition: HistoryObj.cpp:43
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
Gaudi::Details::PropertyBase::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:52
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
IService.h
ServiceHistory::version
const std::string & version() const override
Definition: ServiceHistory.h:46
DataObject::operator<<
friend std::ostream & operator<<(std::ostream &s, const DataObject &obj)
Output operator (ASCII)
Definition: DataObject.h:99
ServiceHistory::m_jobHistory
const JobHistory * m_jobHistory
Definition: ServiceHistory.h:50
HistoryObj::convert_string
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:21
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: Property.h:42
ServiceHistory::m_version
std::string m_version
Definition: ServiceHistory.h:51
ServiceHistory
ServiceHistory class definition.
Definition: ServiceHistory.h:21
Service
Base class for all services.
Definition: Service.h:36
ServiceHistory.h
ServiceHistory::m_pService
const IService * m_pService
Definition: ServiceHistory.h:49
std::ostream
STL class.
ServiceHistory::classID
static const CLID & classID()
Definition: ServiceHistory.cpp:65
ServiceHistory::type
const std::string & type() const override
Definition: ServiceHistory.h:45