CMS 3D CMS Logo

ParameterSetEntry.cc
Go to the documentation of this file.
5 
6 #include <cassert>
7 #include <sstream>
8 #include <iostream>
9 namespace edm {
10 
11  ParameterSetEntry::ParameterSetEntry() : isTracked_(false), thePSet_(nullptr), theID_() {}
12 
14  : isTracked_(isTracked), thePSet_(new ParameterSet(pset)), theID_() {
15  if (pset.isRegistered()) {
16  theID_ = pset.id();
17  }
18  }
19 
21  : isTracked_(isTracked), thePSet_(), theID_(id) {}
22 
23  ParameterSetEntry::ParameterSetEntry(std::string const& rep) : isTracked_(rep[0] == '+'), thePSet_(), theID_() {
24  assert(rep[0] == '+' || rep[0] == '-');
25  assert(rep[2] == '(');
26  assert(rep[rep.size() - 1] == ')');
27  ParameterSetID newID(std::string(rep.begin() + 3, rep.end() - 1));
28  theID_.swap(newID);
29  }
30 
32  result += isTracked() ? "+Q(" : "-Q(";
33  if (!theID_.isValid()) {
34  throw edm::Exception(edm::errors::LogicError) << "ParameterSet::toString() called prematurely\n"
35  << "before ParameterSet::registerIt() has been called\n"
36  << "for all nested parameter sets\n";
37  }
39  result += ')';
40  }
41 
43  digest.append(isTracked() ? "+Q(" : "-Q(", 3);
44  if (!theID_.isValid()) {
45  throw edm::Exception(edm::errors::LogicError) << "ParameterSet::toString() called prematurely\n"
46  << "before ParameterSet::registerIt() has been called\n"
47  << "for all nested parameter sets\n";
48  }
49  theID_.toDigest(digest);
50  digest.append(")", 1);
51  }
52 
56  return result;
57  }
58 
60  fillPSet();
61  return *thePSet_;
62  }
63 
65  fillPSet();
66  return *thePSet_;
67  }
68 
70  if (nullptr == thePSet_.load()) {
71  auto tmp = std::make_unique<ParameterSet>(getParameterSet(theID_));
72  ParameterSet* expected = nullptr;
73  if (thePSet_.compare_exchange_strong(expected, tmp.get())) {
74  // thePSet_ was equal to nullptr and now is equal to tmp.get()
75  tmp.release();
76  }
77  }
78  }
79 
81  assert(pset().isRegistered());
82  theID_ = pset().id();
83  }
84 
86  std::ostringstream os;
87  const char* trackiness = (isTracked() ? "tracked" : "untracked");
88  os << "PSet " << trackiness << " = (" << pset().dump(indent) << ")";
89  return os.str();
90  }
91 
92  std::ostream& operator<<(std::ostream& os, ParameterSetEntry const& psetEntry) {
93  os << psetEntry.dump();
94  return os;
95  }
96 } // namespace edm
void swap(Hash< I > &other)
Definition: Hash.h:181
std::string toString() const
ParameterSet const & pset() const
returns the PSet
assert(be >=bs)
bool isValid() const
Definition: Hash.h:141
void fillPSet() const
reconstitutes the PSet from the registry
ParameterSetID id() const
std::string dump(unsigned int indent=0) const
void toDigest(cms::Digest &digest) const
Definition: Hash.h:176
rep
Definition: cuy.py:1189
atomic_value_ptr< ParameterSet > thePSet_
void toString(std::string &result) const
Definition: Hash.h:171
void toDigest(cms::Digest &digest) const
ParameterSet const & getParameterSet(ParameterSetID const &id)
HLT enums.
ParameterSet & psetForUpdate()
std::string dump(unsigned int indent=0) const
bool isRegistered() const
Definition: ParameterSet.h:71
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