summaryrefslogtreecommitdiff
path: root/libs/pbd/id.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-05-05 12:18:06 +0100
committerPaul Davis <paul@linuxaudiosystems.com>2017-05-05 18:56:25 +0100
commitccd19ed0615bfb300bedc23ac48de7f426a7948e (patch)
tree24a86e76bbbbb15c24f904040c16f527990f9853 /libs/pbd/id.cc
parent417f63a29e54bc962eeb9e5855656f7f7da8c55f (diff)
extend PBD::ID API to allow construction and operator== using uint64_t
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
Diffstat (limited to 'libs/pbd/id.cc')
-rw-r--r--libs/pbd/id.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc
index d507824349..bc119b13dc 100644
--- a/libs/pbd/id.cc
+++ b/libs/pbd/id.cc
@@ -34,8 +34,9 @@ uint64_t ID::_counter = 0;
void
ID::init ()
{
- if (!counter_lock)
+ if (!counter_lock) {
counter_lock = new Glib::Threads::Mutex;
+ }
}
ID::ID ()
@@ -50,14 +51,21 @@ ID::ID (const ID& other)
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