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