Go to the documentation of this file.00001 #include <iterator>
00002 #include <ostream>
00003 #include <sstream>
00004 #include "FWCore/Utilities/interface/Digest.h"
00005 #include "FWCore/Utilities/interface/Algorithms.h"
00006
00007 #include "DataFormats/Provenance/interface/ProcessHistory.h"
00008
00009
00010 namespace edm {
00011 ProcessHistoryID
00012 ProcessHistory::id() const {
00013 if(phid().isValid()) {
00014 return phid();
00015 }
00016
00017
00018 std::ostringstream oss;
00019 for (const_iterator i = begin(), e = end(); i != e; ++i) {
00020 oss << i->processName() << ' '
00021 << i->parameterSetID() << ' '
00022 << i->releaseVersion() << ' '
00023 << i->passID() << ' ';
00024 }
00025 std::string stringrep = oss.str();
00026 cms::Digest md5alg(stringrep);
00027 ProcessHistoryID tmp(md5alg.digest().toString());
00028 phid().swap(tmp);
00029 return phid();
00030 }
00031
00032 bool
00033 ProcessHistory::getConfigurationForProcess(std::string const& name,
00034 ProcessConfiguration& config) const {
00035 for (const_iterator i = begin(), e = end(); i != e; ++i) {
00036 if (i->processName() == name) {
00037 config = *i;
00038 return true;
00039 }
00040 }
00041
00042 return false;
00043 }
00044
00045 void
00046 ProcessHistory::reduce() {
00047 phid() = ProcessHistoryID();
00048 for (iterator i = data_.begin(), e = data_.end(); i != e; ++i) {
00049 i->reduce();
00050 }
00051 }
00052
00053 bool
00054 isAncestor(ProcessHistory const& a, ProcessHistory const& b) {
00055 if (a.size() >= b.size()) return false;
00056 typedef ProcessHistory::collection_type::const_iterator const_iterator;
00057 for (const_iterator itA = a.data().begin(), itB = b.data().begin(),
00058 itAEnd = a.data().end(); itA != itAEnd; ++itA, ++itB) {
00059 if (*itA != *itB) return false;
00060 }
00061 return true;
00062 }
00063
00064 std::ostream&
00065 operator<<(std::ostream& ost, ProcessHistory const& ph) {
00066 ost << "Process History = ";
00067 copy_all(ph, std::ostream_iterator<ProcessHistory::value_type>(ost,";"));
00068 return ost;
00069 }
00070 }