CMS 3D CMS Logo

DDLAlgorithm.cc
Go to the documentation of this file.
11 
12 #include <cstddef>
13 #include <map>
14 #include <utility>
15 
16 class DDCompactView;
17 
19  : DDXMLElement( myreg )
20 {}
21 
22 void
24 {
25  myRegistry_->getElement( "Vector" )->clear();
26 }
27 
28 void
30 {
31  auto myNumeric = myRegistry_->getElement( "Numeric" );
32  auto myString = myRegistry_->getElement( "String" );
33  auto myVector = myRegistry_->getElement( "Vector" );
34  auto myMap = myRegistry_->getElement( "Map" );
35  auto myrParent = myRegistry_->getElement( "rParent" );
36 
37  DDName algoName( getDDName( nmspace ));
38  DDLogicalPart lp( DDName( myrParent->getDDName( nmspace )));
39  DDXMLAttribute atts;
40 
41  // handle all Numeric elements in the Algorithm.
42  DDNumericArguments nArgs;
43  size_t i = 0;
44  for( ; i < myNumeric->size(); ++i )
45  {
46  atts = myNumeric->getAttributeSet( i );
47  nArgs[atts.find( "name" )->second] = myRegistry_->evaluator().eval( nmspace, atts.find( "value" )->second );
48  }
49 
50  DDStringArguments sArgs;
51  for( i = 0; i < myString->size(); ++i )
52  {
53  atts = myString->getAttributeSet( i );
54  sArgs[atts.find( "name" )->second] = atts.find( "value" )->second;
55  }
56 
57  DDAlgorithmHandler handler;
58  atts = getAttributeSet();
59  handler.initialize( algoName, lp, nArgs,
60  static_cast<DDLVector*>( myVector.get())->getMapOfVectors(),
61  static_cast<DDLMap*>( myMap.get())->getMapOfMaps(), sArgs,
62  static_cast<DDLVector*>( myVector.get())->getMapOfStrVectors());
63  handler.execute( cpv );
64 
65  // clear used/referred to elements.
66  myString->clear();
67  myNumeric->clear();
68  myVector->clear();
69  myMap->clear();
70  myrParent->clear();
71  clear();
72 }
73 
void initialize(const DDName &algoName, const DDLogicalPart &parent, const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &svArgs)
initializes the wrapped algorithm algo_ and does some pre- and post-processing
void execute(DDCompactView &)
executes the wrapped algorithm algo_; some pre- and post-processing (exception handling) ...
wrapper around a DDAlgorithm
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
DDLVector handles Rotation and ReflectionRotation elements.
Definition: DDLVector.h:29
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:72
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Definition: DDLAlgorithm.cc:29
ClhepEvaluator & evaluator()
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
Definition: DDLAlgorithm.cc:23
DDLMap handles Map container.
Definition: DDLMap.h:33
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:48
DDLAlgorithm(DDLElementRegistry *myreg)
Definition: DDLAlgorithm.cc:18
double eval(const std::string &ns, const std::string &expr)
The main class for processing parsed elements.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:54
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:79