diff options
author | Hans Fugal <hans@fugal.net> | 2006-08-04 02:18:45 +0000 |
---|---|---|
committer | Hans Fugal <hans@fugal.net> | 2006-08-04 02:18:45 +0000 |
commit | 79986643c0c904f6574bb5323e2233a43a9e622e (patch) | |
tree | 859323dbb096ac1658359881e7d11415b6588caa /libs/pbd/id.cc | |
parent | b0b723445816bc968a6a183c6619fccc61e82859 (diff) |
r269@gandalf: fugalh | 2006-08-03 20:18:05 -0600
Trunk merge conflicts resolved
git-svn-id: svn://localhost/ardour2/branches/undo@756 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/id.cc')
-rw-r--r-- | libs/pbd/id.cc | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc new file mode 100644 index 0000000000..f9afa72c98 --- /dev/null +++ b/libs/pbd/id.cc @@ -0,0 +1,63 @@ +#include <ostream> +#include <iostream> +#include <stdio.h> + +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +#include <inttypes.h> + +#include <pbd/id.h> + +using namespace std; +using namespace PBD; + +Glib::Mutex* ID::counter_lock = 0; +uint64_t ID::_counter = 0; + +void +ID::init () +{ + counter_lock = new Glib::Mutex; +} + +ID::ID () +{ + Glib::Mutex::Lock lm (*counter_lock); + id = _counter++; +} + +ID::ID (string str) +{ + string_assign (str); +} + +int +ID::string_assign (string str) +{ + return sscanf (str.c_str(), "%" PRIu64, &id) != 0; +} + +void +ID::print (char* buf) const +{ + /* XXX sizeof buf is unknown. bad API design */ + snprintf (buf, 16, "%" PRIu64, id); +} + +ID& +ID::operator= (string str) +{ + string_assign (str); + return *this; +} + +ostream& +operator<< (ostream& ostr, const ID& id) +{ + char buf[32]; + id.print (buf); + ostr << buf; + return ostr; +} + |