00001
00002
00003
00004
00005
00006
00007
00008
00009
00011 #include <cassert>
00012 #include <iostream>
00013 using namespace std;
00014
00015 #include "TSystem.h"
00016 #include "Record/RecJobRecord.h"
00017 #include "MessageService/MsgService.h"
00018 #include "Util/UtilString.h"
00019
00020 ClassImp(RecJobRecord)
00021
00022 CVSID("$Id: RecJobRecord.cxx,v 1.8 2009/02/28 21:46:16 gmieg Exp $");
00023
00024
00025 std::string RecJobRecord::fgProdName = "";
00026
00027
00028
00029
00030
00031 RecJobRecord::RecJobRecord() {
00032
00033
00034 Set("ProdName",fgProdName.c_str());
00035 std::string codename = std::string(AsString(kMinosSoft)) + ":"
00036 + std::string(gSystem->Getenv("SRT_BASE_RELEASE"));
00037 codename += " " + std::string(AsString(kRoot)) + ":v"
00038 + std::string(ROOT_RELEASE);
00039 Set("CodeName",codename.c_str());
00040 Set("HostName",gSystem->HostName());
00041
00042 }
00043
00044
00045 RecJobRecord::RecJobRecord(const char* prodname, const char* codename,
00046 const char* hostname,
00047 const VldTimeStamp& timestamp) :
00048 fTimeStamp(timestamp) {
00049
00050
00051
00052
00053
00054
00055
00056 Set("ProdName",prodname);
00057 Set("CodeName",codename);
00058 Set("HostName",hostname);
00059
00060 }
00061
00062
00063 std::ostream& RecJobRecord::Print(std::ostream& os) const {
00064
00065
00066 std::string prodname = GetProdName();
00067 std::string codename = GetCodeName();
00068
00069 if ( prodname.empty() ) {
00070 os << "[" << codename.c_str() << ((codename.empty()) ? "" : " ")
00071 << GetHostName() << " " << fTimeStamp.AsString("s") << "]";
00072 }
00073 else {
00074 os << "[" << prodname.c_str() << " " << codename.c_str()
00075 << ((codename.empty()) ? "" : " ")
00076 << GetHostName() << " " << fTimeStamp.AsString("s") << "]";
00077 }
00078
00079 return os;
00080
00081 }
00082
00083
00084 void RecJobRecord::Print(Option_t* ) const {
00085
00086
00087 Print(std::cout);
00088
00089 return;
00090
00091 }
00092
00093
00094 std::ostream& RecJobRecord::PrintStream(std::ostream& os) const {
00095
00096
00097
00098 return Print(os);
00099
00100 }
00101
00102
00103 const char* RecJobRecord::AsString(ECodeType codetype) const {
00104
00105
00106 switch( codetype ) {
00107
00108 case kRoot:
00109 return "root";
00110
00111 case kMinosSoft:
00112 return "minossoft";
00113
00114 default:
00115 MSG("Rec",Msg::kError) << "RecJobRecord::AsString received unknown "
00116 << "enumerated code type " << codetype
00117 << "\nMethod needs updating. Abort." << endl;
00118 abort();
00119 }
00120
00121 }
00122
00123
00124 string RecJobRecord::GetCodeVersion(ECodeType type) const {
00125
00126
00127
00128
00129
00130
00131 string codetype = string(AsString(type)) + ":";
00132 UtilString::ToLower(codetype);
00133
00134 vector<string> codevec;
00135 UtilString::StringTok(codevec,string(GetCodeName())," ");
00136
00137 vector<string>::const_iterator citr;
00138 for ( citr = codevec.begin(); citr != codevec.end(); citr++ ) {
00139 string codetok = *citr;
00140 string::size_type pos = codetok.find(codetype);
00141 if ( pos != string::npos ) {
00142 pos += codetype.size();
00143 return codetok.substr(pos);
00144 }
00145 }
00146
00147 return "";
00148
00149 }
00150
00151
00152 ReleaseType::Release_t RecJobRecord::GetProdReleaseType() const {
00153
00154
00155
00156
00157 ReleaseType::Release_t release = ReleaseType::kUnknown;
00158
00159 std::string prodname = GetProdName();
00160
00161 if ( prodname.empty() ) return release;
00162
00163 release = ReleaseType::GetProductionRelease(prodname.c_str());
00164 return release;
00165
00166 }
00167
00168
00169
00170
00171