| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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/Property.h"
15 #include "GaudiKernel/System.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 using Gaudi::Details::PropertyBase;
26
27 //**********************************************************************
28 // Member functions.
29 //**********************************************************************
30
31 // Constructor.
32
33 JobHistory::JobHistory() : m_start_time( 0 )
34 {
35
36 time( &m_start_time );
37
38 std::string rel;
39
40 if ( ( rel = System::getEnv( "ATLAS_BASE_RELEASE" ) ) != "UNKNOWN" ) {
41 m_release_version = rel;
42 } else if ( ( rel = System::getEnv( "GAUDIROOT" ) ) != "UNKNOWN" ) {
43 m_release_version = rel;
44 } else {
45 m_release_version = "UNKNOWN";
46 }
47 m_dir = System::getEnv( "PWD" );
48 m_cmtconfig = System::getEnv( "CMTCONFIG" );
49
50 m_osname = System::osName();
51 m_hostname = System::hostName();
52 m_os_version = System::osVersion();
53 m_machine = System::machineType();
54
55 m_environ = System::getEnv();
56 }
57
58 JobHistory::JobHistory( const std::string& rel, const std::string& os, const std::string& host, const std::string& dir,
59 const std::string& osver, const std::string& mach, const std::string& cmtconfig,
60 const time_t& time )
61 : m_release_version( rel )
62 , m_dir( dir )
63 , m_cmtconfig( cmtconfig )
64 , m_osname( os )
65 , m_hostname( host )
66 , m_os_version( osver )
67 , m_machine( mach )
68 , m_start_time( time )
69 {
70 }
71
72 //**********************************************************************
73
74 // Destructor.
75
76 JobHistory::~JobHistory() = default;
77
78 const CLID& JobHistory::classID()
79 {
80
81 static const CLID CLID_JobHistory = 247994533;
82 return CLID_JobHistory;
83 }
84
85 void JobHistory::addProperty( const std::string& client, const PropertyBase* prop )
86 {
87 // if (m_props.find(prop) == m_props.end())
88 m_ppl.emplace_back( client, prop );
89 }
90
91 void JobHistory::dump( std::ostream& ost, const bool isXML, int /*ind*/ ) const
92 {
93
94 if ( !isXML ) {
95 ost << "Release: " << release_version() << endl;
96 ost << "OS: " << os() << endl;
97 ost << "OS ver: " << os_version() << endl;
98 ost << "Host: " << hostname() << endl;
99 ost << "Machine: " << machine() << endl;
100 ost << "Run dir: " << dir() << endl;
101 ost << "CMTCONFIG: " << cmtconfig() << endl;
102 ost << "Job start time: " << start_time() << endl << endl;
103 ost << "Properties: [" << endl;
104 ;
105 for ( const auto& ipprop : propertyPairs() ) {
106 const std::string& client = ipprop.first;
107 const PropertyBase* prop = ipprop.second;
108 ost << client << ": ";
109 prop->fillStream( ost );
110 ost << endl;
111 }
112 ost << "]" << endl;
113 for ( const auto& itr : environment() ) ost << itr << endl;
114 } else {
115 }
116 }
117
118 //**********************************************************************
119 // Free functions.
120 //**********************************************************************
121
122 // Output stream.
123
124 ostream& operator<<( ostream& lhs, const JobHistory& rhs )
125 {
126 rhs.dump( lhs, false );
127 return lhs;
128 }
129
130 //**********************************************************************
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:550
JobHistory::os_version
std::string os_version() const
Definition: JobHistory.h:66
System.h
JobHistory::m_ppl
PropertyPairList m_ppl
Definition: JobHistory.h:41
JobHistory::m_dir
std::string m_dir
Definition: JobHistory.h:30
JobHistory::os
std::string os() const
Definition: JobHistory.h:64
std::endl
T endl(T...args)
JobHistory::m_os_version
std::string m_os_version
Definition: JobHistory.h:35
plotSpeedupsPyRoot.time
time
Definition: plotSpeedupsPyRoot.py:146
Containers::vector
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
Definition: KeyedObjectManager.h:29
JobHistory::start_time
time_t start_time() const
Definition: JobHistory.h:73
JobHistory::m_osname
std::string m_osname
Definition: JobHistory.h:33
JobHistory::~JobHistory
virtual ~JobHistory()
JobHistory::m_hostname
std::string m_hostname
Definition: JobHistory.h:34
JobHistory
JobHistory class definition.
Definition: JobHistory.h:22
std::string
STL class.
JobHistory::m_environ
std::vector< std::string > m_environ
Definition: JobHistory.h:38
JobHistory::JobHistory
JobHistory()
Definition: JobHistory.cpp:33
JobHistory.h
JobHistory::m_start_time
time_t m_start_time
Definition: JobHistory.h:44
JobHistory::addProperty
void addProperty(const std::string &, const Gaudi::Details::PropertyBase *)
Definition: JobHistory.cpp:85
JobHistory::release_version
std::string release_version() const
Definition: JobHistory.h:63
JobHistory::m_cmtconfig
std::string m_cmtconfig
Definition: JobHistory.h:31
JobHistory::machine
std::string machine() const
Definition: JobHistory.h:67
System::osName
GAUDI_API const std::string & osName()
OS name.
Definition: System.cpp:377
JobHistory::environment
std::vector< std::string > environment() const
Definition: JobHistory.h:70
JobHistory::m_machine
std::string m_machine
Definition: JobHistory.h:36
JobHistory::cmtconfig
std::string cmtconfig() const
Definition: JobHistory.h:69
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
JobHistory::propertyPairs
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:72
JobHistory::dump
void dump(std::ostream &, const bool isXML=false, int indent=0) const override
Definition: JobHistory.cpp:91
JobHistory::m_release_version
std::string m_release_version
Definition: JobHistory.h:29
DataObject::operator<<
friend std::ostream & operator<<(std::ostream &s, const DataObject &obj)
Output operator (ASCII)
Definition: DataObject.h:99
System::hostName
GAUDI_API const std::string & hostName()
Host name.
Definition: System.cpp:371
Property.h
System::osVersion
GAUDI_API const std::string & osVersion()
OS version.
Definition: System.cpp:394
JobHistory::classID
static const CLID & classID()
Definition: JobHistory.cpp:78
System::machineType
GAUDI_API const std::string & machineType()
Machine type.
Definition: System.cpp:415
JobHistory::dir
std::string dir() const
Definition: JobHistory.h:68
std::ostream
STL class.
JobHistory::hostname
std::string hostname() const
Definition: JobHistory.h:65
std::vector::emplace_back
T emplace_back(T...args)