CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDValue.h
Go to the documentation of this file.
1 #ifndef DDValue_h
2 #define DDValue_h
3 #include <iostream>
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <memory>
8 
11 
12 #include "boost/shared_ptr.hpp"
13 
14 class DDValue;
15 class DDSpecifics;
16 class DDLSpecPar;
17 
18 //std::ostream & operator<< ( std::ostream &, const DDValue &);
26 class DDValue //: public std::vector<DDValuePair>
27 {
28  friend class DDSpecifics;
29  friend class DDLSpecPar;
30 public:
32  DDValue() : id_(0), vecPair_(0) { }
33 
35  DDValue(const std::string &);
36 
38  DDValue(const char *);
39 
40  void init(const std::string &);
41 
43  explicit DDValue(const std::string &, const std::vector<DDValuePair>&);
44 
46  explicit DDValue(const std::string &, double);
47 
49  explicit DDValue(const std::string &, const std::string &, double);
50 
52  explicit DDValue(const std::string & name, const std::string & val);
53 
54  explicit DDValue(unsigned int);
55  //~DDValue() { destroy(); }
56  //DDValue(const DDValue &);
57  //DDValue & operator=(const DDValue &);
58  //const DDValuePair &
59 
60  ~DDValue();
61 
63  unsigned int id() const { return id_; }
64 
66  operator unsigned int() const { return id_; }
67 
69  const std::string & name() const { return names()[id_]; }
70 
73  DDValuePair operator[](unsigned int i) const;
74 
76  const std::vector<std::string> & strings() const { return vecPair_->second.first; }
77 
79  const std::vector<double> & doubles() const;
80  //const DDValuePair & operator[](unsigned int i) const { return (*valPairs_)[i] ; }
81 
83  unsigned int size() const {
84  return vecPair_ ? vecPair_->second.first.size() : 0 ;
85  }
86 
87  static void clear();
88 
90  void setEvalState(bool newState);
91 
93 
95  bool isEvaluated() const;
96 
98 
100  bool operator==(const DDValue & v) const;
101  /* {
102  return id()==v.id()
103  && (
104  vecPair_ == v.vecPair_ ||
105  (
106  vecPair_ && v.vecPair_ &&
107  ( (vecPair_->first) ? (vecPair_->second.second == v.vecPair_->second.second)
108  : (vecPair_->second.first == v.vecPair_->second.first)
109  )
110  )
111  )
112  }
113  */
114 
116  bool operator<(const DDValue &) const;
117  /*{
118  return id()<v.id() ||
119  (
120  id()==v.id() &&
121  vecPair_ && v.vecPair_ &&
122  ( (vecPair_->first) ? (vecPair_->second.second < v.vecPair_->second.second)
123  : (vecPair_->second.first < v.vecPair_->second.first)
124  )
125  )
126  }
127  */
128 
129 private:
130  typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > >vecpair_type;
131  static std::vector<std::string>& names();
132  static std::map<std::string,unsigned int>& indexer();
133  static std::vector<boost::shared_ptr<vecpair_type> >& mem(vecpair_type*);
134  //DDValue(const DDValue &);
135  //DDValue & operator=(const DDValue &);
136  //void destroy() { delete vecPair_;} //delete valPairs_; }
137 
138  //static std::vector<std::map<std::string,unsigned int>::const_iterator> names_;
139  unsigned int id_;
140 
141  //Ptr<vecpair_type> vecPair_;
142 public:
144 
145 public:
146  //bool isEvaluated_;
147  //auto_ptr<vecpair_type> vecPair_;
148  //std::vector<DDValuePair> * valPairs_;
149 };
150 
151 
152 std::ostream & operator<<(std::ostream & o, const DDValue & v);
153 #endif // DDValue_h
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:144
static std::vector< std::string > & names()
Definition: DDValue.cc:139
int i
Definition: DBlmapReader.cc:9
~DDValue()
Definition: DDValue.cc:113
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:151
unsigned int id() const
returns the ID of the DDValue
Definition: DDValue.h:63
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:130
static std::map< std::string, unsigned int > & indexer()
Definition: DDValue.cc:134
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:201
DDLSpecPar processes SpecPar elements.
Definition: DDLSpecPar.h:23
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
bool isEvaluated() const
true, if values are numerical evaluated; else false.
Definition: DDValue.cc:207
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
bool operator==(const DDValue &v) const
Two DDValues are equal only if their id() is equal AND their values are equal.
Definition: DDValue.cc:213
DDValue()
create a unnamed emtpy value. One can assing a named DDValue to it.
Definition: DDValue.h:32
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:76
DDValuePair operator[](unsigned int i) const
Definition: DDValue.cc:188
bool operator<(const DDValue &) const
A DDValue a is smaller than a DDValue b if (a.id()&lt;b.id()) OR (a.id()==b.id() and value(a)&lt;value(b)) ...
Definition: DDValue.cc:230
unsigned int size() const
the size of the stored value-pairs (std::string,double)
Definition: DDValue.h:83
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
static void clear()
Definition: DDValue.cc:120
mathSSE::Vec4< T > v
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:40
vecpair_type * vecPair_
Definition: DDValue.h:143