Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RecJobRecord.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // RecJobRecord
00004 //
00005 // RecJobRecord holds information about the job used to create or fill
00006 // a record.
00007 //
00008 // Author:  S. Kasahara   10/07
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 // Global production name set to null by default
00025 std::string RecJobRecord::fgProdName = ""; 
00026 
00027 // Definition of methods
00028 // *********************
00029 
00030 //_____________________________________________________________________________
00031 RecJobRecord::RecJobRecord() {
00032   // Default constructor.  Fills data members from environment.  
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   // Normal constructor.  Fills data members from arguments.  To be used
00050   // in special cases when record not created in framework, e.g. for
00051   // gminos produced record.
00052   // Codename should be constructed using format:
00053   // "codetype:version codetype:version codetype:version" ...
00054   // where codetype is standardized as RecJobRecord::AsString(ECodeType type)
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   //  Purpose:  Print status of record on ostream.
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* /* option */) const {
00085   //  Purpose:  Print header in form supported by TObject::Print.
00086 
00087   Print(std::cout);
00088 
00089   return;
00090 
00091 }
00092 
00093 //_____________________________________________________________________________
00094 std::ostream&  RecJobRecord::PrintStream(std::ostream& os) const {
00095   //  Purpose:  Print status of record on ostream, overriding base class
00096   //            PrintStream method.
00097 
00098   return Print(os);
00099 
00100 }
00101 
00102 //_____________________________________________________________________________
00103 const char* RecJobRecord::AsString(ECodeType codetype) const {
00104   // Purpose: Get code type AsString
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   } // end of switch
00120   
00121 }
00122 
00123 //_____________________________________________________________________________
00124 string RecJobRecord::GetCodeVersion(ECodeType type) const {
00125   // Parse the CodeName for the code version corresponding to codetype 
00126   // AsString(type).  
00127   // The format of the CodeName is assumed to be:
00128   // "codetype:version codetype:version codetype:version ..."
00129   // If no matching codetype is found, return empty string.
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   // Get release type corresponding to ProdName (e.g. "Dogwood0" or
00154   // "Daikon_04")
00155   // Return ReleaseType::kUnknown if unknown.
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 

Generated on Mon Feb 15 11:07:30 2010 for loon by  doxygen 1.3.9.1