| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

# JobHistory.cpp

Go to the documentation of this file.

    00001
    00002 //
    00003 // $Id: JobHistory.cpp,v 1.1 2006/11/09 10:24:05 mato Exp $
    00004 //
    00005 // GaudiHistory/JobHistory.cpp
    00006 //
    00007 // Contains history information for a job. Imports all environment vars
    00008 // and info from uname
    00009 //
    00010 //
    00011 // @author: Charles Leggett
    00012 //
    00014
    00015 #include "GaudiKernel/JobHistory.h"
    00016 #include "GaudiKernel/System.h"
    00017 #include "GaudiKernel/Property.h"
    00018
    00019 #include <cstdlib>
    00020 #include <iostream>
    00021
    00022 using std::string;
    00023 using std::ostream;
    00024 using std::endl;
    00025 using std::vector;
    00026
    00027 //**********************************************************************
    00028 // Member functions.
    00029 //**********************************************************************
    00030
    00031 // Constructor.
    00032
    00033 JobHistory::JobHistory()
    00034 : m_start_time(0) {
    00035
    00036   time(&m_start_time);
    00037
    00038   std::string rel;
    00039
    00040   if  ( (rel = System::getEnv("ATLAS_BASE_RELEASE")) != "UNKNOWN" ) {
    00041     m_release_version = rel;
    00042   } else if ( (rel = System::getEnv("GAUDIROOT")) != "UNKNOWN" ) {
    00043     m_release_version = rel;
    00044   } else {
    00045     m_release_version = "UNKNOWN";
    00046   }
    00047   m_dir = System::getEnv("PWD");
    00048   m_cmtconfig = System::getEnv("CMTCONFIG");
    00049
    00050   m_osname = System::osName();
    00051   m_hostname = System::hostName();
    00052   m_os_version = System::osVersion();
    00053   m_machine = System::machineType();
    00054
    00055   m_environ = System::getEnv();
    00056
    00057 }
    00058
    00059 JobHistory::JobHistory(const std::string& rel, const std::string& os,
    00060                        const std::string& host, const std::string& dir,
    00061                        const std::string& osver, const std::string& mach,
    00062                        const std::string& cmtconfig,
    00063                        const time_t& time):
    00064   m_release_version(rel), m_dir(dir), m_cmtconfig(cmtconfig), m_osname(os),
    00065   m_hostname(host),
    00066   m_os_version(osver), m_machine(mach), m_start_time(time) {
    00067
    00068 }
    00069
    00070
    00071 //**********************************************************************
    00072
    00073 // Destructor.
    00074
    00075 JobHistory::~JobHistory() {
    00076 }
    00077
    00078 const CLID& JobHistory::classID() {
    00079
    00080   static CLID CLID_JobHistory = 247994533;
    00081   return CLID_JobHistory;
    00082
    00083 }
    00084
    00085 void
    00086 JobHistory::addProperty(const std::string& client, const Property* prop) {
    00087 //  if (m_props.find(prop) == m_props.end()) {
    00088     m_props.push_back( std::pair<std::string, const Property*>(client,prop) );
    00089 //  }
    00090 }
    00091
    00092 //**********************************************************************
    00093 // Free functions.
    00094 //**********************************************************************
    00095
    00096 // Output stream.
    00097
    00098 ostream& operator<<(ostream& lhs, const JobHistory& rhs) {
    00099   lhs << "Release: " << rhs.release_version() << endl;
    00100   lhs << "OS:      " << rhs.os() << endl;
    00101   lhs << "OS ver:  " << rhs.os_version() << endl;
    00102   lhs << "Host:    " << rhs.hostname() << endl;
    00103   lhs << "Machine: " << rhs.machine() << endl;
    00104   lhs << "Run dir: " << rhs.dir() << endl;
    00105   lhs << "CMTCONFIG: " << rhs.cmtconfig() << endl;
    00106   lhs << "Job start time: " << rhs.start_time() << endl << endl;
    00107   lhs << "Properties: [" << endl;;
    00108   for ( JobHistory::PropertyList::const_iterator
    00109         ipprop=rhs.properties().begin();
    00110         ipprop!=rhs.properties().end(); ++ipprop ) {
    00111      std::string client = ipprop->first;
    00112      const Property* prop = ipprop->second;
    00113      lhs << client << ":  ";
    00114      prop->fillStream(lhs);
    00115      lhs << endl;
    00116   }
    00117   lhs << "]" << endl;
    00118   vector<string> env = rhs.environment();
    00119   for (vector<string>::const_iterator itr=env.begin();  itr != env.end();
    00120        ++itr) {
    00121     lhs << *itr << endl;
    00122   }
    00123   return lhs;
    00124 }
    00125
    00126 //**********************************************************************

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines