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 bool
00046 isAncestor(ProcessHistory const& a, ProcessHistory const& b) {
00047 if (a.size() >= b.size()) return false;
00048 typedef ProcessHistory::collection_type::const_iterator const_iterator;
00049 for (const_iterator itA = a.data().begin(), itB = b.data().begin(),
00050 itAEnd = a.data().end(); itA != itAEnd; ++itA, ++itB) {
00051 if (*itA != *itB) return false;
00052 }
00053 return true;
00054 }
00055
00056 std::ostream&
00057 operator<<(std::ostream& ost, ProcessHistory const& ph) {
00058 ost << "Process History = ";
00059 copy_all(ph, std::ostream_iterator<ProcessHistory::value_type>(ost,";"));
00060 return ost;
00061 }
00062 }