DUDS
Distributed Update of Data from Something
Identity.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
10 #include <boost/uuid/uuid.hpp>
11 #include <duds/LanguageTaggedString.hpp>
12 
13 namespace duds {
14 
19 class Identity {
23  boost::uuids::uuid uuid;
27  LanguageTaggedStringSet name;
28  protected:
29  void setUuid(const boost::uuids::uuid &u);
30  LanguageTaggedStringSet &getNames() {
31  return name;
32  }
33  void setNames(const LanguageTaggedStringSet &n);
34  public:
39  Identity();
40  Identity(bool genUuid);
41  Identity(const boost::uuids::uuid &u);
42  Identity(const LanguageTaggedStringSet &n, bool genUuid = false);
43  Identity(const boost::uuids::uuid &u, const LanguageTaggedStringSet &n);
47  const boost::uuids::uuid &getUuid() const {
48  return uuid;
49  }
53  const LanguageTaggedStringSet &getNames() const {
54  return name;
55  }
59  std::string getName() const;
63  bool operator < (const Identity &i) const {
64  return uuid < i.uuid;
65  }
69  bool operator > (const Identity &i) const {
70  return uuid > i.uuid;
71  }
75  bool operator <= (const Identity &i) const {
76  return uuid <= i.uuid;
77  }
81  bool operator >= (const Identity &i) const {
82  return uuid >= i.uuid;
83  }
87  bool operator == (const Identity &i) const {
88  return uuid == i.uuid;
89  }
93  bool operator != (const Identity &i) const {
94  return uuid != i.uuid;
95  }
96 };
97 
98 }
bool operator==(const Identity &i) const
Identity objects are compared using the uuid member.
Definition: Identity.hpp:87
std::string getName() const
Returns the name for the current locale.
LanguageTaggedStringSet name
A name for this item intended for user presentation.
Definition: Identity.hpp:27
const LanguageTaggedStringSet & getNames() const
Returns the set of names for all locales and languages.
Definition: Identity.hpp:53
bool operator>=(const Identity &i) const
Identity objects are compared using the uuid member.
Definition: Identity.hpp:81
bool operator<(const Identity &i) const
Identity objects are compared using the uuid member.
Definition: Identity.hpp:63
bool operator!=(const Identity &i) const
Identity objects are compared using the uuid member.
Definition: Identity.hpp:93
LanguageTaggedStringSet & getNames()
Definition: Identity.hpp:30
bool operator<=(const Identity &i) const
Identity objects are compared using the uuid member.
Definition: Identity.hpp:75
bool operator>(const Identity &i) const
Identity objects are compared using the uuid member.
Definition: Identity.hpp:69
The identification for something that is unique across all peers.
Definition: Identity.hpp:19
boost::uuids::uuid uuid
A unique identifier that is valid across all peers.
Definition: Identity.hpp:23
const boost::uuids::uuid & getUuid() const
Returns the object&#39;s unique identifier.
Definition: Identity.hpp:47
void setUuid(const boost::uuids::uuid &u)
void setNames(const LanguageTaggedStringSet &n)