nodeid.h
Go to the documentation of this file.
1 
11 #pragma once
12 
16 #include <opc/ua/protocol/guid.h>
18 
19 #include <sstream>
20 #include <stdint.h>
21 #include <string>
22 #include <vector>
23 
24 namespace OpcUa
25 {
26 
27 enum NodeIdEncoding : uint8_t
28 {
32  EV_STRING = 3,
33  EV_GUId = 4,
35 
38 
39  EV_VALUE_MASK = 0x3f,
40 };
41 
42 struct ExpandedNodeId;
43 
44 struct NodeId
45 {
48  uint32_t ServerIndex;
49 
51  {
52  uint8_t Identifier;
53 
55  : Identifier(0)
56  {
57  }
58 
59  } TwoByteData;
60 
62  {
63  uint8_t NamespaceIndex;
64  uint16_t Identifier;
65 
67  : NamespaceIndex(0)
68  , Identifier(0)
69  {
70  }
71  } FourByteData;
72 
74  {
75  uint16_t NamespaceIndex;
76  uint32_t Identifier;
77 
79  : NamespaceIndex(0)
80  , Identifier(0)
81  {
82  }
83  } NumericData;
84 
85 
87  {
88  uint16_t NamespaceIndex;
90 
92  : NamespaceIndex(0)
93  {
94  }
95 
96  } StringData;
97 
99  {
100  uint16_t NamespaceIndex;
101  std::vector<uint8_t> Identifier;
102 
104  : NamespaceIndex(0)
105  {
106  }
107 
108  } BinaryData;
109 
111  {
112  uint16_t NamespaceIndex;
114 
116  : NamespaceIndex(0)
117  {
118  }
119 
120  } GuidData;
121 
122  NodeId();
123  NodeId(const NodeId & node);
124  NodeId(const ExpandedNodeId & node);
125  NodeId(MessageId messageId);
126  NodeId(ReferenceId referenceId);
127  NodeId(ObjectId objectId);
128  NodeId(ExpandedObjectId objectId);
129  NodeId(uint32_t integerId, uint16_t index);
130  NodeId(std::string stringId, uint16_t index);
131 
132  NodeId & operator= (const NodeId & node);
133  NodeId & operator= (const ExpandedNodeId & node);
134 
135  explicit operator ExpandedNodeId();
136 
138  {
139  *this = NodeId(messageId);
140  return *this;
141  }
142 
144  {
145  *this = NodeId(referenceId);
146  return *this;
147  }
148 
150  {
151  *this = NodeId(objectId);
152  return *this;
153  }
154 
156  {
157  *this = NodeId(objectId);
158  return *this;
159  }
160 
161  bool operator== (const NodeId & node) const;
162  bool operator== (MessageId messageId) const;
163  bool operator== (ReferenceId referenceId) const;
164  bool operator== (ObjectId objectId) const;
165  bool operator== (ExpandedObjectId objectId) const;
166 
167  bool operator!= (const NodeId & node) const;
168  bool operator!= (MessageId messageId) const;
169  bool operator!= (ReferenceId referenceId) const;
170  bool operator!= (ObjectId objectId) const;
171  bool operator!= (ExpandedObjectId objectId) const;
172 
173  bool operator< (const NodeId & node) const;
174 
176  bool IsNull() const;
177  bool HasNullIdentifier() const;
178  bool HasNamespaceURI() const;
179  bool HasServerIndex() const;
180 
181  void SetNamespaceURI(const std::string & uri);
182  void SetServerIndex(uint32_t index);
183  void SetNamespaceIndex(uint32_t ns);
184 
185  bool IsInteger() const;
186  bool IsString() const;
187  bool IsBinary() const;
188  bool IsGuid() const;
189 
190  uint32_t GetNamespaceIndex() const;
191 
192  uint32_t GetIntegerIdentifier() const;
194  std::vector<uint8_t> GetBinaryIdentifier() const;
195  Guid GetGuidIdentifier() const;
196 
197 protected:
198  void CopyNodeId(const NodeId & node);
199 };
200 
201 inline NodeId TwoByteNodeId(uint8_t value)
202 {
203  NodeId id;
204  id.Encoding = EV_TWO_BYTE;
205  id.TwoByteData.Identifier = value;
206  return id;
207 }
208 
209 inline NodeId FourByteNodeId(uint16_t value, uint8_t namespaceIndex = 0)
210 {
211  NodeId id;
212  id.Encoding = EV_FOUR_BYTE;
213  id.FourByteData.Identifier = value;
214  id.FourByteData.NamespaceIndex = namespaceIndex;
215  return id;
216 }
217 
218 inline NodeId NumericNodeId(uint32_t value, uint16_t namespaceIndex = 0)
219 {
220  NodeId id;
221  id.Encoding = EV_NUMERIC;
222  id.NumericData.Identifier = value;
223  id.NumericData.NamespaceIndex = namespaceIndex;
224  return id;
225 }
226 
227 inline NodeId StringNodeId(std::string value, uint16_t namespaceIndex = 0)
228 {
229  NodeId id;
230  id.Encoding = EV_STRING;
231  id.StringData.Identifier = value;
232  id.StringData.NamespaceIndex = namespaceIndex;
233  return id;
234 }
235 
236 inline NodeId BinaryNodeId(std::vector<uint8_t> value, uint16_t namespaceIndex = 0)
237 {
238  NodeId id;
240  id.BinaryData.Identifier = value;
241  id.BinaryData.NamespaceIndex = namespaceIndex;
242  return id;
243 }
244 
245 inline NodeId GuidNodeId(Guid value, uint16_t namespaceIndex = 0)
246 {
247  NodeId id;
248  id.Encoding = EV_GUId;
249  id.GuidData.Identifier = value;
250  id.GuidData.NamespaceIndex = namespaceIndex;
251  return id;
252 }
253 
254 struct ExpandedNodeId : public NodeId
255 {
256  ExpandedNodeId();
257  ExpandedNodeId(const NodeId & node);
258  ExpandedNodeId(const ExpandedNodeId & node);
259  ExpandedNodeId(MessageId messageId);
260  ExpandedNodeId(ReferenceId referenceId);
261  ExpandedNodeId(ObjectId objectId);
263  ExpandedNodeId(uint32_t integerId, uint16_t index);
264  ExpandedNodeId(std::string stringId, uint16_t index);
265 
266  //using NodeId::NodeId;
267  //using base::base;
268 };
269 
270 } // namespace OpcUa
271 
272 
NodeId TwoByteNodeId(uint8_t value)
Definition: nodeid.h:201
bool HasNullIdentifier() const
Definition: nodeid.cpp:421
struct OpcUa::NodeId::NumericDataType NumericData
bool operator==(const NodeId &node) const
Definition: nodeid.cpp:307
uint32_t GetNamespaceIndex() const
Definition: nodeid.cpp:118
bool IsInteger() const
Definition: nodeid.cpp:38
bool IsGuid() const
Definition: nodeid.cpp:56
bool operator<(const NodeId &node) const
Definition: nodeid.cpp:337
bool IsBinary() const
Definition: nodeid.cpp:50
Guid GetGuidIdentifier() const
Definition: nodeid.cpp:82
bool HasNamespaceURI() const
Definition: nodeid.cpp:470
struct OpcUa::NodeId::GuidDataType GuidData
std::vector< uint8_t > GetBinaryIdentifier() const
Definition: nodeid.cpp:72
struct OpcUa::NodeId::TwoByteDataType TwoByteData
bool IsNull() const
Definition: nodeid.cpp:375
void SetNamespaceURI(const std::string &uri)
Definition: nodeid.cpp:480
uint32_t GetIntegerIdentifier() const
Definition: nodeid.cpp:92
void SetNamespaceIndex(uint32_t ns)
Definition: nodeid.cpp:142
ObjectId
Definition: object_ids.h:12
void SetServerIndex(uint32_t index)
Definition: nodeid.cpp:486
struct OpcUa::NodeId::BinaryDataType BinaryData
NodeId GuidNodeId(Guid value, uint16_t namespaceIndex=0)
Definition: nodeid.h:245
struct OpcUa::NodeId::FourByteDataType FourByteData
OPC UA Address space part. GNU LGPL.
std::vector< uint8_t > Identifier
Definition: nodeid.h:101
void CopyNodeId(const NodeId &node)
Definition: nodeid.cpp:177
string uri
Definition: client.py:31
bool HasServerIndex() const
Definition: nodeid.cpp:475
NodeId & operator=(const NodeId &node)
Definition: nodeid.cpp:261
struct OpcUa::NodeId::StringDataType StringData
NodeIdEncoding
Definition: nodeid.h:27
uint32_t ServerIndex
Definition: nodeid.h:48
bool IsString() const
Definition: nodeid.cpp:44
NodeIdEncoding Encoding
Definition: nodeid.h:46
NodeId BinaryNodeId(std::vector< uint8_t > value, uint16_t namespaceIndex=0)
Definition: nodeid.h:236
NodeId StringNodeId(std::string value, uint16_t namespaceIndex=0)
Definition: nodeid.h:227
NodeId NumericNodeId(uint32_t value, uint16_t namespaceIndex=0)
Definition: nodeid.h:218
bool operator!=(const NodeId &node) const
Definition: nodeid.cpp:492
std::string GetStringIdentifier() const
Definition: nodeid.cpp:62
std::string NamespaceURI
Definition: nodeid.h:47
NodeIdEncoding GetEncodingValue() const
Definition: nodeid.cpp:370
NodeId FourByteNodeId(uint16_t value, uint8_t namespaceIndex=0)
Definition: nodeid.h:209


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:07