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 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 #include <map>
8 #include <memory>
9 
11 
12 #include "boost/shared_ptr.hpp"
13 
14 class DDValue;
15 class DDSpecifics;
16 class DDLSpecPar;
17 
25 class DDValue
26 {
27  friend class DDSpecifics;
28  friend class DDLSpecPar;
29 public:
31  DDValue( void ) : id_(0), vecPair_(0) { }
32 
34  DDValue( const std::string & );
35 
37  DDValue( const char * );
38 
39  void init( const std::string & );
40 
42  explicit DDValue( const std::string &, const std::vector<DDValuePair>& );
43 
45  explicit DDValue( const std::string &, double );
46 
48  explicit DDValue( const std::string &, const std::string &, double );
49 
51  explicit DDValue( const std::string & name, const std::string & val );
52 
53  explicit DDValue( unsigned int );
54 
55  ~DDValue( void );
56 
58  unsigned int id( void ) const { return id_; }
59 
61  operator unsigned int( void ) const { return id_; }
62 
64  const std::string & name( void ) const { return names()[id_]; }
65 
68  DDValuePair operator[]( unsigned int i ) const;
69 
71  const std::vector<std::string> & strings() const { return vecPair_->second.first; }
72 
74  const std::vector<double> & doubles() const;
75  //const DDValuePair & operator[](unsigned int i) const { return (*valPairs_)[i] ; }
76 
78  unsigned int size() const {
79  return vecPair_ ? vecPair_->second.first.size() : 0 ;
80  }
81 
82  static void clear( void );
83 
85  void setEvalState( bool newState );
86 
88 
90  bool isEvaluated( void ) const;
91 
93 
95  bool operator==( const DDValue & v ) const;
96 
98  bool operator<( const DDValue & ) const;
99 
100 private:
101  typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > >vecpair_type;
102  static std::vector<std::string>& names();
103  static std::map<std::string,unsigned int>& indexer();
104  static std::vector<boost::shared_ptr<vecpair_type> >& mem(vecpair_type*);
105 
106  unsigned int id_;
107 
108 public:
110 };
111 
112 std::ostream & operator<<(std::ostream & o, const DDValue & v);
113 
114 #endif // DDValue_h
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:126
static std::vector< std::string > & names()
Definition: DDValue.cc:119
int i
Definition: DBlmapReader.cc:9
DDValue(void)
create a unnamed emtpy value. One can assing a named DDValue to it.
Definition: DDValue.h:31
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:134
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:101
static std::map< std::string, unsigned int > & indexer()
Definition: DDValue.cc:112
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:192
DDLSpecPar processes SpecPar elements.
Definition: DDLSpecPar.h:23
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
unsigned int id(void) const
returns the ID of the DDValue
Definition: DDValue.h:58
~DDValue(void)
Definition: DDValue.cc:101
bool isEvaluated(void) const
true, if values are numerical evaluated; else false.
Definition: DDValue.cc:198
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
bool operator==(const DDValue &v) const
Two DDValues are equal only if their id() is equal AND their values are equal.
Definition: DDValue.cc:204
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:71
DDValuePair operator[](unsigned int i) const
Definition: DDValue.cc:177
static void clear(void)
Definition: DDValue.cc:105
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:222
unsigned int size() const
the size of the stored value-pairs (std::string,double)
Definition: DDValue.h:78
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:40
vecpair_type * vecPair_
Definition: DDValue.h:109