Ardour  8.12
id.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2006 Hans Fugal <hans@fugal.net>
4  * Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
5  * Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __pbd_id_h__
23 #define __pbd_id_h__
24 
25 #include <stdint.h>
26 #include <string>
27 
28 #include <glibmm/threads.h>
29 
30 #include "pbd/libpbd_visibility.h"
31 
32 namespace PBD {
33 
35 class LIBPBD_API ID {
36  public:
37  ID ();
38  ID (std::string);
39  ID (const ID&);
40  ID (uint64_t);
41 
42  void reset ();
43 
44  bool operator== (const ID& other) const {
45  return _id == other._id;
46  }
47 
48  bool operator!= (const ID& other) const {
49  return _id != other._id;
50  }
51 
52  bool operator== (const std::string&) const;
53  bool operator== (uint64_t n) const {
54  return _id == n;
55  }
56 
57  ID& operator= (std::string);
58  ID& operator= (const ID&);
59 
60  bool operator< (const ID& other) const {
61  return _id < other._id;
62  }
63 
64  std::string to_s () const;
65 
66  static uint64_t counter() { return _counter; }
67  static void init_counter (uint64_t val) { _counter = val; }
68  static void init ();
69 
70  private:
71  uint64_t _id;
72  bool string_assign (std::string);
73 
74  static Glib::Threads::Mutex* counter_lock;
75  static uint64_t _counter;
76 };
77 
78 }
79 
80 LIBPBD_API std::ostream& operator<< (std::ostream& ostr, const PBD::ID&);
81 
82 #endif /* __pbd_id_h__ */
Definition: id.h:35
static void init()
static void init_counter(uint64_t val)
Definition: id.h:67
static uint64_t _counter
Definition: id.h:75
ID(const ID &)
uint64_t _id
Definition: id.h:71
static Glib::Threads::Mutex * counter_lock
Definition: id.h:74
std::string to_s() const
ID(uint64_t)
void reset()
bool string_assign(std::string)
ID(std::string)
static uint64_t counter()
Definition: id.h:66
std::ostream & operator<<(std::ostream &ostr, const PBD::ID &)
#define LIBPBD_API
Definition: axis_view.h:42
bool operator==(const ProcessorSelection &a, const ProcessorSelection &b)