CMS 3D CMS Logo

DDNamespace.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DD_NAMESPACE_H
2 #define DETECTOR_DESCRIPTION_DD_NAMESPACE_H
3 
4 #include "XML/XML.h"
5 #include "DD4hep/Objects.h"
6 #include "DD4hep/Shapes.h"
7 #include "DD4hep/Volumes.h"
8 
9 namespace cms {
10 
11  class DDParsingContext;
12 
13  class DDNamespace {
14 
15  public:
16 
17  DDNamespace( DDParsingContext*, xml_h );
18  DDNamespace( DDParsingContext&, xml_h, bool );
21  ~DDNamespace();
22 
23  DDNamespace() = delete;
24  DDNamespace( const DDNamespace& ) = delete;
25  DDNamespace& operator=( const DDNamespace& ) = delete;
26 
27  std::string prepend( const std::string& ) const;
28  std::string realName( const std::string& ) const;
29  static std::string objName( const std::string& );
30  static std::string nsName( const std::string& );
31 
32  template<typename T> T attr( xml_elt_t element, const xml_tag_t& name ) const {
33  std::string val = realName( element.attr<std::string>( name ));
34  element.setAttr( name, val );
35  return element.attr<T>( name );
36  }
37 
38  template<typename T> T attr( xml_elt_t element, const xml_tag_t& name, T defaultValue ) const {
39  if( element.hasAttr( name )) {
40  std::string val = realName( element.attr<std::string>( name ));
41  element.setAttr( name, val );
42  return element.attr<T>( name );
43  }
44  return defaultValue;
45  }
46 
47  void addConstant( const std::string& name, const std::string& value, const std::string& type ) const;
48  void addConstantNS( const std::string& name, const std::string& value, const std::string& type ) const;
49 
50  dd4hep::Material material( const std::string& name ) const;
51  dd4hep::Solid solid( const std::string& name ) const;
52  dd4hep::Solid addSolid( const std::string& name, dd4hep::Solid solid ) const;
53  dd4hep::Solid addSolidNS( const std::string& name, dd4hep::Solid solid ) const;
54 
55  dd4hep::Volume volume( const std::string& name, bool exc = true ) const;
58 
59  const dd4hep::Rotation3D& rotation( const std::string& name ) const;
60  void addRotation( const std::string& name, const dd4hep::Rotation3D& rot ) const;
61 
62  DDParsingContext* const context() const { return m_context; }
64 
65  const std::string& name() const {
66  return m_name;
67  }
68 
69  private:
70 
73  bool m_pop = false;
74  };
75 }
76 
77 #define NAMESPACE_SEP ':'
78 
79 #endif
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:210
type
Definition: HCALResponse.h:21
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:189
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:160
std::string m_name
Definition: DDNamespace.h:72
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
Definition: DDNamespace.cc:175
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:227
DDParsingContext *const context() const
Definition: DDNamespace.h:62
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:108
static std::string nsName(const std::string &)
Definition: DDNamespace.cc:84
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
Definition: DDNamespace.cc:127
std::string realName(const std::string &) const
Definition: DDNamespace.cc:65
T attr(xml_elt_t element, const xml_tag_t &name) const
Definition: DDNamespace.h:32
static std::string objName(const std::string &)
Definition: DDNamespace.cc:93
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
DDNamespace & operator=(const DDNamespace &)=delete
Definition: value.py:1
DDParsingContext * m_context
Definition: DDNamespace.h:71
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:59
T attr(xml_elt_t element, const xml_tag_t &name, T defaultValue) const
Definition: DDNamespace.h:38
Namespace of DDCMS conversion namespace.
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
const std::string & name() const
Definition: DDNamespace.h:65
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:134
DDNamespace()=delete
long double T
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:102
DDParsingContext * setContext()
Definition: DDNamespace.h:63