CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
DDLAlgoPosPart Class Reference

DDLAlgoPosPart handles AlgoPosPart elements. More...

#include <DDLAlgoPosPart.h>

Inheritance diagram for DDLAlgoPosPart:
DDXMLElement

Public Member Functions

 DDLAlgoPosPart (DDLElementRegistry *myreg)
 Constructor. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Processing the element. More...
 
 ~DDLAlgoPosPart ()
 Destructor. More...
 
- Public Member Functions inherited from DDXMLElement
void appendText (const std::string &inText)
 append to the current (i.e. most recently added) More...
 
virtual std::vector
< DDXMLAttribute >
::const_iterator 
begin (void)
 
virtual void clear (void)
 clear this element's contents. More...
 
 DDXMLElement (DDLElementRegistry *myreg)
 Constructor. More...
 
 DDXMLElement (DDLElementRegistry *myreg, const bool &clearme)
 Constructor for autoClear element. More...
 
virtual std::vector
< DDXMLAttribute >
::const_iterator 
end (void)
 
virtual const std::string & get (const std::string &name, size_t aIndex=0) const
 Returns a specific value from the aIndex set of attributes. More...
 
virtual const std::string & getAttribute (const std::string &name) const
 Access to attributes by name. More...
 
virtual const DDXMLAttributegetAttributeSet (size_t aIndex=0) const
 Get a "row" of attributes, i.e. one attribute set. More...
 
virtual const DDName getDDName (const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
 
const std::string getText (size_t tindex=0) const
 retrieve the text blob. More...
 
virtual std::vector< std::string > getVectorAttribute (const std::string &name)
 Returns a set of values as a std::vector of strings, given the attribute name. More...
 
virtual bool gotText (void) const
 gotText()? kind of like gotMilk? Yes = text has already been encountered. More...
 
virtual bool isEmpty (void) const
 Have any elements of this type been encountered but not processed? More...
 
void loadAttributes (const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv)
 Load the element attributes. More...
 
void loadText (const std::string &inText)
 Used to load both text and XML comments into this object. More...
 
std::vector< DDXMLAttribute >
::const_iterator & 
operator++ (int inc)
 Allow the elements of this type to be iterated over using ++ operator. More...
 
const std::string & parent (void) const
 access to parent element name More...
 
virtual void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded. More...
 
void setParent (const std::string &pename)
 Set parent element name to central list of names. More...
 
void setSelf (const std::string &sename)
 Set self element name to central list of names. More...
 
virtual size_t size (void) const
 Number of elements accumulated. More...
 
virtual void stream (std::ostream &os) const
 Allow for the elements to have their own streaming method, but also provide a default. More...
 
void throwError (const std::string &keyMessage) const
 format std::string for throw an error. More...
 
virtual ~DDXMLElement (void)
 Destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DDXMLElement
static std::string itostr (int i)
 WARNING: abused by other classes in this system: yet another conversion from int to std::string... More...
 
- Protected Attributes inherited from DDXMLElement
DDLElementRegistrymyRegistry_
 

Detailed Description

DDLAlgoPosPart handles AlgoPosPart elements.

Author
Michael Case

DDLAlgoPosPart.h - description

begin: Wed Apr 17 2002 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

An AlgoPosPart (or Algorithmic Positioning Part) is used to repeatedly position a LogicalPart somewhere inside it's parent. So, an AlgoPosPart needs two rLogicalParts (self and parent) on which to operate, an Algorithm and it's parameters.

Definition at line 25 of file DDLAlgoPosPart.h.

Constructor & Destructor Documentation

DDLAlgoPosPart::DDLAlgoPosPart ( DDLElementRegistry myreg)

Constructor.

Definition at line 26 of file DDLAlgoPosPart.cc.

27  : DDXMLElement( myreg )
28 {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:15
DDLAlgoPosPart::~DDLAlgoPosPart ( void  )

Destructor.

Definition at line 30 of file DDLAlgoPosPart.cc.

31 {}

Member Function Documentation

void DDLAlgoPosPart::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
virtual

Processing the element.

The processElement method completes any necessary work to process the XML element.

For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.

Reimplemented from DDXMLElement.

Definition at line 36 of file DDLAlgoPosPart.cc.

References DDCompactView::algoPosPart(), DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, DDI::Singleton< I >::instance(), DDBase< N, C >::isDefined(), lumiQueryAPI::msg, DDXMLElement::myRegistry_, DDXMLElement::parent(), DDAlgo::setParameters(), DDXMLElement::size(), AlCaHLTBitMon_QueryRunRegistry::string, and DDXMLElement::throwError().

37 {
38  DCOUT_V('P', "DDLAlgoPosPart::processElement started");
39 
40  // get all internal elements.
41  DDXMLElement* myParent = myRegistry_->getElement("rParent");
42  DDXMLElement* myChild = myRegistry_->getElement("rChild");
43  DDXMLElement* myParS = myRegistry_->getElement("ParS");
44  DDXMLElement* myParE = myRegistry_->getElement("ParE");
45 
47 
49 
50  // these were doubles
51  int st = static_cast<int> ((atts.find("start") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("start")->second)));
52  int ic = static_cast<int> ((atts.find("incr") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("incr")->second)));
53  int ed = static_cast<int> ((atts.find("end") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("end")->second)));
54 
55  // get actual DDLogicalPart objects.
56  DDLogicalPart parent(DDName(myParent->getDDName(nmspace)));
57  DDLogicalPart self(DDName(myChild->getDDName(nmspace)));
58 
59  // get the algorithm
60  DDAlgo algo( getDDName(nmspace, "algo" ));
61  if (!(algo.isDefined().second))
62  {
63  std::string msg = std::string("\n\tDDLParser, algo requested is not defined. Either AlgoInit() or check algo spelling.\n ")
64  + "\n\t\talgo=" + std::string(getDDName(nmspace, "algo" ))
65  + "\n\t\tparent=" + std::string(myParent->getDDName(nmspace))
66  + "\n\t\tself=" + std::string(myChild->getDDName(nmspace));
67  throwError(msg);
68  }
69 
70  // set the parameters for the algorithm
71 
72  // First for ParE type
73  parE_type parE;
74  for (size_t i = 0; i < myParE->size(); ++i)
75  {
76  atts = myParE->getAttributeSet(i);
77  // find vname in ParE.
78  parE_type::iterator existingName=parE.find(atts.find("name")->second);
79 
80  // if found, get std::vector, then add this value to it.
81  // if not found, add this var, then add a value to it.
82  if (existingName != parE.end())
83  existingName->second.push_back(ev.eval(nmspace,atts.find("value")->second));
84  // tvect = existingName->second;
85  else
86  {
87  std::vector<double> tvect;
88  tvect.push_back(ev.eval(nmspace,atts.find("value")->second));
89  parE[atts.find("name")->second] = tvect;
90  }
91  }
92 
93  // Now for ParS type
94  parS_type parS;
95 
96  for (size_t i = 0; i < myParS->size(); ++i)
97  {
98  atts = myParS->getAttributeSet(i);
99 
100  // find vname in ParS.
101  parS_type::iterator existingName=parS.find(atts.find("name")->second);
102 
103  // if found, get std::vector, then add this value to it.
104  // if not found, add this var, then add a value to it.
105 
106  if (existingName != parS.end())
107  existingName->second.push_back(atts.find("value")->second);
108  else
109  {
110  std::vector<std::string> tvect;
111  tvect.push_back(atts.find("value")->second);
112  parS[atts.find("name")->second] = tvect;
113  }
114  }
115 
116  algo.setParameters(st,ed,ic,parS,parE);
117  // for efficiency, I do not want to make a DDAlgoPositioner every time this is called.
118  // so DDCompactView must have a way to position inside itself as well.
119  cpv.algoPosPart(self, parent, algo);
120  // ap_(self, parent, algo);
121  // clear all "children" and attributes
122  myChild->clear();
123  myParent->clear();
124  myParS->clear();
125  myParE->clear();
126  // after an AlgoPosPart, we are sure it can be cleared.
127  clear();
128 
129  DCOUT_V('P', "DDLAlgoPosPart::processElement completed");
130 }
int i
Definition: DBlmapReader.cc:9
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
void algoPosPart(const DDLogicalPart &self, const DDLogicalPart &parent, DDAlgo &algo)
positioning...
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a &quot;row&quot; of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:79
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
Definition: DDAlgo.h:17
const std::string & parent(void) const
access to parent element name
std::map< std::string, std::vector< std::string > > parS_type
Definition: DDAlgoPar.h:9
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
static value_type & instance()
virtual size_t size(void) const
Number of elements accumulated.
Interface of an Expression Evaluator.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
virtual double eval(const std::string &ns, const std::string &expr)=0
evaluate an expression expr inside the local namespace
std::map< std::string, std::vector< double > > parE_type
Definition: DDAlgoPar.h:12
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:86