test
CMS 3D CMS Logo

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

The main class for processing parsed elements. More...

#include <DDLElementRegistry.h>

Public Types

typedef std::map< std::string,
DDXMLElement * > 
RegistryMap
 

Public Member Functions

 DDLElementRegistry ()
 
ClhepEvaluatorevaluator ()
 
DDXMLElementgetElement (const std::string &name)
 THE most important part. Getting the pointer to a given element type. More...
 
const std::string & getElementName (DDXMLElement *theElement) const
 Get the name given a pointer. This may not be needed... More...
 
void registerElement (const std::string &name, DDXMLElement *)
 This allows other Elements to register themselves with the static registry. More...
 
 ~DDLElementRegistry ()
 

Private Attributes

RegistryMap registry_
 

Detailed Description

The main class for processing parsed elements.

DDLElementRegistry.h - description

begin : Wed Oct 24 2001 email : case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

This class is designed to serve as a registry of all DDL XML elements. It inherits from DDXMLElementRegistry.

This class is responsible for constructing and destructing any necessary DDL element.

Definition at line 32 of file DDLElementRegistry.h.

Member Typedef Documentation

typedef std::map<std::string, DDXMLElement*> DDLElementRegistry::RegistryMap

Definition at line 36 of file DDLElementRegistry.h.

Constructor & Destructor Documentation

DDLElementRegistry::DDLElementRegistry ( void  )

Definition at line 51 of file DDLElementRegistry.cc.

52 {}
DDLElementRegistry::~DDLElementRegistry ( void  )

Definition at line 54 of file DDLElementRegistry.cc.

References end, spr::find(), and registry_.

55 {
56  // Complicated cleanup. I keep track of DDXMLElements that have
57  // already been deleted using this vector. Then delete them one-by-one.
58  std::vector<DDXMLElement*> toDelete;
59  for( RegistryMap::const_iterator it = registry_.begin(), end = registry_.end(); it != end; ++it )
60  {
61  std::vector<DDXMLElement*>::const_iterator deleteIt = std::find( toDelete.begin(), toDelete.end(), it->second );
62  if( deleteIt == toDelete.end())
63  {
64  toDelete.push_back( it->second );
65  delete it->second;
66  }
67  }
68 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
#define end
Definition: vmac.h:37

Member Function Documentation

ClhepEvaluator& DDLElementRegistry::evaluator ( )
inline
DDXMLElement * DDLElementRegistry::getElement ( const std::string &  name)

THE most important part. Getting the pointer to a given element type.

If this is called with a DDXMLElementRegistry pointer, it will simply return a pointer if already registered or NULL, no instantiating.

Definition at line 74 of file DDLElementRegistry.cc.

References DCOUT_V, mergeVDriftHistosByStation::name, NULL, and registry_.

Referenced by DDLBooleanSolid::dumpBooleanSolid(), DDLAlgorithm::preProcessElement(), DDLReflectionSolid::preProcessElement(), DDLRotationSequence::preProcessElement(), DDLPosPart::preProcessElement(), DDLBooleanSolid::preProcessElement(), DDLShapelessSolid::preProcessElement(), DDLPolyGenerator::preProcessElement(), DDLCompositeMaterial::preProcessElement(), DDLLogicalPart::preProcessElement(), DDLSpecPar::processElement(), DDLReflectionSolid::processElement(), DDLAlgorithm::processElement(), DDLPolyGenerator::processElement(), DDLBooleanSolid::processElement(), DDLPosPart::processElement(), DDLRotationSequence::processElement(), DDLRotationByAxis::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLMaterial::setReference(), and DDLSolid::setReference().

75 {
76  DCOUT_V('P',"myRegistry_->getElementRegistry(" << name << ")");
77 
78  // DDXMLElement* myret = instance()->DDXMLElementRegistry::getElement(name);
79  RegistryMap::iterator it = registry_.find(name);
80  // std::cout << "it found name? "<< name << " " ;
81  // if (it != registry_.end() ) std::cout << "yes"; else std::cout << "no";
82  // std::cout << std::endl;
83  // std::cout << "there are " << registry_.size() << " elements-types so far." << std::endl;
84  DDXMLElement* myret = NULL;
85  if( it != registry_.end())
86  {
87  myret = it->second;
88  } else {
89  // std::cout << " making first and only " << name << std::endl;
90  // Make the Solid handlers and register them.
91  if (name == "Box")
92  {
93  myret = new DDLBox(this);
94  }
95  else if (name == "Cone")
96  {
97  myret = new DDLCone(this);
98  }
99  else if (name == "Polyhedra" || name == "Polycone")
100  {
101  myret = new DDLPolyGenerator(this);
102  }
103  else if (name == "Trapezoid" || name == "Trd1")
104  {
105  myret = new DDLTrapezoid(this);
106  }
107  else if (name == "PseudoTrap")
108  {
109  myret = new DDLPseudoTrap(this);
110  }
111  else if (name == "Tubs" || name == "Tube" || name == "TruncTubs")
112  {
113  myret = new DDLTubs(this);
114  }
115  else if (name == "Torus")
116  {
117  myret = new DDLTorus(this);
118  }
119  else if (name == "ReflectionSolid")
120  {
121  myret = new DDLReflectionSolid(this);
122  }
123  else if (name == "UnionSolid" || name == "SubtractionSolid"
124  || name == "IntersectionSolid")
125  {
126  myret = new DDLBooleanSolid(this);
127  }
128  else if (name == "ShapelessSolid")
129  {
130  myret = new DDLShapelessSolid(this);
131  }
132  else if (name == "Sphere")
133  {
134  myret = new DDLSphere(this);
135  }
136  else if (name == "Orb")
137  {
138  myret = new DDLOrb(this);
139  }
140  else if (name == "EllipticalTube")
141  {
142  myret = new DDLEllipticalTube(this);
143  }
144  else if (name == "Ellipsoid")
145  {
146  myret = new DDLEllipsoid(this);
147  }
148  else if (name == "Sphere")
149  {
150  myret = new DDLParallelepiped(this);
151  }
152 
153  // LogicalParts, Positioners, Materials, Rotations, Reflections
154  // and Specific (Specified?) Parameters
155  else if (name == "PosPart")
156  {
157  myret = new DDLPosPart(this);
158  }
159  else if (name == "CompositeMaterial")
160  {
161  myret = new DDLCompositeMaterial(this);
162  }
163  else if (name == "ElementaryMaterial")
164  {
165  myret = new DDLElementaryMaterial(this);
166  }
167  else if (name == "LogicalPart")
168  {
169  myret = new DDLLogicalPart(this);
170  }
171  else if (name == "ReflectionRotation" || name == "Rotation" )
172  {
173  myret = new DDLRotationAndReflection(this);
174  }
175  else if (name == "SpecPar")
176  {
177  myret = new DDLSpecPar(this);
178  }
179  else if (name == "RotationSequence")
180  {
181  myret = new DDLRotationSequence(this);
182  }
183  else if (name == "RotationByAxis")
184  {
185  myret = new DDLRotationByAxis(this);
186  }
187  // Special, need them around.
188  else if (name == "SpecParSection") {
189  myret = new DDXMLElement(this, true);
190  }
191  else if (name == "Vector") {
192  myret = new DDLVector(this);
193  }
194  else if (name == "Map") {
195  myret = new DDLMap(this);
196  }
197  else if (name == "String") {
198  myret = new DDLString(this);
199  }
200  else if (name == "Numeric") {
201  myret = new DDLNumeric(this);
202  }
203  else if (name == "Algorithm") {
204  myret = new DDLAlgorithm(this);
205  }
206  else if (name == "Division") {
207  myret = new DDLDivision(this);
208  }
209 
210  // Supporting Cast of elements.
211  // All elements which simply accumulate attributes which are then used
212  // by one of the above elements.
213  else if (name == "MaterialFraction"
214  || name == "RZPoint" || name == "PartSelector"
215  || name == "Parameter" || name == "ZSection"
216  || name == "Translation"
217  || name == "rSolid" || name == "rMaterial"
218  || name == "rParent" || name == "rChild"
219  || name == "rRotation" || name == "rReflectionRotation"
220  || name == "DDDefinition" )
221  {
222  myret = new DDXMLElement(this);
223  }
224 
225  // IF it is a new element return a default XMLElement which processes nothing.
226  // Since there are elements in the XML which require no processing, they
227  // can all use the same DDXMLElement which defaults to anything. A validated
228  // XML document (i.e. validated with XML Schema) will work properly.
229  // As of 8/16/2002: Elements like LogicalPartSection and any other *Section
230  // XML elements of the DDLSchema are taken care of by this.
231  else
232  {
233  // myret = instance()->DDXMLElementRegistry::getElement("***");
234 
235  myret = new DDXMLElement(this);
236  // std::cout << "about to register a " << "***" << std::endl;
237  // registry_["***"] = myret;
238  // DCOUT_V('P', "WARNING: The default (DDLElementRegistry) was used for "
239  // << name << " since there was no specific handler." << std::endl);
240  // return myret;
241  }
242 
243  // Actually register the thing
244  // instance()->registerElement(name, myret);
245  // std::cout << "about to register a " << name << std::endl;
246  registry_[name] = myret;
247  }
248  return myret;
249 }
DDLPosPart handles PosPart elements.
Definition: DDLPosPart.h:24
This class takes care of processing all BooleanSolid type elements.
DDLSphere processes all Sphere elements.
Definition: DDLSphere.h:24
DDLDivision processes Division elements.
Definition: DDLDivision.h:23
DDLOrb processes all Orb elements.
Definition: DDLOrb.h:24
DDLString handles String Elements.
Definition: DDLString.h:26
DDLVector handles Rotation and ReflectionRotation elements.
Definition: DDLVector.h:31
DDLReflectionSolid processes ReflectionSolid elements.
#define NULL
Definition: scimark2.h:8
DDLSpecPar processes SpecPar elements.
Definition: DDLSpecPar.h:23
DDLRotationAndReflection handles RotationCMSIM and ReflectionRotation elements.
DDLEllipticalTube processes all EllipticalTube elements.
DDLAlgorithm processes Algorithm elements.
Definition: DDLAlgorithm.h:22
DDLParallelepiped processes all Parallelepiped elements.
DDLBox processes Box elements.
Definition: DDLBox.h:24
DDLElementaryMaterial processes ElementaryMaterial elements.
DDLCone processes all Cone elements.
Definition: DDLCone.h:24
DDLEllipsoid processes all Ellipsoid elements.
Definition: DDLEllipsoid.h:24
DDLTubs processes Tubs elements.
Definition: DDLTubs.h:22
DDLPolyGenerator processes DDL XML Polycone and DDL XML Polyhedra elements.
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
DDLMap handles Map container.
Definition: DDLMap.h:58
DDLLogicalPart processes LogicalPart elements.
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
DDLRotationByAxis handles RotationByAxis elements.
DDLCompositeMaterial processes all CompositeMaterial elements.
DDLNumeric handles Numeric Elements.
Definition: DDLNumeric.h:26
DDLRotationSequence handles a set of Rotations.
DDLShapelessSolid processes ShapelessSolid elements.
const std::string & DDLElementRegistry::getElementName ( DDXMLElement theElement) const

Get the name given a pointer. This may not be needed...

Definition at line 252 of file DDLElementRegistry.cc.

References end, and registry_.

253 {
254  for( RegistryMap::const_iterator it = registry_.begin(), end = registry_.end(); it != end; ++it )
255  if( it->second == theElement )
256  return it->first;
257  return registry_.find( "***" )->first;
258 }
#define end
Definition: vmac.h:37
void DDLElementRegistry::registerElement ( const std::string &  name,
DDXMLElement  
)

This allows other Elements to register themselves with the static registry.

Member Data Documentation

RegistryMap DDLElementRegistry::registry_
private

Definition at line 58 of file DDLElementRegistry.h.

Referenced by getElement(), getElementName(), and ~DDLElementRegistry().