ardour
id.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000-2007 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifndef __pbd_id_h__
21 #define __pbd_id_h__
22 
23 #include <stdint.h>
24 #include <string>
25 
26 #include <glibmm/threads.h>
27 
28 #include "pbd/libpbd_visibility.h"
29 
30 namespace PBD {
31 
32 class LIBPBD_API ID {
33  public:
34  ID ();
35  ID (std::string);
36  ID (const ID&);
37 
38  void reset ();
39 
40  bool operator== (const ID& other) const {
41  return _id == other._id;
42  }
43 
44  bool operator!= (const ID& other) const {
45  return _id != other._id;
46  }
47 
48  bool operator== (const std::string&) const;
49 
50  ID& operator= (std::string);
51  ID& operator= (const ID&);
52 
53  bool operator< (const ID& other) const {
54  return _id < other._id;
55  }
56 
57  void print (char* buf, uint32_t bufsize) const;
58  std::string to_s() const;
59 
60  static uint64_t counter() { return _counter; }
61  static void init_counter (uint64_t val) { _counter = val; }
62  static void init ();
63 
64  private:
65  uint64_t _id;
66  int string_assign (std::string);
67 
68  static Glib::Threads::Mutex* counter_lock;
69  static uint64_t _counter;
70 };
71 
72 }
73 
74 LIBPBD_API std::ostream& operator<< (std::ostream& ostr, const PBD::ID&);
75 
76 #endif /* __pbd_id_h__ */
bool operator<(shared_ptr< T > const &a, shared_ptr< U > const &b)
Definition: shared_ptr.hpp:376
static void init_counter(uint64_t val)
Definition: id.h:61
bool operator!=(shared_ptr< T > const &a, shared_ptr< U > const &b)
Definition: shared_ptr.hpp:360
#define LIBPBD_API
LIBPBD_API std::ostream & operator<<(std::ostream &ostr, const PBD::ID &)
Definition: id.h:32
static uint64_t counter()
Definition: id.h:60
LIBPBD_API bool init()
Definition: pbd.cc:66
bool operator==(const RouteProcessorSelection &a, const RouteProcessorSelection &b)
Definition: debug.h:30
static uint64_t _counter
Definition: id.h:69
static Glib::Threads::Mutex * counter_lock
Definition: id.h:68
uint64_t _id
Definition: id.h:65