1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <iterator>
#include <ostream>
#include <sstream>
#include "FWCore/Utilities/interface/Digest.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
namespace edm {
ProcessHistoryID ProcessHistory::id() const {
if (transient_.phid_.isValid()) {
return transient_.phid_;
}
// This implementation is ripe for optimization.
// We do not use operator<< because it does not write out everything.
std::ostringstream oss;
for (auto const& item : *this) {
oss << item.processName() << ' ' << item.parameterSetID() << ' ' << item.releaseVersion() << ' '
<< item.hardwareResourcesDescriptionSerialized() << ' ';
}
std::string stringrep = oss.str();
cms::Digest md5alg(stringrep);
ProcessHistoryID phID(md5alg.digest().toString());
return phID;
}
ProcessHistoryID ProcessHistory::setProcessHistoryID() {
if (!transient_.phid_.isValid()) {
transient_.phid_ = id();
}
return transient_.phid_;
}
bool ProcessHistory::getConfigurationForProcess(std::string const& name, ProcessConfiguration& config) const {
for (auto const& item : *this) {
if (item.processName() == name) {
config = item;
return true;
}
}
// Name not found!
return false;
}
ProcessHistory& ProcessHistory::reduce() {
phid() = ProcessHistoryID();
for (auto& item : data_) {
item.reduce();
}
return *this;
}
bool isAncestor(ProcessHistory const& a, ProcessHistory const& b) {
if (a.size() >= b.size())
return false;
typedef ProcessHistory::collection_type::const_iterator const_iterator;
for (const_iterator itA = a.data().begin(), itB = b.data().begin(), itAEnd = a.data().end(); itA != itAEnd;
++itA, ++itB) {
if (*itA != *itB)
return false;
}
return true;
}
std::ostream& operator<<(std::ostream& ost, ProcessHistory const& ph) {
ost << "Process History = ";
copy_all(ph, std::ostream_iterator<ProcessHistory::value_type>(ost, ";"));
return ost;
}
} // namespace edm
|