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 | Static Public Member Functions | Static Private Member Functions | Private Attributes | Friends
DDName Class Reference

DDName is used to identify DDD entities uniquely. More...

#include <DDName.h>

Public Types

typedef DDCurrentNamespace CNS
 
typedef int id_type
 
typedef std::vector
< Registry::const_iterator > 
IdToName
 
typedef std::map< std::pair
< std::string, std::string >
, id_type
Registry
 

Public Member Functions

 DDName (const std::string &name, const std::string &ns)
 Constructs a DDName with name name and assigns name to the namespace ns. More...
 
 DDName (const std::string &name)
 Creates a DDName with name in the current namespace defined in the singleton DDCurrentNamespace. More...
 
 DDName (const char *name)
 
 DDName (const char *name, const char *ns)
 
 DDName (id_type)
 
 DDName ()
 
const std::string fullname () const
 
id_type id () const
 
const std::string & name () const
 Returns the name. More...
 
const std::string & ns () const
 Returns the namespace. More...
 
 operator std::string () const
 
bool operator< (const DDName &rhs) const
 
bool operator== (const DDName &rhs) const
 

Static Public Member Functions

static void defineId (const std::pair< std::string, std::string > &, id_type id)
 register pre-defined ids More...
 
static bool exists (const std::string &name, const std::string &ns)
 true, if a DDName with given name and namespace (ns) already is registerd, otherwise false More...
 

Static Private Member Functions

static Registry::iterator registerName (const std::pair< std::string, std::string > &s)
 

Private Attributes

id_type id_
 

Friends

class DStreamer
 

Detailed Description

DDName is used to identify DDD entities uniquely.

A DDName consists of a name and a namespace. Both are represented as std::string.

Definition at line 18 of file DDName.h.

Member Typedef Documentation

Definition at line 24 of file DDName.h.

typedef int DDName::id_type

Definition at line 25 of file DDName.h.

typedef std::vector<Registry::const_iterator> DDName::IdToName

Definition at line 27 of file DDName.h.

typedef std::map<std::pair<std::string,std::string>,id_type> DDName::Registry

Definition at line 26 of file DDName.h.

Constructor & Destructor Documentation

DDName::DDName ( const std::string &  name,
const std::string &  ns 
)

Constructs a DDName with name name and assigns name to the namespace ns.

Definition at line 19 of file DDName.cc.

20  : id_(registerName(std::make_pair(name,ns))->second)
21 { }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
U second(std::pair< T, U > const &p)
id_type id_
Definition: DDName.h:67
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:124
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
DDName::DDName ( const std::string &  name)

Creates a DDName with name in the current namespace defined in the singleton DDCurrentNamespace.

Definition at line 24 of file DDName.cc.

References DDSplit(), id_, DDCurrentNamespace::ns(), registerName(), and query::result.

25  : id_(0)
26 {
27  std::pair<std::string,std::string> result = DDSplit(name);
28  if (result.second == "") {
29  id_ = registerName(std::make_pair(result.first,DDCurrentNamespace::ns()))->second;
30  }
31  else {
32  id_ = registerName(result)->second;
33  }
34 }
static std::string & ns()
tuple result
Definition: query.py:137
id_type id_
Definition: DDName.h:67
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:124
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
DDName::DDName ( const char *  name)

Definition at line 37 of file DDName.cc.

References DDSplit(), id_, DDCurrentNamespace::ns(), registerName(), and query::result.

38  : id_(0)
39 {
40  std::pair<std::string,std::string> result = DDSplit(name);
41  if (result.second == "") {
42  id_ = registerName(std::make_pair(result.first,DDCurrentNamespace::ns()))->second;
43  }
44  else {
45  id_ = registerName(result)->second;
46  }
47 }
static std::string & ns()
tuple result
Definition: query.py:137
id_type id_
Definition: DDName.h:67
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:124
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
DDName::DDName ( const char *  name,
const char *  ns 
)

Definition at line 50 of file DDName.cc.

51  : id_(registerName(std::make_pair(std::string(name),std::string(ns)))->second)
52 { }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
U second(std::pair< T, U > const &p)
id_type id_
Definition: DDName.h:67
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:124
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
DDName::DDName ( DDName::id_type  id)

Definition at line 59 of file DDName.cc.

60  : id_(id)
61 { }
id_type id_
Definition: DDName.h:67
DDName::DDName ( )
explicit

Definition at line 55 of file DDName.cc.

56  : id_(0)
57 { }
id_type id_
Definition: DDName.h:67

Member Function Documentation

void DDName::defineId ( const std::pair< std::string, std::string > &  nm,
DDName::id_type  id 
)
static

register pre-defined ids

Definition at line 63 of file DDName.cc.

References edm::hlt::Exception, first, id(), DDI::Singleton< I >::instance(), and alignCSCRings::s.

Referenced by DDStreamer::names_read().

64 {
66 
67  /*
68  Semantics:
69  If id exists && the registered value matches the given one, do nothing
70  If id exists && the registered value DOES NOT match, throw
71  If id DOES NOT exists, register with the given value
72  */
73  if ( id < id_type(id2n.size()) ) {
74  if(id2n[id]->first != nm) {
75  std::stringstream s;
76  s << id;
77  throw cms::Exception("DDException") << "DDName::DDName(std::pair<std::string,std::string>,id_type): id=" + s.str() + " reg-name=?";
78  }
79  }
80  else {
81  id2n.resize(id+1);
83  id2n[id] = DDI::Singleton<Registry>::instance().find(nm);
84  }
85 }
id_type id() const
Definition: DDName.h:61
static value_type & instance()
bool first
Definition: L1TdeRCT.cc:94
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:27
int id_type
Definition: DDName.h:25
bool DDName::exists ( const std::string &  name,
const std::string &  ns 
)
static

true, if a DDName with given name and namespace (ns) already is registerd, otherwise false

Definition at line 116 of file DDName.cc.

References DDI::Singleton< I >::instance(), and AlCaHLTBitMon_ParallelJobs::p.

117 {
118  const std::pair<std::string,std::string> p(name,ns);
119  Registry::const_iterator it = DDI::Singleton<Registry>::instance().find(p);
120  return it != DDI::Singleton<Registry>::instance().end() ? true : false;
121 }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
static value_type & instance()
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
const std::string DDName::fullname ( ) const
inline

Returns a string complete of the namespace and name separated by ":". Most likely you want to use ns() and / or name() methods instead.

Definition at line 56 of file DDName.h.

References name(), and ns().

Referenced by TGeoMgrFromDdd::createMaterial(), TGeoFromDddService::createMaterial(), TGeoMgrFromDdd::createShape(), TGeoFromDddService::createShape(), TGeoMgrFromDdd::createVolume(), TGeoFromDddService::createVolume(), DDHtmlMaDetails::details(), DDHtmlRoDetails::details(), DDEcalEndcapAlgo::EEPositionCRs(), DDEcalEndcapAlgo::execute(), DDErrorDetection::lp_cpv(), DDCompareCPV::operator()(), DDCompareLP::operator()(), DDCompareSolid::operator()(), DDCompareBoolSol::operator()(), DDCompareDDRot::operator()(), and DDG4SolidConverter::trunctubs().

56 { return ns() + ":" + name(); }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
id_type DDName::id ( void  ) const
inline

Definition at line 61 of file DDName.h.

References id_.

Referenced by defineId(), nameout(), and operator<<().

61 { return id_;}
id_type id_
Definition: DDName.h:67
const std::string & DDName::name ( ) const

Returns the name.

Definition at line 87 of file DDName.cc.

References id_, DDI::Singleton< I >::instance(), and query::result.

Referenced by DDEcalEndcapAlgo::addTmp(), DDCompactView::algoPosPart(), MaterialForOnline::beginRun(), DDG4SolidConverter::box(), MagGeoBuilderFromDDD::build(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), DDG4SolidConverter::cons(), DDHCalBarrelAlgo::constructInsideDetectors(), DDHCalEndcapAlgo::constructInsideModule(), DDHCalEndcapAlgo::constructInsideModule0(), DDG4Builder::convertLV(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createShape(), TGeoFromDddService::createShape(), DD_NC(), DDBox::DDBox(), DDCheckAll(), DDCheckMaterial(), DDCons::DDCons(), DDEllipsoid::DDEllipsoid(), DDEllipticalTube::DDEllipticalTube(), DDIntersection::DDIntersection(), DDOrb::DDOrb(), DDParallelepiped::DDParallelepiped(), DDPolycone::DDPolycone(), DDPolyhedra::DDPolyhedra(), DDPseudoTrap::DDPseudoTrap(), DDrot(), DDrotReflect(), DDShapelessSolid::DDShapelessSolid(), DDSphere::DDSphere(), DDSubtraction::DDSubtraction(), DDTorus::DDTorus(), DDTrap::DDTrap(), DDTruncTubs::DDTruncTubs(), DDTubs::DDTubs(), DDUnion::DDUnion(), DDHtmlLpDetails::details(), DDHtmlMaDetails::details(), DDG4SolidConverter::ellipsoid(), DDG4SolidConverter::ellipticaltube(), DDTIBLayerAlgo_MTCC::execute(), DDHCalForwardAlgo::execute(), DDPixBarLayerAlgo::execute(), DDTIBLayerAlgo::execute(), DDTECModuleAlgo::execute(), DDTIDRingAlgo::execute(), DDTBH4Algo::execute(), DDEcalBarrelAlgo::execute(), DDEcalBarrelNewAlgo::execute(), fullname(), HcalTB06BeamSD::getNames(), MaterialBudgetHcalHistos::getNames(), HCalSD::getNames(), HCalSD::HCalSD(), HcalTB06BeamSD::HcalTB06BeamSD(), DreamSD::initMap(), ECalSD::initMap(), HcalTB02SD::initMap(), DDG4SolidConverter::intersection(), CmsTrackerDebugNavigator::iterate(), DDDividedConsRho::makeDDLogicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDLDivision::makeDivider(), nameout_strings(), operator std::string(), DDCompareEPV::operator()(), operator<<(), DDG4SolidConverter::orb(), DDG4SolidConverter::para(), DDG4SolidConverter::polycone_rrz(), DDG4SolidConverter::polycone_rz(), DDG4SolidConverter::polyhedra_rrz(), DDG4SolidConverter::polyhedra_rz(), DDLDivision::processElement(), DDLPosPart::processElement(), DDLRotationByAxis::processElement(), DDLCompositeMaterial::processElement(), DDG4SolidConverter::pseudotrap(), PGeometricDetBuilder::putOne(), GeometricDetLoader::putOne(), CocoaAnalyzer::ReadXMLFile(), DDG4SolidConverter::reflected(), DDG4SolidConverter::sphere(), DDG4SolidConverter::subtraction(), DDG4SolidConverter::torus(), DDG4SolidConverter::trap(), DDG4SolidConverter::trunctubs(), DDG4SolidConverter::tubs(), DDG4SolidConverter::unionsolid(), PrintGeomInfoAction::update(), Vispa.Views.PropertyView.Property::valueChanged(), MagGeoBuilderFromDDD::volumeHandle::volumeHandle(), DDEcalBarrelAlgo::web(), and DDEcalBarrelNewAlgo::web().

88 {
89  static std::string ano_("anonymous");
90  const std::string * result;
91  if (id_ < 0) {
92  result = &ano_;
93  }
94  else {
95  result = &DDI::Singleton<IdToName>::instance()[id_]->first.first;
96  }
97  return *result;
98 }
static value_type & instance()
tuple result
Definition: query.py:137
id_type id_
Definition: DDName.h:67
const std::string & DDName::ns ( ) const

Returns the namespace.

Definition at line 101 of file DDName.cc.

References id_, DDI::Singleton< I >::instance(), and query::result.

Referenced by DDCompactView::algoPosPart(), DD_NC(), DDBox::DDBox(), DDCheckAll(), DDCheckMaterial(), DDCons::DDCons(), DDEllipsoid::DDEllipsoid(), DDEllipticalTube::DDEllipticalTube(), DDIntersection::DDIntersection(), DDOrb::DDOrb(), DDParallelepiped::DDParallelepiped(), DDPolycone::DDPolycone(), DDPolyhedra::DDPolyhedra(), DDPseudoTrap::DDPseudoTrap(), DDShapelessSolid::DDShapelessSolid(), DDSphere::DDSphere(), DDSubtraction::DDSubtraction(), DDTorus::DDTorus(), DDTrap::DDTrap(), DDTruncTubs::DDTruncTubs(), DDTubs::DDTubs(), DDUnion::DDUnion(), DDHtmlLpDetails::details(), DDHtmlMaDetails::details(), fullname(), hierarchy(), DDDividedConsRho::makeDDLogicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedTubsPhi::makeDDRotation(), DDDividedConsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDLDivision::makeDivider(), nameout_strings(), operator std::string(), operator<<(), DDLDivision::processElement(), DDLPosPart::processElement(), DDLCompositeMaterial::processElement(), and PGeometricDetBuilder::putOne().

102 {
103  static std::string ano_("anonymous");
104  const std::string * result;
105  if (id_ < 0) {
106  result = &ano_;
107  }
108  else {
109  result = &DDI::Singleton<IdToName>::instance()[id_]->first.second;
110  }
111  return *result;
112 }
static value_type & instance()
tuple result
Definition: query.py:137
id_type id_
Definition: DDName.h:67
DDName::operator std::string ( ) const
inline

Definition at line 59 of file DDName.h.

References name(), and ns().

59 { return ns() + ":" + name(); }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
bool DDName::operator< ( const DDName rhs) const
inline

Definition at line 63 of file DDName.h.

References id_.

63 { return id_ < rhs.id_; }
id_type id_
Definition: DDName.h:67
bool DDName::operator== ( const DDName rhs) const
inline

Definition at line 64 of file DDName.h.

References id_.

64 { return id_ == rhs.id_; }
id_type id_
Definition: DDName.h:67
DDName::Registry::iterator DDName::registerName ( const std::pair< std::string, std::string > &  s)
staticprivate

Definition at line 124 of file DDName.cc.

References DDI::Singleton< I >::instance(), and query::result.

Referenced by DDName().

124  {
127  Registry::size_type sz = reg_.size();
128  if (!sz) {
129  reg_[std::make_pair(std::string(""),std::string(""))] = 0;
130  idToName.push_back(reg_.begin());
131  ++sz;
132  }
133  Registry::value_type val(nm, sz);
134  std::pair<Registry::iterator,bool> result = reg_.insert(val);
135  if (result.second) {
136  idToName.push_back(result.first);
137  }
138  return result.first;
139 }
uint16_t size_type
std::map< std::pair< std::string, std::string >, id_type > Registry
Definition: DDName.h:26
static value_type & instance()
tuple result
Definition: query.py:137
Container::value_type value_type
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:27

Friends And Related Function Documentation

friend class DStreamer
friend

Definition at line 20 of file DDName.h.

Member Data Documentation

id_type DDName::id_
private

Definition at line 67 of file DDName.h.

Referenced by DDName(), id(), name(), ns(), operator<(), and operator==().