Merge big changes (mostly Controllable) from trunk
[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         
32         static uint64_t counter() { return _counter; }
33         static void init_counter (uint64_t val) { _counter = val; }
34         static void init ();
35
36   private:
37         uint64_t id;
38         int string_assign (std::string);
39
40         static Glib::Mutex* counter_lock;
41         static uint64_t _counter;
42 };
43
44 }
45 std::ostream& operator<< (std::ostream& ostr, const PBD::ID&);
46
47 #endif /* __pbd_id_h__ */