| The Gaudi Framework v27r1

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

- File List
- File Members

JobHistory.cpp
Go to the documentation of this file.
1 //
3 // GaudiHistory/JobHistory.cpp
4 //
5 // Contains history information for a job. Imports all environment vars
6 // and info from uname
7 //
8 //
9 // @author: Charles Leggett
10 //
12
13 #include "GaudiKernel/JobHistory.h"
14 #include "GaudiKernel/System.h"
15 #include "GaudiKernel/Property.h"
16
17 #include <cstdlib>
18 #include <iostream>
19
20 using std::string;
21 using std::ostream;
22 using std::endl;
23 using std::vector;
24
25 //**********************************************************************
26 // Member functions.
27 //**********************************************************************
28
29 // Constructor.
30
31 JobHistory::JobHistory()
32 : m_start_time(0) {
33
34 time(&m_start_time);
35
36 std::string rel;
37
38 if ( (rel = System::getEnv("ATLAS_BASE_RELEASE")) != "UNKNOWN" ) {
39 m_release_version = rel;
40 } else if ( (rel = System::getEnv("GAUDIROOT")) != "UNKNOWN" ) {
41 m_release_version = rel;
42 } else {
43 m_release_version = "UNKNOWN";
44 }
45 m_dir = System::getEnv("PWD");
46 m_cmtconfig = System::getEnv("CMTCONFIG");
47
48 m_osname = System::osName();
49 m_hostname = System::hostName();
50 m_os_version = System::osVersion();
51 m_machine = System::machineType();
52
53 m_environ = System::getEnv();
54
55 }
56
57 JobHistory::JobHistory(const std::string& rel, const std::string& os,
58 const std::string& host, const std::string& dir,
59 const std::string& osver, const std::string& mach,
60 const std::string& cmtconfig,
61 const time_t& time):
62 m_release_version(rel), m_dir(dir), m_cmtconfig(cmtconfig), m_osname(os),
63 m_hostname(host),
64 m_os_version(osver), m_machine(mach), m_start_time(time) {
65
66 }
67
68
69 //**********************************************************************
70
71 // Destructor.
72
73 JobHistory::~JobHistory() = default;
74
75 const CLID&
76 JobHistory::classID() {
77
78 static const CLID CLID_JobHistory = 247994533;
79 return CLID_JobHistory;
80
81 }
82
83 void
84 JobHistory::addProperty(const std::string& client, const Property* prop) {
85 // if (m_props.find(prop) == m_props.end())
86 m_ppl.emplace_back( client,prop );
87 }
88
89
90 void
91 JobHistory::dump(std::ostream& ost, const bool isXML, int /*ind*/) const {
92
93 if (!isXML) {
94 ost << "Release: " << release_version() << endl;
95 ost << "OS: " << os() << endl;
96 ost << "OS ver: " << os_version() << endl;
97 ost << "Host: " << hostname() << endl;
98 ost << "Machine: " << machine() << endl;
99 ost << "Run dir: " << dir() << endl;
100 ost << "CMTCONFIG: " << cmtconfig() << endl;
101 ost << "Job start time: " << start_time() << endl << endl;
102 ost << "Properties: [" << endl;;
103 for ( const auto& ipprop : propertyPairs() ) {
104 const std::string& client = ipprop.first;
105 const Property* prop = ipprop.second;
106 ost << client << ": ";
107 prop->fillStream(ost);
108 ost << endl;
109 }
110 ost << "]" << endl;
111 for (const auto& itr : environment() ) ost << itr << endl;
112 } else {
113
114 }
115
116 }
117
118 //**********************************************************************
119 // Free functions.
120 //**********************************************************************
121
122 // Output stream.
123
124 ostream& operator<<(ostream& lhs, const JobHistory& rhs) {
125 rhs.dump(lhs,false);
126 return lhs;
127 }
128
129 //**********************************************************************
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:617
JobHistory::os_version
std::string os_version() const
Definition: JobHistory.h:73
System.h
JobHistory::m_ppl
PropertyPairList m_ppl
Definition: JobHistory.h:44
JobHistory::m_dir
std::string m_dir
Definition: JobHistory.h:33
plotSpeedupsPyRoot.time
tuple time
Definition: plotSpeedupsPyRoot.py:146
JobHistory::os
std::string os() const
Definition: JobHistory.h:71
std::endl
T endl(T...args)
JobHistory::m_os_version
std::string m_os_version
Definition: JobHistory.h:38
Containers::vector
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
Definition: KeyedObjectManager.h:29
JobHistory::dump
void dump(std::ostream &, const bool isXML=false, int indent=0) const
Definition: JobHistory.cpp:91
JobHistory::start_time
time_t start_time() const
Definition: JobHistory.h:80
JobHistory::m_osname
std::string m_osname
Definition: JobHistory.h:36
JobHistory::~JobHistory
virtual ~JobHistory()
JobHistory::m_hostname
std::string m_hostname
Definition: JobHistory.h:37
JobHistory
JobHistory class definition.
Definition: JobHistory.h:24
Property::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:111
std::string
STL class.
JobHistory::m_environ
std::vector< std::string > m_environ
Definition: JobHistory.h:41
JobHistory::JobHistory
JobHistory()
Definition: JobHistory.cpp:31
JobHistory.h
JobHistory::m_start_time
time_t m_start_time
Definition: JobHistory.h:47
JobHistory::release_version
std::string release_version() const
Definition: JobHistory.h:70
operator<<
ostream & operator<<(ostream &lhs, const JobHistory &rhs)
Definition: JobHistory.cpp:124
JobHistory::m_cmtconfig
std::string m_cmtconfig
Definition: JobHistory.h:34
JobHistory::machine
std::string machine() const
Definition: JobHistory.h:74
System::osName
GAUDI_API const std::string & osName()
OS name.
Definition: System.cpp:444
JobHistory::environment
std::vector< std::string > environment() const
Definition: JobHistory.h:77
JobHistory::m_machine
std::string m_machine
Definition: JobHistory.h:39
JobHistory::cmtconfig
std::string cmtconfig() const
Definition: JobHistory.h:76
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
JobHistory::addProperty
void addProperty(const std::string &, const Property *)
Definition: JobHistory.cpp:84
JobHistory::propertyPairs
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:79
JobHistory::m_release_version
std::string m_release_version
Definition: JobHistory.h:32
System::hostName
GAUDI_API const std::string & hostName()
Host name.
Definition: System.cpp:438
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
Property.h
System::osVersion
GAUDI_API const std::string & osVersion()
OS version.
Definition: System.cpp:461
JobHistory::classID
static const CLID & classID()
Definition: JobHistory.cpp:76
System::machineType
GAUDI_API const std::string & machineType()
Machine type.
Definition: System.cpp:482
JobHistory::dir
std::string dir() const
Definition: JobHistory.h:75
std::ostream
STL class.
JobHistory::hostname
std::string hostname() const
Definition: JobHistory.h:72
std::vector::emplace_back
T emplace_back(T...args)