CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_(0),
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 
48 
49  void
51  result += isTracked() ? "+Q(" : "-Q(";
52  if (!theID_.isValid()) {
54  << "ParameterSet::toString() called prematurely\n"
55  << "before ParameterSet::registerIt() has been called\n"
56  << "for all nested parameter sets\n";
57  }
58  theID_.toString(result);
59  result += ')';
60  }
61 
62  void
64  digest.append(isTracked() ? "+Q(" : "-Q(", 3);
65  if (!theID_.isValid()) {
67  << "ParameterSet::toString() called prematurely\n"
68  << "before ParameterSet::registerIt() has been called\n"
69  << "for all nested parameter sets\n";
70  }
71  theID_.toDigest(digest);
72  digest.append(")", 1);
73  }
74 
78  toString(result);
79  return result;
80  }
81 
83  fillPSet();
84  return *thePSet_;
85  }
86 
88  fillPSet();
89  return *thePSet_;
90  }
91 
93  if(nullptr == thePSet_.load()) {
94  std::unique_ptr<ParameterSet> tmp(new ParameterSet(getParameterSet(theID_)));
95  ParameterSet* expected = nullptr;
96  if(thePSet_.compare_exchange_strong(expected, tmp.get())) {
97  // thePSet_ was equal to nullptr and now is equal to tmp.get()
98  tmp.release();
99  }
100  }
101  }
102 
104  assert(pset().isRegistered());
105  theID_ = pset().id();
106  }
107 
109  std::ostringstream os;
110  const char* trackiness = (isTracked()?"tracked":"untracked");
111  os << "PSet "<<trackiness<<" = (" << pset().dump(indent) << ")";
112  return os.str();
113  }
114 
115  std::ostream & operator<<(std::ostream & os, ParameterSetEntry const& psetEntry) {
116  os << psetEntry.dump();
117  return os;
118  }
119 }
120 
121 
string rep
Definition: cuy.py:1188
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)
assert(m_qm.get())
void swap(Hash< I > &other)
Definition: Hash.h:206
ParameterSet const & pset() const
returns the PSet
void toDigest(cms::Digest &digest) const
tuple result
Definition: query.py:137
void fillPSet() const
reconstitutes the PSet from the registry
bool isRegistered() const
Definition: ParameterSet.h:65
atomic_value_ptr< ParameterSet > thePSet_
std::string toString() const
void toDigest(cms::Digest &digest) const
Definition: Hash.h:199
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void toString(std::string &result) const
Definition: Hash.h:192
ParameterSet & psetForUpdate()
bool isValid() const
Definition: Hash.h:150
volatile std::atomic< bool > shutdown_flag false
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
void append(std::string const &s)
Definition: Digest.cc:182