CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDVectorGetter.h
Go to the documentation of this file.
1 #ifndef CORE_DDVECTOR_GETTER_H
2 # define CORE_DDVECTOR_GETTER_H
3 
5 # include <string>
6 # include <vector>
7 
8 namespace DDVectorGetter
9 {
10  bool check( const std::string & );
11  std::vector<double> get( const std::string & );
12 
13  inline bool
14  check( const std::string & str )
15  {
16  DDVector::iterator<DDVector> vit;
17  DDVector::iterator<DDVector> ved( DDVector::end());
18 
19  for(; vit != ved; ++vit )
20  {
21  if( vit->isDefined().second )
22  {
23  DDName vname( vit->name());
24  if( vname.name() == str )
25  return true;
26  }
27  }
28 
29  return false;
30  }
31 
32  inline std::vector<double>
33  get( const std::string & str )
34  {
35  DDVector::iterator<DDVector> vit;
36  DDVector::iterator<DDVector> ved( DDVector::end());
37  if( vit == ved )
38  throw cms::Exception( "DDException" ) << "DDVectorGetter: vectors are empty, cannot get array " << str;
39 
40  for (; vit != ved; ++vit )
41  {
42  if( vit->isDefined().second )
43  {
44  DDName vname( vit->name());
45  if( vname.name() == str )
46  {
47  const std::vector<double> & fvec = vit->values();
48  return fvec;
49  }
50  }
51  }
52 
53  throw cms::Exception( "DDException" ) << "DDVectorGetter: cannot get array " << str;
54  }
55 };
56 
57 #endif // CORE_DDVECTOR_GETTER_H
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
bool check(const std::string &)
static DDI::Store< DDName, std::vector< double > * >::iterator end()
Definition: DDBase.h:69