This is theoretically dangerous, because a PBD::ID is supposed to be unique, and this new constructor
cannot guarantee that. However, the same danger already exists with the std::string-based constructor
void
ID::init ()
{
- if (!counter_lock)
+ if (!counter_lock) {
counter_lock = new Glib::Threads::Mutex;
+ }
}
ID::ID ()
ID::ID (string str)
{
+ /* danger, will robinson: could result in non-unique ID */
string_assign (str);
}
+ID::ID (uint64_t n)
+{
+ /* danger, will robinson: could result in non-unique ID */
+ _id = n;
+}
+
void
ID::reset ()
{
Glib::Threads::Mutex::Lock lm (*counter_lock);
- _id = _counter++;
+ _id = ++_counter;
}
bool
ID ();
ID (std::string);
ID (const ID&);
+ ID (uint64_t);
void reset ();
}
bool operator== (const std::string&) const;
+ bool operator== (uint64_t n) const {
+ return _id == n;
+ }
ID& operator= (std::string);
ID& operator= (const ID&);