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 
12  : isTracked_(false),
13  thePSet_(nullptr),
14  theID_()
15  {
16  }
17 
19  : isTracked_(isTracked),
20  thePSet_(new ParameterSet(pset)),
21  theID_()
22  {
23  if (pset.isRegistered()) {
24  theID_ = pset.id();
25  }
26  }
27 
29  : isTracked_(isTracked),
30  thePSet_(),
31  theID_(id)
32  {
33  }
34 
36  : isTracked_(rep[0] == '+'),
37  thePSet_(),
38  theID_()
39  {
40  assert(rep[0] == '+' || rep[0] == '-');
41  assert(rep[2] == '(');
42  assert(rep[rep.size()-1] == ')');
43  ParameterSetID newID(std::string(rep.begin()+3, rep.end()-1) );
44  theID_.swap(newID);
45  }
46 
47  void
49  result += isTracked() ? "+Q(" : "-Q(";
50  if (!theID_.isValid()) {
52  << "ParameterSet::toString() called prematurely\n"
53  << "before ParameterSet::registerIt() has been called\n"
54  << "for all nested parameter sets\n";
55  }
56  theID_.toString(result);
57  result += ')';
58  }
59 
60  void
62  digest.append(isTracked() ? "+Q(" : "-Q(", 3);
63  if (!theID_.isValid()) {
65  << "ParameterSet::toString() called prematurely\n"
66  << "before ParameterSet::registerIt() has been called\n"
67  << "for all nested parameter sets\n";
68  }
69  theID_.toDigest(digest);
70  digest.append(")", 1);
71  }
72 
76  toString(result);
77  return result;
78  }
79 
81  fillPSet();
82  return *thePSet_;
83  }
84 
86  fillPSet();
87  return *thePSet_;
88  }
89 
91  if(nullptr == thePSet_.load()) {
92  auto tmp = std::make_unique<ParameterSet>(getParameterSet(theID_));
93  ParameterSet* expected = nullptr;
94  if(thePSet_.compare_exchange_strong(expected, tmp.get())) {
95  // thePSet_ was equal to nullptr and now is equal to tmp.get()
96  tmp.release();
97  }
98  }
99  }
100 
102  assert(pset().isRegistered());
103  theID_ = pset().id();
104  }
105 
107  std::ostringstream os;
108  const char* trackiness = (isTracked()?"tracked":"untracked");
109  os << "PSet "<<trackiness<<" = (" << pset().dump(indent) << ")";
110  return os.str();
111  }
112 
113  std::ostream & operator<<(std::ostream & os, ParameterSetEntry const& psetEntry) {
114  os << psetEntry.dump();
115  return os;
116  }
117 }
118 
119 
std::string dump(unsigned int indent=0) const
std::string dump(unsigned int indent=0) const
ParameterSetID id() const
ParameterSet const & getParameterSet(ParameterSetID const &id)
void swap(Hash< I > &other)
Definition: Hash.h:210
#define nullptr
ParameterSet const & pset() const
returns the PSet
void toDigest(cms::Digest &digest) const
void fillPSet() const
reconstitutes the PSet from the registry
rep
Definition: cuy.py:1190
bool isRegistered() const
Definition: ParameterSet.h:64
atomic_value_ptr< ParameterSet > thePSet_
std::string toString() const
void toDigest(cms::Digest &digest) const
Definition: Hash.h:203
friend std::ostream & operator<<(std::ostream &os, ParameterSetEntry const &psetEntry)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
void toString(std::string &result) const
Definition: Hash.h:196
ParameterSet & psetForUpdate()
bool isValid() const
Definition: Hash.h:154
void append(std::string const &s)
Definition: Digest.cc:182