Line | |
---|
1 | /*! |
---|
2 | * @file new_class_id.h |
---|
3 | * @brief Definition of a dynamically allocating ClassID |
---|
4 | * |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _NEW_CLASS_ID_H |
---|
8 | #define _NEW_CLASS_ID_H |
---|
9 | |
---|
10 | #include <string> |
---|
11 | |
---|
12 | //! A class to dynamically allocate ClassID's and support a isA operator |
---|
13 | class NewClassID |
---|
14 | { |
---|
15 | public: |
---|
16 | NewClassID() : _id(-1), _name("") { }; |
---|
17 | NewClassID(int id, const std::string& name) : _id(id), _name(name) { }; |
---|
18 | // the copy constructor is also defined. |
---|
19 | const int& id() const { return _id; }; |
---|
20 | const std::string& name() const { return _name; }; |
---|
21 | |
---|
22 | bool operator==(NewClassID id) const { return _id == id._id || _name == id._name; }; |
---|
23 | bool operator==(int id) const { return _id == id; }; |
---|
24 | bool operator==(const std::string& name) const { return _name == name; }; |
---|
25 | bool operator!=(NewClassID id) const { return _id != id._id && _name != id._name; }; |
---|
26 | bool operator!=(int id) const { return _id != id; }; |
---|
27 | bool operator!=(const std::string& name) const { return _name != name; }; |
---|
28 | |
---|
29 | private: |
---|
30 | int _id; |
---|
31 | std::string _name; |
---|
32 | }; |
---|
33 | #endif /* _NEW_CLASS_ID_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.