1 #ifndef UNIQUE_ID_CLASS
2 #define UNIQUE_ID_CLASS
29 template <
class uniquifier>
33 unique_id(uniquifier initial_value) : _id(initial_value) {}
41 virtual bool equal_to(
const equalizable &to_compare)
const {
43 if (!cast)
throw "error: unique_id::==: unknown type";
44 return cast->_id == _id;
51 {
return _id == to_compare._id; }
55 {
if (
this != &to_copy) _id = to_copy._id;
return *
this; }
57 uniquifier
raw_id()
const {
return _id; }
60 void set_raw_id(uniquifier new_value) { _id = new_value; }
76 template <
class uniquifier>
Base class for object that can tell itself apart from other instances.
A unique identifier class that supports sorting.
bool operator<(const unique_id< uniquifier > &to_compare) const
orderable_unique_id(const uniquifier &initial_value)
orderable_unique_id(const unique_id< uniquifier > &initial_value)
Provides an abstraction for the responsibilities of a unique identifier.
uniquifier raw_id() const
Returns the held identifier in its native form.
unique_id(const unique_id< uniquifier > &to_copy)
Constructs a unique id as a copy of the "to_copy" object.
virtual bool equal_to(const equalizable &to_compare) const
unique_id(uniquifier initial_value)
Constructs a unique id from the "initial_value".
bool operator==(const unique_id< uniquifier > &to_compare) const
Returns true if the held id is the same as "to_compare".
void set_raw_id(uniquifier new_value)
Sets the held identifier to "new_value".
unique_id & operator=(const unique_id< uniquifier > &to_copy)
Sets this id to be the same as "to_copy".
A unique identifier based on integers.
bool operator!() const
provides a way to test whether an id is valid.
unique_int(int initial=0)
implicit default for "initial" of zero indicates bogus id.
A dynamic container class that holds any kind of object via pointers.