CMS 3D CMS Logo

DDVector.cc
Go to the documentation of this file.
2 
3 #include <utility>
4 
6 
8  : DDBase<DDName,std::vector<double>*>()
9 { }
10 
11 DDVector::DDVector(const DDName & name) : DDBase<DDName,std::vector<double>*>()
12 {
13  prep_ = StoreT::instance().create(name);
14 }
15 
16 DDVector::DDVector(const DDName & name,std::vector<double>* vals)
17 {
18  prep_ = StoreT::instance().create(name,vals);
19 }
20 
21 
22 std::ostream & operator<<(std::ostream & os, const DDVector & cons)
23 {
24  os << "DDVector name=" << cons.name();
25 
26  if(cons.isDefined().second) {
27  os << " size=" << cons.size() << " vals=( ";
28  DDVector::value_type::const_iterator it(cons.values().begin()), ed(cons.values().end());
29  for(; it<ed; ++it) {
30  os << *it << ' ';
31  }
32  os << ')';
33  }
34  else {
35  os << " constant is not yet defined, only declared.";
36  }
37  return os;
38 }
39 
40 
41 
42 
43 DDVector::operator std::vector<int>() const
44 {
45  std::vector<int> result(rep().size());
47  std::vector<double>::const_iterator it(rep().begin()), ed(rep().end());
48  for (; it != ed; ++it) {
49  result[sz] = int(*it);
50  ++sz;
51  }
52  return result;
53 }
Definition: DDBase.h:10
const DDI::rep_traits< DDName, std::vector< double > * >::reference rep() const
Definition: DDBase.h:84
def_type isDefined() const
Definition: DDBase.h:110
const DDName & name() const
Definition: DDBase.h:78
size_t size() const
the size of the array of values
Definition: DDVector.h:40
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::ostream & operator<<(std::ostream &os, const DDVector &cons)
output operator for printing ...
Definition: DDVector.cc:22
uint16_t size_type
static value_type & instance()
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> ...
Definition: DDVector.h:17
DDVector()
an uninitialized constant; one can assign an initialized constant to make it valid ...
Definition: DDVector.cc:7
const value_type & values() const
the stored values
Definition: DDVector.h:43