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 ()
 
 DDName (const char *name)
 
 DDName (const char *name, const char *ns)
 
 DDName (const std::string &name)
 Creates a DDName with name in the current namespace defined in the singleton DDCurrentNamespace. More...
 
 DDName (const std::string &name, const std::string &ns)
 Constructs a DDName with name name and assigns name to the namespace ns. More...
 
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) {}

◆ 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.

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 }

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

◆ DDName() [3/5]

DDName::DDName ( const char *  name)

Definition at line 27 of file DDName.cc.

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 }

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

◆ 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) {}

◆ DDName() [5/5]

DDName::DDName ( )
explicit

Definition at line 39 of file DDName.cc.

39 : id_(0) {}

Member Function Documentation

◆ fullname()

const std::string DDName::fullname ( ) const
inline

◆ id()

id_type DDName::id ( ) const
inline

Definition at line 45 of file DDName.h.

45 { return id_; }

References id_.

◆ name()

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

Returns the name.

Definition at line 41 of file DDName.cc.

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 }

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(), HcalTB02ParametersFromDD::build(), MuonOffsetFromDD::build(), EcalSimParametersFromDD::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(), DDTIBLayerAlgo::execute(), DDPixBarLayerAlgo::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDHCalForwardAlgo::execute(), DDTECModuleAlgo::execute(), DDEcalBarrelAlgo::execute(), DDEcalBarrelNewAlgo::execute(), DDPixFwdBlades::execute(), DDG4SolidConverter::extrudedpolygon(), fullname(), VIDSelectorBase.VIDSelectorBase::initialize(), DreamSD::initMap(), DDG4SolidConverter::intersection(), HGCalGeomParameters::loadGeometryHexagon(), DDDividedConsRho::makeDDLogicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDDividedPolyconePhi::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().

◆ ns()

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

◆ operator<()

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

Definition at line 47 of file DDName.h.

47 { return id_ < rhs.id_; }

References id_.

◆ operator==()

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

Definition at line 48 of file DDName.h.

48 { return id_ == rhs.id_; }

References id_.

◆ registerName()

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

Definition at line 67 of file DDName.cc.

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 }

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

Referenced by DDName().

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==().

edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
DDName::id_
id_type id_
Definition: DDName.h:51
DDI::Singleton::instance
static value_type & instance()
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDName::registerName
static Registry::const_iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:67
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDName::ns
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDName::Registry
tbb::concurrent_unordered_map< key_type, id_type, edm::StdPairHasher > Registry
Definition: DDName.h:21
mps_fire.result
result
Definition: mps_fire.py:311
DDName::IdToName
tbb::concurrent_vector< Registry::const_iterator > IdToName
Definition: DDName.h:22
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3