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