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
DDConstant Class Reference

a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> More...

#include <DDConstant.h>

Inheritance diagram for DDConstant:
DDBase< DDName, double * >

Public Member Functions

 DDConstant ()
 an uninitialized constant; one can assign an initialized constant to make it valid More...
 
 DDConstant (const DDName &name)
 a refenrence to a constant More...
 
 DDConstant (const DDName &name, double *value)
 creation of a new named constant; if it already existed with the given name, it's overwritten with new values More...
 
 operator double () const
 convert to a double More...
 
double value () const
 return the first stored value; does not check boundaries! More...
 
- Public Member Functions inherited from DDBase< DDName, double * >
 DDBase ()
 
const DDNameddname () const
 
def_type isDefined () const
 
bool isValid () const
 true, if the wrapped pointer is valid More...
 
const DDNamename () const
 
 operator bool () const
 
bool operator< (const DDBase &b) const
 
bool operator== (const DDBase &b) const
 
bool operator> (const DDBase &b) const
 
const DDI::rep_traits< DDName,
double * >::reference 
rep () const
 
DDI::rep_traits< DDName,
double * >::reference 
rep ()
 
std::string toString () const
 
const DDI::rep_traits< DDName,
double * >::reference 
val () const
 
const DDI::rep_traits< DDName,
double * >::reference 
val ()
 
virtual ~DDBase ()
 

Static Public Member Functions

static void createConstantsFromEvaluator ()
 creates all DDConstants from the variables of the ClhepEvaluator More...
 
- Static Public Member Functions inherited from DDBase< DDName, double * >
static DDI::Store< DDName,
double * >::iterator 
begin ()
 
static void clear ()
 
static DDI::Store< DDName,
double * >::iterator 
end ()
 
static size_t size ()
 

Additional Inherited Members

- Public Types inherited from DDBase< DDName, double * >
typedef std::pair< const
DDName *, bool > 
def_type
 
typedef double * pimpl_type
 
typedef DDI::rep_type< DDName,
pimpl_type > * 
prep_type
 
typedef DDI::Singleton
< DDI::Store< DDName, double * > > 
StoreT
 
- Protected Attributes inherited from DDBase< DDName, double * >
prep_type prep_
 

Detailed Description

a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>

Definition at line 15 of file DDConstant.h.

Constructor & Destructor Documentation

DDConstant::DDConstant ( )

an uninitialized constant; one can assign an initialized constant to make it valid

Definition at line 6 of file DDConstant.cc.

DDConstant::DDConstant ( const DDName name)

a refenrence to a constant

Definition at line 9 of file DDConstant.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, double * >::prep_.

10 {
11  prep_ = StoreT::instance().create(name);
12 }
static value_type & instance()
DDConstant::DDConstant ( const DDName name,
double *  value 
)

creation of a new named constant; if it already existed with the given name, it's overwritten with new values

Definition at line 14 of file DDConstant.cc.

References DDI::Singleton< I >::instance(), and DDBase< DDName, double * >::prep_.

15 {
16  prep_ = StoreT::instance().create(name,vals);
17 }
static value_type & instance()

Member Function Documentation

void DDConstant::createConstantsFromEvaluator ( )
static

creates all DDConstants from the variables of the ClhepEvaluator

Definition at line 34 of file DDConstant.cc.

References ClhepEvaluator::eval(), edm::hlt::Exception, i, DDI::Singleton< I >::instance(), DDBase< DDName, double * >::name(), alignCSCRings::s, create_public_pileup_plots::vals, ClhepEvaluator::values(), and ClhepEvaluator::variables().

Referenced by DDLSAX2FileHandler::createDDConstants(), and DDStreamer::vars_read().

35 {
37  ClhepEvaluator * eval = dynamic_cast<ClhepEvaluator*>(&ev);
38  if (eval){
39  const std::vector<std::string> & vars = eval->variables();
40  const std::vector<std::string> & vals = eval->values();
41  if (vars.size() != vals.size()) {
42  throw cms::Exception("DDException") << "DDConstants::createConstansFromEvaluator(): different size of variable names & values!";
43  }
44  size_t i(0), s(vars.size());
45  for (; i<s; ++i) {
46  const std::string & sr = vars[i];
47  typedef std::string::size_type ST;
48  ST i1 = sr.find("___");
49  DDName name(std::string(sr,i1+3,sr.size()-1),std::string(sr,0,i1));
50  double* dv = new double;
51  *dv = eval->eval(sr.c_str());
52  DDConstant cst(name,dv);//(ddname);
53  }
54  }
55  else {
56  throw cms::Exception("DDException") << "DDConstants::createConstansFromEvaluator(): expression-evaluator is not a ClhepEvaluator-implementation!";
57  }
58 }
int i
Definition: DBlmapReader.cc:9
const DDName & name() const
Definition: DDBase.h:82
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
uint16_t size_type
static value_type & instance()
Interface of an Expression Evaluator.
const std::vector< std::string > & variables() const
access to the clhep-implementation of the dictionary variables
const std::vector< std::string > & values() const
double eval(const std::string &ns, const std::string &expr)
evaluate an expression expr inside the local namespace
a named constant corresponding to the DDL-XML tag &lt;Constant&gt; and &lt;ConstantsVector&gt; ...
Definition: DDConstant.h:15
DDConstant::operator double ( ) const
inline

convert to a double

Definition at line 34 of file DDConstant.h.

References DDBase< DDName, double * >::rep().

34 { return rep(); }
const DDI::rep_traits< DDName, double * >::reference rep() const
Definition: DDBase.h:89
double DDConstant::value ( ) const
inline