13
0
livetrax/libs/pbd/id.cc
David Robillard fedf3d34f3 Merged with trunk R992.
Completely untested other than it compiles, runs, and records somewhat (need to merge again).


git-svn-id: svn://localhost/ardour2/branches/midi@999 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-10-21 19:01:50 +00:00

71 lines
979 B
C++

#include <ostream>
#include <iostream>
#include <stdio.h>
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include <pbd/id.h>
#include <string>
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, uint32_t bufsize) const
{
snprintf (buf, bufsize, "%" PRIu64, _id);
}
string ID::to_s() const
{
char buf[32]; // see print()
print(buf, sizeof (buf));
return string(buf);
}
ID&
ID::operator= (string str)
{
string_assign (str);
return *this;
}
ostream&
operator<< (ostream& ostr, const ID& _id)
{
char buf[32];
_id.print (buf, sizeof (buf));
ostr << buf;
return ostr;
}