CMS 3D CMS Logo

ParameterDescriptionCases.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_ParameterDescriptionCases_h
2 #define FWCore_ParameterSet_ParameterDescriptionCases_h
3 
4 // This class is used to store temporary objects created when
5 // building ParameterSwitch's in a ParameterSetDescription.
6 // It gets created while evaluating an expression something
7 // like
8 //
9 // parameterSetDescription.ifValue( ParameterDescription<int>("switch", 0),
10 // 0 >> ParameterDescription<int>("label1", 11) or
11 // 1 >> ParameterDescription<float>("label2", 11.0f) or
12 // 2 >> ParameterDescription<std::string>("label3", "aValue");
13 // It hold the temporary results of the operator>> and operator||
14 // functions in the expression. The ONLY way to create one
15 // is via the operator>> function. The intent is that user
16 // should not need to save this temporary result nor directly
17 // reference this class, but ...
18 
19 // If one decided to save the value then one should be aware
20 // the class has been optimized to minimize the number of copies made
21 // while evaluating such an expression. It contains a unique_ptr and
22 // the class has move semantics like a unique_ptr.
23 
26 
27 #include <map>
28 #include <memory>
29 #include <string>
30 #include <utility>
31 
32 namespace edm {
33 
34  template <typename T>
36  public:
37  typedef std::map<T, edm::value_ptr<ParameterDescriptionNode> > CaseMap;
38 
39  void insert(T caseValue, std::unique_ptr<ParameterDescriptionNode> node) {
40  std::pair<T, edm::value_ptr<ParameterDescriptionNode> > casePair(caseValue,
42  std::pair<typename CaseMap::iterator, bool> status;
43  status = caseMap_->insert(casePair);
44  (*caseMap_)[caseValue] = std::move(node);
45  if (status.second == false)
46  duplicateCaseValues_ = true;
47  }
48 
49  std::unique_ptr<CaseMap> caseMap() { return std::move(caseMap_); }
50  bool duplicateCaseValues() const { return duplicateCaseValues_; }
51 
52  private:
53  friend std::unique_ptr<ParameterDescriptionCases<bool> > operator>>(bool caseValue,
54  std::unique_ptr<ParameterDescriptionNode> node);
55 
56  friend std::unique_ptr<ParameterDescriptionCases<int> > operator>>(int caseValue,
57  std::unique_ptr<ParameterDescriptionNode> node);
58 
59  friend std::unique_ptr<ParameterDescriptionCases<std::string> > operator>>(
60  std::string const& caseValue, std::unique_ptr<ParameterDescriptionNode> node);
61 
62  friend std::unique_ptr<ParameterDescriptionCases<std::string> > operator>>(
63  char const* caseValue, std::unique_ptr<ParameterDescriptionNode> node);
64 
65  // The constructor is intentionally private so that only the operator>> functions
66  // can create these.
67  ParameterDescriptionCases(T const& caseValue, std::unique_ptr<ParameterDescriptionNode> node)
69  std::pair<T, edm::value_ptr<ParameterDescriptionNode> > casePair(caseValue,
71  caseMap_->insert(casePair);
72  (*caseMap_)[caseValue] = std::move(node);
73  }
74 
75  std::unique_ptr<CaseMap> caseMap_;
77  };
78 
79  std::unique_ptr<ParameterDescriptionCases<bool> > operator||(std::unique_ptr<ParameterDescriptionCases<bool> >,
81 
82  std::unique_ptr<ParameterDescriptionCases<int> > operator||(std::unique_ptr<ParameterDescriptionCases<int> >,
84 
85  std::unique_ptr<ParameterDescriptionCases<std::string> > operator||(
88 } // namespace edm
89 #endif
edm::ParameterDescriptionCases::caseMap_
std::unique_ptr< CaseMap > caseMap_
Definition: ParameterDescriptionCases.h:75
funct::false
false
Definition: Factorize.h:29
edm::operator||
std::unique_ptr< ParameterDescriptionCases< bool > > operator||(std::unique_ptr< ParameterDescriptionCases< bool > >, std::unique_ptr< ParameterDescriptionCases< bool > >)
Definition: ParameterDescriptionCases.cc:6
edm::ParameterDescriptionCases::duplicateCaseValues_
bool duplicateCaseValues_
Definition: ParameterDescriptionCases.h:76
mps_update.status
status
Definition: mps_update.py:69
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterDescriptionCases::operator>>
friend std::unique_ptr< ParameterDescriptionCases< bool > > operator>>(bool caseValue, std::unique_ptr< ParameterDescriptionNode > node)
Definition: ParameterDescriptionNode.cc:155
edm::ParameterDescriptionCases::CaseMap
std::map< T, edm::value_ptr< ParameterDescriptionNode > > CaseMap
Definition: ParameterDescriptionCases.h:37
edm::ParameterDescriptionCases
Definition: ParameterDescriptionCases.h:35
edm::ParameterDescriptionCases::caseMap
std::unique_ptr< CaseMap > caseMap()
Definition: ParameterDescriptionCases.h:49
ParameterDescriptionNode.h
value_ptr.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::value_ptr
Definition: value_ptr.h:63
edm::ParameterDescriptionCases::insert
void insert(T caseValue, std::unique_ptr< ParameterDescriptionNode > node)
Definition: ParameterDescriptionCases.h:39
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ParameterDescriptionCases::ParameterDescriptionCases
ParameterDescriptionCases(T const &caseValue, std::unique_ptr< ParameterDescriptionNode > node)
Definition: ParameterDescriptionCases.h:67
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ParameterDescriptionCases::duplicateCaseValues
bool duplicateCaseValues() const
Definition: ParameterDescriptionCases.h:50