CMS 3D CMS Logo

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 <map>
6 #include <string>
7 #include <utility>
8 #include <vector>
9 
10 class DDCurrentNamespace;
11 
13 
15 class DDName
16 {
17 public:
18 
19  using id_type = int;
20  using Registry = std::map<std::pair<std::string, std::string>, id_type>;
21  using IdToName = std::vector<Registry::const_iterator>;
22 
24  DDName( const std::string & name,
25  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:
51 
52  id_type id_;
53 
54  static Registry::iterator registerName( const std::pair<std::string, std::string> & s );
55 };
56 
57 std::ostream & operator<<( std::ostream & os, const DDName & n );
58 
59 #endif
id_type id() const
Definition: DDName.h:45
std::map< std::pair< std::string, std::string >, id_type > Registry
Definition: DDName.h:20
int id_type
Definition: DDName.h:19
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:67
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDName()
Definition: DDName.cc:48
std::ostream & operator<<(std::ostream &os, const DDName &n)
Definition: DDName.cc:10
const std::string fullname() const
Definition: DDName.h:43
bool operator<(const DDName &rhs) const
Definition: DDName.h:47
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:21
id_type id_
Definition: DDName.h:52
bool operator==(const DDName &rhs) const
Definition: DDName.h:48
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:81
const std::string & name() const
Returns the name.
Definition: DDName.cc:53