Robot Raconteur Core C++ Library
NodeID.h
Go to the documentation of this file.
1 
24 #pragma once
25 
28 #include <boost/array.hpp>
29 #include <boost/uuid/uuid.hpp>
30 
31 namespace RobotRaconteur
32 {
33 
57 class ROBOTRACONTEUR_CORE_API NodeID : virtual public RRObject
58 {
59  private:
60  boost::uuids::uuid id;
61 
62  public:
67  NodeID();
68 
74  NodeID(boost::array<uint8_t, 16> id);
75 
81  NodeID(boost::uuids::uuid id);
82 
88  NodeID(const NodeID& id);
89 
95  NodeID(boost::string_ref id);
96 
102  const boost::array<uint8_t, 16> ToByteArray() const;
103 
104  const boost::uuids::uuid ToUuid() const;
105 
115  virtual std::string ToString() const;
116 
139  virtual std::string ToString(boost::string_ref format) const;
140 
148  static NodeID NewUniqueID();
149 
151  bool operator==(const NodeID& id2) const;
152 
154  bool operator!=(const NodeID& id2) const;
155 
157  bool operator<(const NodeID& id2) const;
158 
160  NodeID& operator=(const NodeID& id);
161 
170  bool IsAnyNode() const;
171 
177  static NodeID GetAny();
178 
180  virtual int32_t GetHashCode() const;
181 
182  RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur::NodeID"; }
183 
184  private:
185  void init_from_string(const boost::string_ref& id);
186 };
187 
188 size_t hash(const NodeID& nodeid);
189 
190 } // namespace RobotRaconteur
NodeID UUID storage and generation.
Definition: NodeID.h:58
static NodeID GetAny()
Get the "any" NodeId.
bool operator==(const NodeID &id2) const
Test if NodeID is equal.
NodeID(boost::uuids::uuid id)
Construct a new NodeID with the specified boost::uuids::uuid.
NodeID(boost::array< uint8_t, 16 > id)
Construct a new NodeID with the specified UUID bytes.
virtual std::string ToString(boost::string_ref format) const
Convert the NodeID UUID to specified format.
NodeID(boost::string_ref id)
Construct a new NodeID parsing a string UUID.
bool IsAnyNode() const
Is the NodeID UUID all zeros.
const boost::array< uint8_t, 16 > ToByteArray() const
Convert the NodeID UUID to bytes.
virtual std::string ToString() const
Convert the NodeID UUID to string with "B" format.
bool operator!=(const NodeID &id2) const
Test if NodeID is not equal.
NodeID()
Construct a new NodeID with "any" node UUID.
static NodeID NewUniqueID()
Generate a new random NodeID UUID.
NodeID & operator=(const NodeID &id)
Assignment operator.
NodeID(const NodeID &id)
Copy construct a new NodeID.
Base class for all Robot Raconteur objects.
Definition: DataTypes.h:227