CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes
DDName Class Reference

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

#include <DDName.h>

Public Types

using id_type = int
 
using IdToName = tbb::concurrent_vector< Registry::const_iterator >
 
using key_type = std::pair< const std::string, std::string >
 
using Registry = tbb::concurrent_unordered_map< key_type, id_type, edm::StdPairHasher >
 

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 ()
 
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...
 
bool operator< (const DDName &rhs) const
 
bool operator== (const DDName &rhs) const
 

Static Private Member Functions

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

Private Attributes

id_type id_
 

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

Member Typedef Documentation

◆ id_type

using DDName::id_type = int

Definition at line 19 of file DDName.h.

◆ IdToName

using DDName::IdToName = tbb::concurrent_vector<Registry::const_iterator>

Definition at line 22 of file DDName.h.

◆ key_type

using DDName::key_type = std::pair<const std::string, std::string>

Definition at line 20 of file DDName.h.

◆ Registry

using DDName::Registry = tbb::concurrent_unordered_map<key_type, id_type, edm::StdPairHasher>

Definition at line 21 of file DDName.h.

Constructor & Destructor Documentation

◆ DDName() [1/5]

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

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

◆ DDName() [2/5]

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

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

Definition at line 18 of file DDName.cc.

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

18  : id_(0) {
19  std::pair<std::string, std::string> result = DDSplit(name);
20  if (result.second.empty()) {
21  id_ = registerName(std::make_pair(result.first, DDCurrentNamespace::ns()))->second;
22  } else {
23  id_ = registerName(result)->second;
24  }
25 }
static std::string & ns()
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
static Registry::const_iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:67
id_type id_
Definition: DDName.h:51
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3

◆ DDName() [3/5]

DDName::DDName ( const char *  name)

Definition at line 27 of file DDName.cc.

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

27  : id_(0) {
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  } else {
32  id_ = registerName(result)->second;
33  }
34 }
static std::string & ns()
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
static Registry::const_iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:67
id_type id_
Definition: DDName.h:51
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3

◆ DDName() [4/5]

DDName::DDName ( const char *  name,
const char *  ns 
)

Definition at line 36 of file DDName.cc.

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

◆ DDName() [5/5]

DDName::DDName ( )
explicit

Definition at line 39 of file DDName.cc.

39 : id_(0) {}
id_type id_
Definition: DDName.h:51

Member Function Documentation

◆ fullname()

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

References name(), and ns().

Referenced by ListIds::analyze(), TGeoMgrFromDdd::createMaterial(), TGeoMgrFromDdd::createShape(), TGeoMgrFromDdd::createVolume(), DDCheckMaterial(), DDCompareBoolSol(), DDCompareCPV(), DDCompareDDRot(), DDCompareLP(), DDCompareSolid(), DDHtmlRoDetails::details(), DDErrorDetection::lp_cpv(), and DDFilteredView::material().

43 { return ns() + ":" + name(); }
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52

◆ id()

id_type DDName::id ( ) const
inline

Definition at line 45 of file DDName.h.

References id_.

45 { return id_; }
id_type id_
Definition: DDName.h:51

◆ name()

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

Returns the name.

Definition at line 41 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(), DDG4SolidConverter::box(), HcalTB06BeamParametersFromDD::build(), EcalSimParametersFromDD::build(), MuonOffsetFromDD::build(), GEMGeometryBuilder::build(), MagGeoBuilderFromDDD::build(), ME0GeometryParsFromDD::buildChamber(), GEMGeometryParsFromDD::buildChamber(), ME0GeometryBuilder::buildChamber(), GEMGeometryBuilder::buildChamber(), ME0GeometryParsFromDD::buildEtaPartition(), GEMGeometryParsFromDD::buildEtaPartition(), ME0GeometryBuilder::buildEtaPartition(), GEMGeometryBuilder::buildEtaPartition(), ME0GeometryParsFromDD::buildGeometry(), RPCGeometryBuilder::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), GEMGeometryParsFromDD::buildGeometry(), ME0GeometryBuilder::buildGeometry(), ME0GeometryParsFromDD::buildLayer(), ME0GeometryBuilder::buildLayer(), GEMGeometryParsFromDD::buildSuperChamber(), GEMGeometryBuilder::buildSuperChamber(), DDDividedGeometryObject::checkNDivAndWidth(), DDG4SolidConverter::cons(), DDG4Builder::convertMaterial(), TGeoMgrFromDdd::createMaterial(), TGeoMgrFromDdd::createShape(), TGeoMgrFromDdd::createVolume(), DDG4SolidConverter::cuttubs(), DDCheckAll(), DDCheckMaterial(), DDCompareEPV(), DDName(), DDrot(), DDrotReflect(), DDHtmlLpDetails::details(), DDHtmlMaDetails::details(), validation.Sample::digest(), DDG4SolidConverter::ellipticaltube(), DDTBH4Algo::execute(), DDTIDRingAlgo::execute(), DDCutTubsFromPoints::execute(), DDPixBarLayerAlgo::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDTIBLayerAlgo::execute(), DDHCalForwardAlgo::execute(), DDPixFwdBladesNew::execute(), DDTECModuleAlgo::execute(), DDEcalBarrelNewAlgo::execute(), DDEcalBarrelAlgo::execute(), DDPixFwdBlades::execute(), DDG4SolidConverter::extrudedpolygon(), fullname(), VIDSelectorBase.VIDSelectorBase::initialize(), DDG4SolidConverter::intersection(), HGCalGeomParameters::loadGeometryHexagon(), DDDividedConsRho::makeDDLogicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedTubsPhi::makeDDRotation(), DDDividedConsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDLDivision::makeDivider(), DDFilteredView::name(), DDG4SolidConverter::polycone_rrz(), DDG4SolidConverter::polycone_rz(), DDG4SolidConverter::polyhedra_rrz(), DDG4SolidConverter::polyhedra_rz(), DDLPosPart::processElement(), DDLDivision::processElement(), DDLCompositeMaterial::processElement(), DDG4SolidConverter::sphere(), DDG4SolidConverter::subtraction(), DDG4SolidConverter::torus(), DDG4SolidConverter::trap(), DDG4SolidConverter::tubs(), DDG4SolidConverter::unionsolid(), MagGeoBuilderFromDDD::volumeHandle::volumeHandle(), DDEcalBarrelAlgo::web(), and DDEcalBarrelNewAlgo::web().

41  {
42  const static std::string ano_("anonymous");
43  const std::string* result;
44  if (id_ == 0) {
45  result = &ano_;
46  } else {
48  }
49  return *result;
50 }
static value_type & instance()
id_type id_
Definition: DDName.h:51

◆ ns()

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

Returns the namespace.

Definition at line 52 of file DDName.cc.

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

Referenced by DDCheckAll(), DDCheckMaterial(), DDHtmlLpDetails::details(), DDHtmlMaDetails::details(), DDCutTubsFromPoints::execute(), fullname(), DDDividedBoxX::makeDDLogicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedConsRho::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedTubsPhi::makeDDRotation(), DDDividedConsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDLDivision::makeDivider(), DDLPosPart::processElement(), DDLDivision::processElement(), and DDLCompositeMaterial::processElement().

52  {
53  const static std::string ano_("anonymous");
54  const std::string* result;
55  if (id_ == 0) {
56  result = &ano_;
57  } else {
58  result = &DDI::Singleton<IdToName>::instance()[id_]->first.second;
59  }
60  return *result;
61 }
static value_type & instance()
id_type id_
Definition: DDName.h:51

◆ operator<()

bool DDName::operator< ( const DDName rhs) const
inline

Definition at line 47 of file DDName.h.

References id_.

47 { return id_ < rhs.id_; }
id_type id_
Definition: DDName.h:51

◆ operator==()

bool DDName::operator== ( const DDName rhs) const
inline

Definition at line 48 of file DDName.h.

References id_.

48 { return id_ == rhs.id_; }
id_type id_
Definition: DDName.h:51

◆ registerName()

DDName::Registry::const_iterator DDName::registerName ( const std::pair< std::string, std::string > &  s)
staticprivate

Definition at line 67 of file DDName.cc.

References first, DDI::Singleton< I >::instance(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by DDName().

67  {
68  std::call_once(s_once, []() {
71  reg.emplace(std::make_pair(std::string(""), std::string("")), 0);
72  idToName.emplace_back(reg.begin());
73  });
75 
76  Registry::const_iterator itFound = reg.find(nm);
77  if (itFound == reg.end()) {
78  //If two threads are concurrently adding the same name we will get
79  // two entries in IdToName but they will both point to the same entry
80  // to Registry where the first emplace to Registry will set the ID number.
82  auto it = idToName.emplace_back(reg.end());
83  *it = reg.emplace(nm, it - idToName.begin()).first;
84  itFound = *it;
85  }
86  return itFound;
87 }
tbb::concurrent_unordered_map< key_type, id_type, edm::StdPairHasher > Registry
Definition: DDName.h:21
static value_type & instance()
tbb::concurrent_vector< Registry::const_iterator > IdToName
Definition: DDName.h:22

Member Data Documentation

◆ id_

id_type DDName::id_
private

Definition at line 51 of file DDName.h.

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