CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/Provenance/src/ProcessConfiguration.cc

Go to the documentation of this file.
00001 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
00002 #include "FWCore/Utilities/interface/Digest.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 
00005 #include <ostream>
00006 #include <cassert>
00007 #include <sstream>
00008 
00009 /*----------------------------------------------------------------------
00010 
00011 ----------------------------------------------------------------------*/
00012 
00013 namespace edm {
00014 
00015 
00016   ProcessConfiguration::ProcessConfiguration() : processName_(), parameterSetID_(), releaseVersion_(), passID_() {}
00017 
00018   ProcessConfiguration::ProcessConfiguration(
00019                         std::string const& procName,
00020                         ParameterSetID const& pSetID,
00021                         ReleaseVersion const& relVersion,
00022                         PassID const& pass) :
00023       processName_(procName),
00024       parameterSetID_(pSetID),
00025       releaseVersion_(relVersion),
00026       passID_(pass) { }
00027 
00028   ProcessConfiguration::ProcessConfiguration(
00029                         std::string const& procName,
00030                         ReleaseVersion const& relVersion,
00031                         PassID const& pass) :
00032       processName_(procName),
00033       parameterSetID_(),
00034       releaseVersion_(relVersion),
00035       passID_(pass) { isCurrentProcess() = true; }
00036 
00037   ParameterSetID const&
00038   ProcessConfiguration::parameterSetID() const {
00039     if (parameterSetID_ == ParameterSetID() && isCurrentProcess()) {     
00040       throw edm::Exception(errors::LogicError)   
00041         << "Illegal attempt to access the process top level parameter set ID\n"          
00042         << "from the ProcessConfiguration before that parameter\n"       
00043         << "set has been frozen and registered.  The parameter set\n"    
00044         << "can be changed during module validation, which occurs\n"     
00045         << "concurrently with module construction.  The ID of the\n"     
00046         << "ProcessConfiguration itself also depends on that parameter\n"        
00047         << "set ID.  It is illegal to access either before they are frozen.\n";          
00048     }
00049     return parameterSetID_;
00050   }
00051 
00052   ProcessConfigurationID
00053   ProcessConfiguration::id() const {
00054     if(pcid().isValid()) {
00055       return pcid();
00056     }
00057     // This implementation is ripe for optimization.
00058     std::ostringstream oss;
00059     oss << *this;
00060     std::string stringrep = oss.str();
00061     cms::Digest md5alg(stringrep);
00062     ProcessConfigurationID tmp(md5alg.digest().toString());
00063     pcid().swap(tmp);
00064     return pcid();
00065   }
00066 
00067   void
00068   ProcessConfiguration::setParameterSetID(ParameterSetID const& pSetID) {
00069     assert(parameterSetID_ == ParameterSetID());
00070     parameterSetID_ = pSetID;
00071   }
00072 
00073   bool operator<(ProcessConfiguration const& a, ProcessConfiguration const& b) {
00074     if (a.processName() < b.processName()) return true;
00075     if (b.processName() < a.processName()) return false;
00076     if (a.parameterSetID() < b.parameterSetID()) return true;
00077     if (b.parameterSetID() < a.parameterSetID()) return false;
00078     if (a.releaseVersion() < b.releaseVersion()) return true;
00079     if (b.releaseVersion() < a.releaseVersion()) return false;
00080     if (a.passID() < b.passID()) return true;
00081     return false;
00082   }
00083 
00084   std::ostream&
00085   operator<< (std::ostream& os, ProcessConfiguration const& pc) {
00086     os << pc.processName() << ' ' 
00087        << pc.parameterSetID() << ' '
00088        << pc.releaseVersion() << ' '
00089        << pc.passID();
00090     return os;
00091   }
00092 }