CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDName.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_CORE_DDNAME_H
2 #define DETECTOR_DESCRIPTION_CORE_DDNAME_H
3 
4 #include <iosfwd>
5 #include <string>
6 #include <utility>
7 
9 #include <tbb/concurrent_vector.h>
10 #include <tbb/concurrent_unordered_map.h>
11 
12 class DDCurrentNamespace;
13 
15 
17 class DDName {
18 public:
19  using id_type = int;
20  using key_type = std::pair<const std::string, std::string>;
21  using Registry = tbb::concurrent_unordered_map<key_type, id_type, edm::StdPairHasher>;
22  using IdToName = tbb::concurrent_vector<Registry::const_iterator>;
23 
25  DDName(const std::string& name, const std::string& ns);
26 
28  DDName(const std::string& name);
29  DDName(const char* name);
30  DDName(const char* name, const char* ns);
31 
32  explicit DDName();
33 
35  const std::string& name() const;
36 
38  const std::string& ns() const;
39 
43  const std::string fullname() const { return ns() + ":" + name(); }
44 
45  id_type id() const { return id_; }
46 
47  bool operator<(const DDName& rhs) const { return id_ < rhs.id_; }
48  bool operator==(const DDName& rhs) const { return id_ == rhs.id_; }
49 
50 private:
52 
53  static Registry::const_iterator registerName(const std::pair<std::string, std::string>& s);
54 };
55 
56 std::ostream& operator<<(std::ostream& os, const DDName& n);
57 
58 #endif
id_type id() const
Definition: DDName.h:45
tbb::concurrent_unordered_map< key_type, id_type, edm::StdPairHasher > Registry
Definition: DDName.h:21
int id_type
Definition: DDName.h:19
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
DDName()
Definition: DDName.cc:39
std::pair< const std::string, std::string > key_type
Definition: DDName.h:20
static Registry::const_iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:67
const std::string fullname() const
Definition: DDName.h:43
bool operator<(const DDName &rhs) const
Definition: DDName.h:47
id_type id_
Definition: DDName.h:51
tbb::concurrent_vector< Registry::const_iterator > IdToName
Definition: DDName.h:22
bool operator==(const DDName &rhs) const
Definition: DDName.h:48
const std::string & name() const
Returns the name.
Definition: DDName.cc:41