test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDName.h
Go to the documentation of this file.
1 #ifndef DDName_h
2 #define DDName_h
3 
4 #include <string>
5 #include <map>
6 #include <vector>
7 
9 class DDStreamer;
10 
12 
14 class DDName
15 {
16  friend class DStreamer; // intrusive!
17 
18 public:
19 
21  typedef int id_type;
22  typedef std::map<std::pair<std::string,std::string>,id_type> Registry;
23  typedef std::vector<Registry::const_iterator> IdToName;
24 
26  DDName( const std::string & name,
27  const std::string & ns);
28 
30  DDName( const std::string & name );
31  DDName( const char* name );
32  DDName( const char* name, const char* ns );
33  // DDName(pair<int,int>);
34  DDName(id_type);
36  static void defineId( const std::pair<std::string,std::string> &, id_type id);
37 
38  explicit DDName();
39 
41  static bool exists(const std::string & name, const std::string & ns);
43  const std::string & name() const;
44 
46  const std::string & ns() const;
47 
51  const std::string fullname() const { return ns() + ":" + name(); }
52 
53  // DEPRECATED!!!
54  operator std::string() const { return ns() + ":" + name(); }
55 
56  id_type id() const { return id_;}
57 
58  bool operator<(const DDName & rhs) const { return id_ < rhs.id_; }
59  bool operator==(const DDName & rhs) const { return id_ == rhs.id_; }
60 
61 private:
63 
64  static Registry::iterator registerName(const std::pair<std::string,std::string> & s);
65 };
66 
68 
73 {
74  virtual ~DDNameInterface() {}
75 
77  virtual const std::string & name() const=0; // name without namespace
78 
80  virtual const std::string & ns() const=0; // only the namespace
81 
83  DDName ddname() const { return DDName(name(),ns()); }
84 
85  virtual operator bool() const=0;
86 
88  virtual int id() const=0; // dont't know if usefull ...
89 };
90 
91 std::ostream & operator<<(std::ostream & os, const DDName & n);
92 
93 #endif
id_type id() const
Definition: DDName.h:56
DDCurrentNamespace CNS
Definition: DDName.h:20
Streaming the DDD transient store from/into a std::istream/std::ostream */.
Definition: DDStreamer.h:41
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
DDName()
Definition: DDName.cc:55
DDNameInterface provides a common interface to DDD entities.
Definition: DDName.h:72
std::map< std::pair< std::string, std::string >, id_type > Registry
Definition: DDName.h:22
virtual const std::string & ns() const =0
Return the namespace.
friend class DStreamer
Definition: DDName.h:16
const std::string fullname() const
Definition: DDName.h:51
bool operator<(const DDName &rhs) const
Definition: DDName.h:58
virtual const std::string & name() const =0
Returns the name without the namespace.
static void defineId(const std::pair< std::string, std::string > &, id_type id)
register pre-defined ids
Definition: DDName.cc:63
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:23
int id_type
Definition: DDName.h:21
static bool exists(const std::string &name, const std::string &ns)
true, if a DDName with given name and namespace (ns) already is registerd, otherwise false ...
Definition: DDName.cc:116
id_type id_
Definition: DDName.h:62
bool operator==(const DDName &rhs) const
Definition: DDName.h:59
virtual ~DDNameInterface()
Definition: DDName.h:74
static Registry::iterator registerName(const std::pair< std::string, std::string > &s)
Definition: DDName.cc:124
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
virtual int id() const =0
don&#39;t use !
DDName ddname() const
Return the DDName.
Definition: DDName.h:83