DetectorDescription
Core
src
DDName.cc
Go to the documentation of this file.
1
#include "
DetectorDescription/Core/interface/DDName.h
"
2
#include "
DetectorDescription/Core/interface/DDCurrentNamespace.h
"
3
#include "
DetectorDescription/Core/interface/DDSplit.h
"
4
#include "
DetectorDescription/Core/interface/Singleton.h
"
5
6
#include <ext/alloc_traits.h>
7
#include <cstdlib>
8
#include <sstream>
9
10
std::ostream&
operator<<
(std::ostream& os,
const
DDName
&
n
) {
11
os <<
n
.ns() <<
':'
<<
n
.name();
12
return
os;
13
}
14
15
DDName::DDName
(
const
std::string
&
name
,
const
std::string
& ns) : id_(registerName(
std
::make_pair(
name
, ns))->
second
) {}
16
17
DDName::DDName
(
const
std::string
&
name
) : id_(0) {
18
std::pair<std::string, std::string>
result
=
DDSplit
(
name
);
19
if
(
result
.second.empty()) {
20
id_
=
registerName
(std::make_pair(
result
.first,
DDCurrentNamespace::ns
()))->second;
21
}
else
{
22
id_
=
registerName
(
result
)->second;
23
}
24
}
25
26
DDName::DDName
(
const
char
*
name
) : id_(0) {
27
std::pair<std::string, std::string>
result
=
DDSplit
(
name
);
28
if
(
result
.second.empty()) {
29
id_
=
registerName
(std::make_pair(
result
.first,
DDCurrentNamespace::ns
()))->second;
30
}
else
{
31
id_
=
registerName
(
result
)->second;
32
}
33
}
34
35
DDName::DDName
(
const
char
*
name
,
const
char
* ns)
36
: id_(registerName(
std
::make_pair(
std
::
string
(
name
),
std
::
string
(ns)))->
second
) {}
37
38
DDName::DDName
() : id_(0) {}
39
40
const
std::string
&
DDName::name
()
const
{
41
const
static
std::string
ano_(
"anonymous"
);
42
const
std::string
*
result
;
43
if
(
id_
== 0) {
44
result
= &ano_;
45
}
else
{
46
result
= &
DDI::Singleton<IdToName>::instance
()[
id_
]->first.first;
47
}
48
return
*
result
;
49
}
50
51
const
std::string
&
DDName::ns
()
const
{
52
const
static
std::string
ano_(
"anonymous"
);
53
const
std::string
*
result
;
54
if
(
id_
== 0) {
55
result
= &ano_;
56
}
else
{
57
result
= &
DDI::Singleton<IdToName>::instance
()[
id_
]->first.second;
58
}
59
return
*
result
;
60
}
61
62
DDName::Registry::iterator
DDName::registerName
(
const
std::pair<std::string, std::string>& nm) {
63
Registry
& reg =
DDI::Singleton<Registry>::instance
();
64
IdToName
& idToName =
DDI::Singleton<IdToName>::instance
();
65
Registry::size_type
sz = reg.size();
66
if
(!sz) {
67
reg[std::make_pair(
std::string
(
""
),
std::string
(
""
))] = 0;
68
idToName.emplace_back(reg.begin());
69
++sz;
70
}
71
Registry::value_type
val
(nm, sz);
72
std::pair<Registry::iterator, bool>
result
= reg.insert(
val
);
73
if
(
result
.second) {
74
idToName.emplace_back(
result
.first);
75
}
76
return
result
.first;
77
}
DDCurrentNamespace.h
dqmiodumpmetadata.n
n
Definition:
dqmiodumpmetadata.py:28
DDName
DDName is used to identify DDD entities uniquely.
Definition:
DDName.h:15
DDSplit.h
operator<<
std::ostream & operator<<(std::ostream &os, const DDName &n)
Definition:
DDName.cc:10
edm::second
U second(std::pair< T, U > const &p)
Definition:
ParameterSet.cc:215
trigger::size_type
uint16_t size_type
Definition:
TriggerTypeDefs.h:18
DDName::DDName
DDName()
Definition:
DDName.cc:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
DDName::id_
id_type id_
Definition:
DDName.h:48
DDI::Singleton::instance
static value_type & instance()
DDName::name
const std::string & name() const
Returns the name.
Definition:
DDName.cc:40
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
DDName::IdToName
std::vector< Registry::const_iterator > IdToName
Definition:
DDName.h:19
Singleton.h
heppy_batch.val
val
Definition:
heppy_batch.py:351
std
Definition:
JetResolutionObject.h:76
DDName::ns
const std::string & ns() const
Returns the namespace.
Definition:
DDName.cc:51
DDCurrentNamespace::ns
static std::string & ns()
Definition:
DDCurrentNamespace.cc:3
DDName.h
Skims_PA_cff.name
name
Definition:
Skims_PA_cff.py:17
mps_fire.result
result
Definition:
mps_fire.py:303
DDName::Registry
std::map< std::pair< std::string, std::string >, id_type > Registry
Definition:
DDName.h:18
DDName::registerName
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition:
DDName.cc:62
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition:
DDSplit.cc:3
Generated for CMSSW Reference Manual by
1.8.16