CMS 3D CMS Logo

VParameterSetEntry.cc
Go to the documentation of this file.
5 
6 #include <cassert>
7 #include <ostream>
8 #include <sstream>
9 
10 namespace edm {
11 
12  VParameterSetEntry::VParameterSetEntry() : tracked_(false), theVPSet_(), theIDs_() {}
13 
14  VParameterSetEntry::VParameterSetEntry(std::vector<ParameterSet> const& vpset, bool isTracked)
15  : tracked_(isTracked), theVPSet_(new std::vector<ParameterSet>(vpset)), theIDs_() {}
16 
18  : tracked_(rep[0] == '+'), theVPSet_(), theIDs_(new std::vector<ParameterSetID>) {
19  assert(rep[0] == '+' || rep[0] == '-');
20  std::vector<std::string_view> temp;
21  // need a substring that starts at the '{'
22  std::string_view bracketedRepr = rep.substr(2);
23  split(std::back_inserter(temp), bracketedRepr, '{', ',', '}');
24  theIDs_->reserve(temp.size());
25  for (auto const& id : temp) {
26  theIDs_->emplace_back(std::string(id));
27  }
28  }
29 
31  assert(theIDs_);
32  result += tracked_ ? "+q" : "-q";
33  result += '{';
35  std::string const between(",");
36  for (std::vector<ParameterSetID>::const_iterator i = theIDs_->begin(), e = theIDs_->end(); i != e; ++i) {
37  result += start;
38  i->toString(result);
39  start = between;
40  }
41  result += '}';
42  }
43 
45  assert(theIDs_);
46  digest.append(tracked_ ? "+q{" : "-q{", 3);
47  bool started = false;
48  for (std::vector<ParameterSetID>::const_iterator i = theIDs_->begin(), e = theIDs_->end(); i != e; ++i) {
49  if (started)
50  digest.append(",", 1);
51  i->toDigest(digest);
52  started = true;
53  }
54  digest.append("}", 1);
55  }
56 
60  return result;
61  }
62 
63  std::vector<ParameterSet> const& VParameterSetEntry::vpset() const {
64  fillVPSet();
65  return *theVPSet_;
66  }
67 
68  // NOTE: This function, and other non-const functions of this class
69  // that expose internals, may be used in a way that causes the cached
70  // "theVPSet_" and "theIDs_" to be inconsistent.
71  // THIS PROBLEM NEEDS TO BE ADDRESSED
72  std::vector<ParameterSet>& VParameterSetEntry::vpsetForUpdate() {
73  fillVPSet();
74  return *theVPSet_;
75  }
76 
78  if (nullptr == theVPSet_.load()) {
79  auto tmp = std::make_unique<std::vector<ParameterSet>>();
80  tmp->reserve(theIDs_->size());
81  for (auto const& theID : *theIDs_) {
82  tmp->push_back(getParameterSet(theID));
83  }
84  VParameterSet* expected = nullptr;
85  if (theVPSet_.compare_exchange_strong(expected, tmp.get())) {
86  // theVPSet_ was equal to nullptr and now is equal to tmp.get()
87  tmp.release();
88  }
89  }
90  }
91 
92  // NOTE: This function, and other non-const functions of this class
93  // that expose internals, may be used in a way that causes the cached
94  // "theVPSet_" and "theIDs_" to be inconsistent.
95  // THIS PROBLEM NEEDS TO BE ADDRESSED
98  return theVPSet_->at(i);
99  }
100 
102  return theIDs_ ? theIDs_->size() : (theVPSet_ ? vpset().size() : 0);
103  }
104 
106  fillVPSet();
107  theIDs_ = value_ptr<std::vector<ParameterSetID>>(new std::vector<ParameterSetID>);
108  theIDs_->resize(theVPSet_->size());
109  for (std::vector<ParameterSet>::iterator i = theVPSet_->begin(), e = theVPSet_->end(); i != e; ++i) {
110  if (!i->isRegistered()) {
111  i->registerIt();
112  }
113  theIDs_->at(i - theVPSet_->begin()) = i->id();
114  }
115  }
116 
119  std::ostringstream os;
120  std::vector<ParameterSet> const& vps = vpset();
121  os << "VPSet " << (isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
123  std::string const between(",\n");
124  for (std::vector<ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
125  os << start << indentation << i->dump(indent);
126  start = between;
127  }
128  if (!vps.empty()) {
129  os << std::endl;
130  }
131  os << indentation << "})";
132  return os.str();
133  }
134 
135  std::ostream& operator<<(std::ostream& os, VParameterSetEntry const& vpsetEntry) {
136  os << vpsetEntry.dump();
137  return os;
138  }
139 } // namespace edm
Definition: start.py:1
void toDigest(cms::Digest &digest) const
Definition: Hash.h:43
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:35
std::vector< ParameterSet > const & vpset() const
returns the VPSet
std::vector< ParameterSet > & vpsetForUpdate()
assert(be >=bs)
uint16_t size_type
std::string toString() const
value_ptr< std::vector< ParameterSetID > > theIDs_
atomic_value_ptr< std::vector< ParameterSet > > theVPSet_
rep
Definition: cuy.py:1189
void fillVPSet() const
reconstitutes the VPSet from the registry
bool split(OutIter result, std::string_view string_to_split, char first, char sep, char last)
Definition: split.h:70
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::string dump(unsigned int indent=0) const
HLT enums.
ParameterSet & psetInVector(int i)
std::vector< ParameterSet >::size_type size() const
tmp
align.sh
Definition: createJobs.py:716
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
void append(std::string const &s)
Definition: Digest.cc:161