Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:31

0001 #ifndef DETECTOR_DESCRIPTION_PARSER_DDL_ELEMENT_REGISTRY_H
0002 #define DETECTOR_DESCRIPTION_PARSER_DDL_ELEMENT_REGISTRY_H
0003 
0004 #include "DetectorDescription/Core/interface/ClhepEvaluator.h"
0005 
0006 #include <CLHEP/Evaluator/Evaluator.h>
0007 #include <string>
0008 #include <map>
0009 #include <memory>
0010 
0011 class DDXMLElement;
0012 
0013 /// The main class for processing parsed elements.
0014 /** \class DDLElementRegistry
0015  *                                                                         
0016  *  This class is designed to serve as a registry of all DDL XML elements.
0017  *
0018  *  This class is responsible for constructing and destructing
0019  *  any necessary DDL element.
0020  *
0021  */
0022 
0023 class DDLElementRegistry {
0024 public:
0025   typedef std::map<std::string, std::shared_ptr<DDXMLElement> > RegistryMap;
0026 
0027   DDLElementRegistry();
0028 
0029   ~DDLElementRegistry();
0030 
0031   /// This allows other Elements to register themselves with the static registry
0032   void registerElement(const std::string& name, DDXMLElement*);
0033 
0034   /// THE most important part.  Getting the pointer to a given element type.
0035   /**
0036    *  If this is called with a DDXMLElementRegistry pointer, it will simply
0037    *  return a pointer if already registered or NULL, no instantiating.
0038    *
0039    */
0040   std::shared_ptr<DDXMLElement> getElement(const std::string& name);
0041 
0042   ClhepEvaluator& evaluator() { return evaluator_; }
0043 
0044 private:
0045   RegistryMap registry_;
0046   ClhepEvaluator evaluator_;
0047 };
0048 
0049 #endif