CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Static Private Member Functions | Private Attributes | Friends
DDValue Class Reference

#include <DDValue.h>

Public Member Functions

 DDValue ()
 create a unnamed emtpy value. One can assing a named DDValue to it. More...
 
 DDValue (const std::string &)
 create a named empty value More...
 
 DDValue (const char *)
 create a named empty value More...
 
 DDValue (const std::string &, const std::vector< DDValuePair > &)
 creates a named DDValue initialized with a std::vector of values More...
 
 DDValue (const std::string &, double)
 creates a single double valued named DDValue. The corresponding std::string-value is an empty std::string More...
 
 DDValue (const std::string &, const std::string &, double)
 
 DDValue (const std::string &name, const std::string &val)
 
 DDValue (unsigned int)
 
const std::vector< double > & doubles () const
 a reference to the double-valued values stored in the given instance of DDValue More...
 
unsigned int id () const
 returns the ID of the DDValue More...
 
void init (const std::string &)
 
bool isEvaluated () const
 true, if values are numerical evaluated; else false. More...
 
const std::string & name () const
 the name of the DDValue More...
 
 operator unsigned int () const
 converts a DDValue object into its ID More...
 
bool operator< (const DDValue &) const
 A DDValue a is smaller than a DDValue b if (a.id()<b.id()) OR (a.id()==b.id() and value(a)<value(b)) More...
 
bool operator== (const DDValue &v) const
 Two DDValues are equal only if their id() is equal AND their values are equal. More...
 
DDValuePair operator[] (unsigned int i) const
 
void setEvalState (bool newState)
 set to true, if the double-values (method DDValue::doubles()) make sense More...
 
unsigned int size () const
 the size of the stored value-pairs (std::string,double) More...
 
const std::vector< std::string > & strings () const
 a reference to the std::string-valued values stored in the given instance of DDValue More...
 
 ~DDValue ()
 

Static Public Member Functions

static void clear ()
 

Public Attributes

vecpair_typevecPair_
 

Private Types

typedef std::pair< bool,
std::pair< std::vector
< std::string >, std::vector
< double > > > 
vecpair_type
 

Static Private Member Functions

static std::map< std::string,
unsigned int > & 
indexer ()
 
static std::vector
< boost::shared_ptr
< vecpair_type > > & 
mem (vecpair_type *)
 
static std::vector< std::string > & names ()
 

Private Attributes

unsigned int id_
 

Friends

class DDLSpecPar
 
class DDSpecifics
 

Detailed Description

A DDValue std::maps a std::vector of DDValuePair (std::string,double) to a name. Names of DDValues are stored transiently. Furthermore, an ID is assigned std::mapping to the name. If a particular DDValue is not used anymore, use DDValue::clear() to free the internally allocated memory. Use DDValue::setEvalState(true) to indicate whether the double numbers stored in the DDValuePair make sense, otherwise an exception will be thrown when trying to get access to these values via DDValue::doubles() or DDValue::operator[].

Definition at line 26 of file DDValue.h.

Member Typedef Documentation

typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > > DDValue::vecpair_type
private

Definition at line 130 of file DDValue.h.

Constructor & Destructor Documentation

DDValue::DDValue ( )
inline

create a unnamed emtpy value. One can assing a named DDValue to it.

Definition at line 32 of file DDValue.h.

32 : id_(0), vecPair_(0) { }
unsigned int id_
Definition: DDValue.h:139
vecpair_type * vecPair_
Definition: DDValue.h:143
DDValue::DDValue ( const std::string &  name)

create a named empty value

Definition at line 28 of file DDValue.cc.

References init().

29  : id_(0)
30 {
31  init(name);
32 }
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
DDValue::DDValue ( const char *  name)

create a named empty value

Definition at line 34 of file DDValue.cc.

References init().

35  : id_(0)
36 {
37  init(name);
38 }
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
DDValue::DDValue ( const std::string &  name,
const std::vector< DDValuePair > &  v 
)
explicit

creates a named DDValue initialized with a std::vector of values

Definition at line 40 of file DDValue.cc.

References init(), mem(), and vecPair_.

41  : id_(0)
42 {
43  init(name);
44 
45  std::vector<DDValuePair>::const_iterator it = v.begin();
46  std::vector<std::string> svec;
47  std::vector<double> dvec;
48  vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec));
49  mem(vecPair_);
50  for (; it != v.end(); ++it) {
51  vecPair_->second.first.push_back(it->first);
52  vecPair_->second.second.push_back(it->second);
53  }
54 
55  //valPairs_ = new std::vector<DDValuePair>(v);
56 }
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:144
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:130
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
mathSSE::Vec4< T > v
vecpair_type * vecPair_
Definition: DDValue.h:143
DDValue::DDValue ( const std::string &  name,
double  val 
)
explicit

creates a single double valued named DDValue. The corresponding std::string-value is an empty std::string

Definition at line 59 of file DDValue.cc.

References init(), mem(), setEvalState(), and vecPair_.

60  : id_(0) {
61  init(name);
62 
63  std::vector<std::string> svec(1,"");
64  std::vector<double> dvec(1,val);
65 
66  vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec));
67  setEvalState(true);
68  mem(vecPair_);
69 
70  //DDValuePair vp(val);
71  //valPairs_ = new std::vector<DDValuePair>(1,vp);
72 }
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:144
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:130
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:201
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
vecpair_type * vecPair_
Definition: DDValue.h:143
DDValue::DDValue ( const std::string &  name,
const std::string &  sval,
double  dval 
)
explicit

creates a single std::string & numerical-valued named DDValue.

Definition at line 75 of file DDValue.cc.

References init(), mem(), setEvalState(), and vecPair_.

76  : id_(0)
77  {
78  init(name);
79 
80  std::vector<std::string> svec(1,sval);
81  std::vector<double> dvec(1,dval);
82  vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec));
83  setEvalState(true);
84  mem(vecPair_);
85  //DDValuePair vp(sval,dval);
86  //valPairs_ = new std::vector<DDValuePair>(1,vp);
87 }
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:144
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:130
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:201
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
vecpair_type * vecPair_
Definition: DDValue.h:143
DDValue::DDValue ( const std::string &  name,
const std::string &  val 
)
explicit

creates a single std::string-valued named DDValue

Definition at line 90 of file DDValue.cc.

References init(), mem(), setEvalState(), and vecPair_.

91  : id_(0)
92  {
93  init(name);
94 
95  std::vector<std::string> svec(1,sval);
96  std::vector<double> dvec(1,0);
97  vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec));
98  setEvalState(false);
99  mem(vecPair_);
100  //DDValuePair vp(sval,dval);
101  //valPairs_ = new std::vector<DDValuePair>(1,vp);
102 }
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:144
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:130
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:201
unsigned int id_
Definition: DDValue.h:139
void init(const std::string &)
Definition: DDValue.cc:12
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
vecpair_type * vecPair_
Definition: DDValue.h:143
DDValue::DDValue ( unsigned int  i)
explicit

Definition at line 105 of file DDValue.cc.

References i, id_, names(), and size().

106  : id_(0)
107 {
108  if (names().size()-1 <= i)
109  id_ = i;
110 }
static std::vector< std::string > & names()
Definition: DDValue.cc:139
int i
Definition: DBlmapReader.cc:9
unsigned int id_
Definition: DDValue.h:139
unsigned int size() const
the size of the stored value-pairs (std::string,double)
Definition: DDValue.h:83
DDValue::~DDValue ( )

Definition at line 113 of file DDValue.cc.

114 {
115  //DCOUT('C' , "Deleting DDValue.name()=" << name() );
116  // delete vecPair_;
117 }

Member Function Documentation

void DDValue::clear ( void  )
static

Definition at line 120 of file DDValue.cc.

References mem(), and v.

Referenced by python.Vispa.Views.WidgetView.WidgetView::closeEvent(), python.Vispa.Views.BoxDecayView.BoxDecayView::closeEvent(), python.Vispa.Share.FindAlgorithm.FindAlgorithm::findUsingFindDialog(), python.Vispa.Views.LineDecayView.LineDecayView::setDataObjects(), python.Vispa.Views.WidgetView.WidgetView::setDataObjects(), python.Vispa.Views.TreeView.TreeView::updateContent(), python.Vispa.Views.TableView.TableView::updateContent(), python.Vispa.Views.BoxDecayView.BoxDecayView::updateContent(), and python.Vispa.Views.PropertyView.PropertyView::updateContent().

121 {
122  std::vector<boost::shared_ptr<vecpair_type> > & v = mem(0);
123  //NOT sure about removing this... I think it is ok because of shared_ptr...
124 // std::vector<boost::shared_ptr<vecpair_type> >::iterator it = v.begin();
125 // for (; it != v.end(); ++ it) {
126 // delete *it;
127 // }
128  v.clear();
129  //delete vecPair_;
130  //vecPair_=0;
131 }
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:144
mathSSE::Vec4< T > v
const std::vector< double > & DDValue::doubles ( ) const

a reference to the double-valued values stored in the given instance of DDValue

Definition at line 151 of file DDValue.cc.

References id_, argparse::message, names(), and vecPair_.

Referenced by DDMapper< KeyType, ValueType >::all(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), HFShowerPMT::getDDDArray(), HFShowerFibreBundle::getDDDArray(), HFFibre::getDDDArray(), MaterialBudgetHcalHistos::getDDDArray(), HFShower::getDDDArray(), ECalSD::getDDDArray(), HFShowerParam::getDDDArray(), HCalSD::getDDDArray(), HcalNumberingFromDDD::getDDDArray(), HFShowerLibrary::getDDDArray(), MuonDDDNumbering::getInt(), DDG4Builder::getInt(), CaloTrkProcessing::getNumbers(), CocoaAnalyzer::myFetchDbl(), DDMapper< KeyType, ValueType >::toDouble(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().

152 {
153  if (vecPair_->first) {
154  return vecPair_->second.second;
155  }
156  else {
157  std::string message = "DDValue " + names()[id_] + " is not numerically evaluated! Use DDValue::std::strings()!";
158  edm::LogError("DDValue") << message << std::endl;
159  throw DDException(message);
160  }
161 }
static std::vector< std::string > & names()
Definition: DDValue.cc:139
An exception for DDD errors.
Definition: DDException.h:23
unsigned int id_
Definition: DDValue.h:139
string message
Definition: argparse.py:126
vecpair_type * vecPair_
Definition: DDValue.h:143
unsigned int DDValue::id ( void  ) const
inline

returns the ID of the DDValue

Definition at line 63 of file DDValue.h.

References id_.

Referenced by DDI::LogicalPart::hasDDValue(), operator<(), and operator==().

63 { return id_; }
unsigned int id_
Definition: DDValue.h:139
std::map< std::string, unsigned int > & DDValue::indexer ( )
staticprivate

Definition at line 134 of file DDValue.cc.

Referenced by init().

134  {
135  static std::map<std::string,unsigned int> indexer_;
136  return indexer_;
137 }
void DDValue::init ( const std::string &  name)

Definition at line 12 of file DDValue.cc.

References id_, indexer(), names(), query::result, and cond::rpcobtemp::temp.

Referenced by DDValue().

12  {
13  unsigned int temp = indexer().size()+1;
14  typedef std::map<std::string,unsigned int>::iterator itT;
15  std::pair<itT,bool> result = indexer().insert(std::make_pair(name,temp));
16 
17  if (result.second) {
18  id_ = temp;
19  names().push_back(name);
20  }
21  else {
22  id_ = result.first->second;
23  }
24 }
static std::vector< std::string > & names()
Definition: DDValue.cc:139
static std::map< std::string, unsigned int > & indexer()
Definition: DDValue.cc:134
unsigned int id_
Definition: DDValue.h:139
tuple result
Definition: query.py:137
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
bool DDValue::isEvaluated ( ) const

true, if values are numerical evaluated; else false.

in case of a 'true' return value, the method DDValue::doubles() and the operator DDValue::operator[] can be used

Definition at line 207 of file DDValue.cc.

References vecPair_.

Referenced by operator<<(), DDCoreToDDXMLOutput::specpar(), DDStreamer::specs_write(), and DDI::Specific::stream().

208 {
209  return vecPair_->first;
210 }
vecpair_type * vecPair_
Definition: DDValue.h:143
std::vector< boost::shared_ptr< DDValue::vecpair_type > > & DDValue::mem ( DDValue::vecpair_type vp)
staticprivate

Definition at line 144 of file DDValue.cc.

Referenced by clear(), and DDValue().

145 {
146  static std::vector<boost::shared_ptr<vecpair_type> > memory_;
147  memory_.push_back( boost::shared_ptr<vecpair_type>(vp) );
148  return memory_;
149 }
const std::string& DDValue::name ( ) const
inline

the name of the DDValue

Definition at line 69 of file DDValue.h.

References id_, and names().

Referenced by BeautifulSoup.Tag::_invert(), DDI::LogicalPart::addSpecifics(), operator<<(), DDCoreToDDXMLOutput::specpar(), DDStreamer::specs_write(), DDI::Specific::stream(), and python.Vispa.Views.PropertyView.Property::valueChanged().

69 { return names()[id_]; }
static std::vector< std::string > & names()
Definition: DDValue.cc:139
unsigned int id_
Definition: DDValue.h:139
std::vector< std::string > & DDValue::names ( )
staticprivate

Definition at line 139 of file DDValue.cc.

Referenced by DDValue(), doubles(), init(), name(), and operator[]().

139  {
140  static std::vector<std::string> names_(1);
141  return names_;
142 }
DDValue::operator unsigned int ( ) const
inline

converts a DDValue object into its ID

Definition at line 66 of file DDValue.h.

References id_.

66 { return id_; }
unsigned int id_
Definition: DDValue.h:139
bool DDValue::operator< ( const DDValue v) const

A DDValue a is smaller than a DDValue b if (a.id()<b.id()) OR (a.id()==b.id() and value(a)<value(b))

Definition at line 230 of file DDValue.cc.

References id(), query::result, and vecPair_.

231 {
232  bool result(false);
233  if (id()<v.id()) {
234  result = true;
235  }
236  else {
237  if (id()==v.id()) {
238  assert(vecPair_);
239  assert(v.vecPair_);
240  if (vecPair_->first && v.vecPair_->first) { // numerical values
241  result = (vecPair_->second.second < v.vecPair_->second.second);
242  }
243  else { // std::string values
244  result = (vecPair_->second.first < v.vecPair_->second.first);
245  }
246  }
247  }
248  return result;
249 }
unsigned int id() const
returns the ID of the DDValue
Definition: DDValue.h:63
tuple result
Definition: query.py:137
vecpair_type * vecPair_
Definition: DDValue.h:143
bool DDValue::operator== ( const DDValue v) const

Two DDValues are equal only if their id() is equal AND their values are equal.

If the DDValue::isEvalued() == true, the numerical representation is taken for comparison, else the std::string representation

Definition at line 213 of file DDValue.cc.

References id(), query::result, and vecPair_.

214 {
215  bool result(false);
216  if (id()==v.id()) {
217  assert(vecPair_);
218  assert(v.vecPair_);
219  if (vecPair_->first) { // numerical values
220  result = (vecPair_->second.second == v.vecPair_->second.second);
221  }
222  else { // std::string values
223  result = (vecPair_->second.first == v.vecPair_->second.first);
224  }
225  }
226  return result;
227 }
unsigned int id() const
returns the ID of the DDValue
Definition: DDValue.h:63
tuple result
Definition: query.py:137
vecpair_type * vecPair_
Definition: DDValue.h:143
DDValuePair DDValue::operator[] ( unsigned int  i) const

access to the values stored in DDValue by an index. Note, that the index is not checked for bounds excess!

Definition at line 188 of file DDValue.cc.

References id_, argparse::message, names(), and vecPair_.

189  {
190  if (vecPair_->first) {
191  return DDValuePair(vecPair_->second.first[i], vecPair_->second.second[i]);
192  }
193  else {
194  std::string message = "DDValue " + names()[id_] + " is not numerically evaluated! Use DDValue::std::strings()!";
195  edm::LogError("DDValue") << message;
196  throw DDException(message);
197  }
198  }
static std::vector< std::string > & names()
Definition: DDValue.cc:139
int i
Definition: DBlmapReader.cc:9
An exception for DDD errors.
Definition: DDException.h:23
unsigned int id_
Definition: DDValue.h:139
string message
Definition: argparse.py:126
vecpair_type * vecPair_
Definition: DDValue.h:143
void DDValue::setEvalState ( bool  newState)

set to true, if the double-values (method DDValue::doubles()) make sense

Definition at line 201 of file DDValue.cc.

References vecPair_.

Referenced by DDValue(), DDLSpecPar::processElement(), and DDStreamer::specs_read().

202 {
203  vecPair_->first = newState;
204 }
vecpair_type * vecPair_
Definition: DDValue.h:143
unsigned int DDValue::size ( void  ) const
inline

the size of the stored value-pairs (std::string,double)

Definition at line 83 of file DDValue.h.

References vecPair_.

Referenced by DDValue(), DDMapper< KeyType, ValueType >::noSpecifics(), operator<<(), DDCoreToDDXMLOutput::specpar(), DDStreamer::specs_write(), DDI::Specific::stream(), DDMapper< KeyType, ValueType >::toDouble(), and DDMapper< KeyType, ValueType >::toString().

83  {
84  return vecPair_ ? vecPair_->second.first.size() : 0 ;
85  }
vecpair_type * vecPair_
Definition: DDValue.h:143
const std::vector<std::string>& DDValue::strings ( ) const
inline

Friends And Related Function Documentation

friend class DDLSpecPar
friend

Definition at line 29 of file DDValue.h.

friend class DDSpecifics
friend

Definition at line 28 of file DDValue.h.

Member Data Documentation

unsigned int DDValue::id_
private

Definition at line 139 of file DDValue.h.

Referenced by DDValue(), doubles(), id(), init(), name(), operator unsigned int(), and operator[]().

vecpair_type* DDValue::vecPair_