c1103627342ba4d313052baa62cc03acb39de70e
[ardour.git] / libs / pbd / pbd / id.h
1 #ifndef __pbd_id_h__
2 #define __pbd_id_h__
3
4 #include <stdint.h>
5 #include <string>
6
7 #include <glibmm/thread.h>
8
9 namespace PBD {
10
11 class ID {
12   public:
13         ID ();
14         ID (std::string);
15         
16         bool operator== (const ID& other) const {
17                 return _id == other._id; 
18         }
19
20         bool operator!= (const ID& other) const {
21                 return _id != other._id;
22         }
23
24         ID& operator= (std::string); 
25
26         bool operator< (const ID& other) const {
27                 return _id < other._id;
28         }
29
30         void print (char* buf) const;
31         std::string to_s() const;
32         
33         static uint64_t counter() { return _counter; }
34         static void init_counter (uint64_t val) { _counter = val; }
35         static void init ();
36
37   private:
38         uint64_t _id;
39         int string_assign (std::string);
40
41         static Glib::Mutex* counter_lock;
42         static uint64_t _counter;
43 };
44
45 }
46 std::ostream& operator<< (std::ostream& ostr, const PBD::ID&);
47
48 #endif /* __pbd_id_h__ */