RSC  0.17.1
UUID.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of the RSC project
4  *
5  * Copyright (C) 2010 by Sebastian Wrede <swrede at techfak dot uni-bielefeld dot de>
6  *
7  * This file may be licensed under the terms of the
8  * GNU Lesser General Public License Version 3 (the ``LGPL''),
9  * or (at your option) any later version.
10  *
11  * Software distributed under the License is distributed
12  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13  * express or implied. See the LGPL for the specific language
14  * governing rights and limitations.
15  *
16  * You should have received a copy of the LGPL along with this
17  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
18  * or write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The development of this software was supported by:
22  * CoR-Lab, Research Institute for Cognition and Robotics
23  * Bielefeld University
24  *
25  * ============================================================ */
26 
27 #pragma once
28 
29 #include <ostream>
30 #include <string>
31 
32 #include <boost/uuid/uuid.hpp>
33 #include <boost/uuid/uuid_generators.hpp>
34 #include <boost/shared_ptr.hpp>
35 
36 #include "rsc/rscexports.h"
37 
38 namespace rsc {
39 namespace misc {
40 
46 class RSC_EXPORT UUID {
47 public:
48 
56  explicit UUID(const bool& random = true);
57 
66  explicit UUID(const std::string& uuid);
67 
76  explicit UUID(const char* uuid);
77 
83  explicit UUID(boost::uint8_t* data);
84 
91  UUID(const UUID& ns, const std::string& name);
92 
93  virtual ~UUID();
94 
100  boost::uuids::uuid getId() const;
101 
107  std::string getIdAsString() const;
108 
109  bool operator==(const UUID& other) const;
110  bool operator!=(const UUID& other) const;
111  bool operator<(const UUID& other) const;
112 
113  friend RSC_EXPORT std::ostream& operator<<(std::ostream& stream, const UUID& id);
114 
115 private:
116 
117  boost::uuids::uuid id;
118  // TODO refactor to singleton
119  static boost::uuids::nil_generator nilGen;
120  static boost::uuids::basic_random_generator<boost::mt19937> randomGen;
121 
122 };
123 
124 typedef boost::shared_ptr<UUID> UUIDPtr;
125 
126 RSC_EXPORT std::ostream& operator<<(std::ostream& stream, const UUID& id);
127 
128 }
129 }
boost::uuids::uuid id
Definition: UUID.h:117
boost::shared_ptr< UUID > UUIDPtr
Definition: UUID.h:124
Encapsulates the generation and handling of UUIDs.
Definition: UUID.h:46
static boost::uuids::basic_random_generator< boost::mt19937 > randomGen
Definition: UUID.h:120
ostream & operator<<(ostream &stream, const UUID &id)
Definition: UUID.cpp:98
static boost::uuids::nil_generator nilGen
Definition: UUID.h:119
bool operator==(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
Two pairs of the same type are equal iff their members are equal.
bool operator<(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
http://gcc.gnu.org/onlinedocs/libstdc++/20_util/howto.html#pairlt
bool operator!=(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
Uses operator== to find the result.