CMS 3D CMS Logo

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_typeRegistry
 

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 15 of file DDName.h.

Member Typedef Documentation

Definition at line 21 of file DDName.h.

typedef int DDName::id_type

Definition at line 22 of file DDName.h.

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

Definition at line 24 of file DDName.h.

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

Definition at line 23 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 20 of file DDName.cc.

21  : id_(registerName(std::make_pair(name,ns))->second)
22 { }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:102
U second(std::pair< T, U > const &p)
id_type id_
Definition: DDName.h:63
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:125
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
DDName::DDName ( const std::string &  name)

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

Definition at line 25 of file DDName.cc.

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

26  : id_(0)
27 {
28  std::pair<std::string,std::string> result = DDSplit(name);
29  if (result.second.empty()) {
30  id_ = registerName(std::make_pair(result.first,DDCurrentNamespace::ns()))->second;
31  }
32  else {
33  id_ = registerName(result)->second;
34  }
35 }
static std::string & ns()
id_type id_
Definition: DDName.h:63
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:125
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
DDName::DDName ( const char *  name)

Definition at line 38 of file DDName.cc.

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

39  : id_(0)
40 {
41  std::pair<std::string,std::string> result = DDSplit(name);
42  if (result.second.empty()) {
43  id_ = registerName(std::make_pair(result.first,DDCurrentNamespace::ns()))->second;
44  }
45  else {
46  id_ = registerName(result)->second;
47  }
48 }
static std::string & ns()
id_type id_
Definition: DDName.h:63
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:125
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
DDName::DDName ( const char *  name,
const char *  ns 
)

Definition at line 51 of file DDName.cc.

52  : id_(registerName(std::make_pair(std::string(name),std::string(ns)))->second)
53 { }
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:102
U second(std::pair< T, U > const &p)
id_type id_
Definition: DDName.h:63
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:125
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
DDName::DDName ( DDName::id_type  id)

Definition at line 60 of file DDName.cc.

61  : id_(id)
62 { }
id_type id_
Definition: DDName.h:63
DDName::DDName ( )
explicit

Definition at line 56 of file DDName.cc.

Referenced by DDNameInterface::ddname().

57  : id_(0)
58 { }
id_type id_
Definition: DDName.h:63

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 64 of file DDName.cc.

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

65 {
67 
68  /*
69  Semantics:
70  If id exists && the registered value matches the given one, do nothing
71  If id exists && the registered value DOES NOT match, throw
72  If id DOES NOT exists, register with the given value
73  */
74  if ( id < id_type(id2n.size()) ) {
75  if(id2n[id]->first != nm) {
76  std::stringstream s;
77  s << id;
78  throw cms::Exception("DDException") << "DDName::DDName(std::pair<std::string,std::string>,id_type): id=" + s.str() + " reg-name=?";
79  }
80  }
81  else {
82  id2n.resize(id+1);
84  id2n[id] = DDI::Singleton<Registry>::instance().find(nm);
85  }
86 }
id_type id() const
Definition: DDName.h:57
static value_type & instance()
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:24
int id_type
Definition: DDName.h:22
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 117 of file DDName.cc.

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

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

Definition at line 57 of file DDName.h.

References id_.

Referenced by DDNameInterface::ddname(), and defineId().

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

Returns the name.

Definition at line 88 of file DDName.cc.

References id_, DDI::Singleton< I >::instance(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by config.CFG::__str__(), PrintGeomSummary::addSolid(), DDEcalEndcapAlgo::addTmp(), CTPPSGeometryESModule::applyAlignments(), DDG4SolidConverter::box(), GEMGeometryBuilderFromDDD::build(), CTPPSGeometry::build(), MagGeoBuilderFromDDD::build(), ME0GeometryParsFromDD::buildChamber(), ME0GeometryBuilderFromDDD::buildChamber(), GEMGeometryParsFromDD::buildChamber(), GEMGeometryBuilderFromDDD::buildChamber(), CTPPSGeometryESModule::buildDetGeomDesc(), ME0GeometryParsFromDD::buildEtaPartition(), GEMGeometryParsFromDD::buildEtaPartition(), ME0GeometryBuilderFromDDD::buildEtaPartition(), GEMGeometryBuilderFromDDD::buildEtaPartition(), ME0GeometryParsFromDD::buildGeometry(), ME0GeometryBuilderFromDDD::buildGeometry(), GEMGeometryParsFromDD::buildGeometry(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), ME0GeometryParsFromDD::buildLayer(), ME0GeometryBuilderFromDDD::buildLayer(), GEMGeometryParsFromDD::buildSuperChamber(), GEMGeometryBuilderFromDDD::buildSuperChamber(), DDDividedGeometryObject::checkNDivAndWidth(), DDG4SolidConverter::cons(), DDHCalBarrelAlgo::constructInsideDetectors(), DDHCalEndcapAlgo::constructInsideModule(), DDHCalEndcapAlgo::constructInsideModule0(), DDG4Builder::convertLV(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createShape(), TGeoFromDddService::createShape(), DDG4SolidConverter::cuttubs(), DD_NC(), DDBox::DDBox(), DDCheckAll(), DDCheckMaterial(), DDCons::DDCons(), DDCutTubs::DDCutTubs(), DDEllipticalTube::DDEllipticalTube(), DDExtrudedPolygon::DDExtrudedPolygon(), DDIntersection::DDIntersection(), DDNameInterface::ddname(), 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(), validation.Sample::digest(), DDG4SolidConverter::ellipticaltube(), DDTIBLayerAlgo::execute(), DDHCalForwardAlgo::execute(), DDTIBLayerAlgo_MTCC::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDPixBarLayerAlgo::execute(), DDTIDRingAlgo::execute(), DDTECModuleAlgo::execute(), DDCutTubsFromPoints::execute(), DDTBH4Algo::execute(), DDEcalBarrelAlgo::execute(), DDEcalBarrelNewAlgo::execute(), DDG4SolidConverter::extrudedpolygon(), fullname(), HcalTB06BeamSD::getNames(), MaterialBudgetHcalHistos::getNames(), HCalSD::getNames(), HCalSD::HCalSD(), HcalTB06BeamSD::HcalTB06BeamSD(), VIDSelectorBase.VIDSelectorBase::initialize(), DreamSD::initMap(), HcalTB02SD::initMap(), ECalSD::initMap(), DDG4SolidConverter::intersection(), CmsTrackerDebugNavigator::iterate(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedConsRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDLDivision::makeDivider(), operator std::string(), DDCompareEPV::operator()(), operator<<(), DDG4SolidConverter::polycone_rrz(), DDG4SolidConverter::polycone_rz(), DDG4SolidConverter::polyhedra_rrz(), DDG4SolidConverter::polyhedra_rz(), DDLRotationByAxis::processElement(), DDLDivision::processElement(), DDLPosPart::processElement(), DDLCompositeMaterial::processElement(), DDG4SolidConverter::pseudotrap(), GeometricDetLoader::putOne(), PGeometricDetBuilder::putOne(), CocoaAnalyzer::ReadXMLFile(), 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(), DDEcalBarrelNewAlgo::web(), and DDNameInterface::~DDNameInterface().

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

Returns the namespace.

Definition at line 102 of file DDName.cc.

References id_, DDI::Singleton< I >::instance(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by DD_NC(), DDBox::DDBox(), DDCheckAll(), DDCheckMaterial(), DDCons::DDCons(), DDCutTubs::DDCutTubs(), DDEllipticalTube::DDEllipticalTube(), DDExtrudedPolygon::DDExtrudedPolygon(), DDIntersection::DDIntersection(), DDNameInterface::ddname(), 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(), DDCutTubsFromPoints::execute(), fullname(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedConsRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDLDivision::makeDivider(), operator std::string(), operator<<(), DDLDivision::processElement(), DDLPosPart::processElement(), DDLCompositeMaterial::processElement(), PGeometricDetBuilder::putOne(), and DDNameInterface::~DDNameInterface().

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

Definition at line 55 of file DDName.h.

References name(), and ns().

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

Definition at line 59 of file DDName.h.

References id_.

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

Definition at line 60 of file DDName.h.

References id_.

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

Definition at line 125 of file DDName.cc.

References DDI::Singleton< I >::instance(), mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, and heppy_batch::val.

Referenced by DDName().

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

Friends And Related Function Documentation

friend class DStreamer
friend

Definition at line 17 of file DDName.h.

Member Data Documentation

id_type DDName::id_
private

Definition at line 63 of file DDName.h.

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