test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 an auto_ptr and
22 // the class has copy semantics like an auto_ptr. If you tried to use
23 // this class directly you must be aware that if a copy is
24 // made the original contains a null pointer. Then it would
25 // be easy to write code that dereferences that null pointer.
26 
29 
30 #include <map>
31 #include <memory>
32 #include <string>
33 #include <utility>
34 
35 namespace edm {
36 
37  template<typename T>
39  public:
40  typedef std::map<T, edm::value_ptr<ParameterDescriptionNode> > CaseMap;
41 
42  void insert(T caseValue, std::auto_ptr<ParameterDescriptionNode> node) {
43  std::pair<T, edm::value_ptr<ParameterDescriptionNode> > casePair(caseValue,edm::value_ptr<ParameterDescriptionNode>());
44  std::pair<typename CaseMap::iterator,bool> status;
45  status = caseMap_->insert(casePair);
46  (*caseMap_)[caseValue] = node;
47  if (status.second == false) duplicateCaseValues_ = true;
48  }
49 
50  std::auto_ptr<CaseMap> caseMap() { return caseMap_; }
51  bool duplicateCaseValues() const { return duplicateCaseValues_; }
52 
53  private:
54 
55  friend
56  std::auto_ptr<ParameterDescriptionCases<bool> >
57  operator>>(bool caseValue,
58  std::auto_ptr<ParameterDescriptionNode> node);
59 
60  friend
61  std::auto_ptr<ParameterDescriptionCases<int> >
62  operator>>(int caseValue,
63  std::auto_ptr<ParameterDescriptionNode> node);
64 
65  friend
66  std::auto_ptr<ParameterDescriptionCases<std::string> >
67  operator>>(std::string const& caseValue,
68  std::auto_ptr<ParameterDescriptionNode> node);
69 
70  friend
71  std::auto_ptr<ParameterDescriptionCases<std::string> >
72  operator>>(char const* caseValue,
73  std::auto_ptr<ParameterDescriptionNode> node);
74 
75  // The constructor is intentionally private so that only the operator>> functions
76  // can create these.
77  ParameterDescriptionCases(T const& caseValue, std::auto_ptr<ParameterDescriptionNode> node) :
78  caseMap_(new CaseMap),
80  {
81  std::pair<T, edm::value_ptr<ParameterDescriptionNode> > casePair(caseValue,edm::value_ptr<ParameterDescriptionNode>());
82  caseMap_->insert(casePair);
83  (*caseMap_)[caseValue] = node;
84  }
85 
86  std::auto_ptr<CaseMap> caseMap_;
88  };
89 
90  std::auto_ptr<ParameterDescriptionCases<bool> >
92  std::auto_ptr<ParameterDescriptionCases<bool> >);
93 
94  std::auto_ptr<ParameterDescriptionCases<int> >
96  std::auto_ptr<ParameterDescriptionCases<int> >);
97 
98  std::auto_ptr<ParameterDescriptionCases<std::string> >
101 }
102 #endif
std::auto_ptr< CaseMap > caseMap()
std::auto_ptr< ParameterDescriptionCases< bool > > operator||(std::auto_ptr< ParameterDescriptionCases< bool > >, std::auto_ptr< ParameterDescriptionCases< bool > >)
void insert(T caseValue, std::auto_ptr< ParameterDescriptionNode > node)
ParameterDescriptionCases(T const &caseValue, std::auto_ptr< ParameterDescriptionNode > node)
friend std::auto_ptr< ParameterDescriptionCases< bool > > operator>>(bool caseValue, std::auto_ptr< ParameterDescriptionNode > node)
volatile std::atomic< bool > shutdown_flag false
long double T
std::map< T, edm::value_ptr< ParameterDescriptionNode > > CaseMap
tuple status
Definition: mps_update.py:57