Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
23 
24 #include <stdint.h>
25 #include <string>
26 
27 #include <glibmm/threads.h>
28 
29 #include "pbd/libpbd_visibility.h"
30 
31 namespace PBD {
32 
34 class LIBPBD_API ID {
35  public:
36  ID ();
37  ID (std::string);
38  ID (const ID&);
39  ID (uint64_t);
40 
41  void reset ();
42 
43  bool operator== (const ID& other) const {
44  return _id == other._id;
45  }
46 
47  bool operator!= (const ID& other) const {
48  return _id != other._id;
49  }
50 
51  bool operator== (const std::string&) const;
52  bool operator== (uint64_t n) const {
53  return _id == n;
54  }
55 
56  ID& operator= (std::string);
57  ID& operator= (const ID&);
58 
59  bool operator< (const ID& other) const {
60  return _id < other._id;
61  }
62 
63  std::string to_s () const;
64 
65  static uint64_t counter() { return _counter; }
66  static void init_counter (uint64_t val) { _counter = val; }
67  static void init ();
68 
69  private:
70  uint64_t _id;
71  bool string_assign (std::string);
72 
73  static Glib::Threads::Mutex* counter_lock;
74  static uint64_t _counter;
75 };
76 
77 }
78 
79 LIBPBD_API std::ostream& operator<< (std::ostream& ostr, const PBD::ID&);
80 
Definition: id.h:34
static void init()
static void init_counter(uint64_t val)
Definition: id.h:66
static uint64_t _counter
Definition: id.h:74
ID(const ID &)
uint64_t _id
Definition: id.h:70
static Glib::Threads::Mutex * counter_lock
Definition: id.h:73
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:65
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)