open62541++ 0.13.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
Node.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string_view>
5#include <utility> // move
6#include <vector>
7
9#include "open62541pp/Common.h" // BrowseDirection
10#include "open62541pp/Config.h"
11#include "open62541pp/NodeIds.h"
12#include "open62541pp/Span.h"
13#include "open62541pp/TypeRegistry.h" // getDataType
14#include "open62541pp/Wrapper.h" // asWrapper
25
26namespace opcua {
27
28/**
29 * High-level node class to access node attribute, browse and populate address space.
30 *
31 * The Node API is just a more convenient way of using the free functions in the opcua::services
32 * namespace.
33 *
34 * Node objects are useful as-is but they do not expose the entire OPC UA protocol. You can get
35 * access to the associated NodeId instance with the Node::id() method and apply the native
36 * open62541 functions or the free functions in the opcua::services namespace.
37 *
38 * @tparam Connection Server or Client
39 * @see Services
40 */
41template <typename Connection>
42class Node {
43public:
44 /// Create a Node object.
45 Node(Connection& connection, const NodeId& id)
46 : connection_(connection),
47 id_(id) {}
48
49 /// Create a Node object.
50 Node(Connection& connection, NodeId&& id)
51 : connection_(connection),
52 id_(std::move(id)) {}
53
54 /// Get the server/client instance.
55 Connection& connection() noexcept {
56 return connection_;
57 }
58
59 /// Get the server/client instance.
60 const Connection& connection() const noexcept {
61 return connection_;
62 }
63
64 /// @deprecated Use connection() instead
65 [[deprecated("Use connection() instead")]]
66 Connection& getConnection() noexcept {
67 return connection_;
68 }
69
70 /// @deprecated Use connection() instead
71 [[deprecated("Use connection() instead")]]
72 const Connection& getConnection() const noexcept {
73 return connection_;
74 }
75
76 /// Get the node id.
77 const NodeId& id() const noexcept {
78 return id_;
79 }
80
81 /// @deprecated Use id() instead
82 [[deprecated("Use id() instead")]]
83 const NodeId& getNodeId() const noexcept {
84 return id_;
85 }
86
87 /// Check if the Node exists in the most efficient manner.
88 /// If the instance is of type `Node<Server>`, the internal node store is searched.
89 /// If the instance is of type `Node<Client>`, an actual read request to the server is made.
90 bool exists() noexcept;
91
92 /// @wrapper{services::addFolder}
94 const NodeId& id,
95 std::string_view browseName,
96 const ObjectAttributes& attributes = {},
97 const NodeId& referenceType = ReferenceTypeId::HasComponent
98 ) {
99 auto result = services::addFolder(
100 connection_, id_, id, browseName, attributes, referenceType
101 );
102 return {connection_, result.value()};
103 }
104
105 /// @wrapper{services::addObject}
107 const NodeId& id,
108 std::string_view browseName,
109 const ObjectAttributes& attributes = {},
110 const NodeId& objectType = ObjectTypeId::BaseObjectType,
111 const NodeId& referenceType = ReferenceTypeId::HasComponent
112 ) {
113 auto result = services::addObject(
114 connection_, id_, id, browseName, attributes, objectType, referenceType
115 );
116 return {connection_, result.value()};
117 }
118
119 /// @wrapper{services::addVariable}
121 const NodeId& id,
122 std::string_view browseName,
123 const VariableAttributes& attributes = {},
124 const NodeId& variableType = VariableTypeId::BaseDataVariableType,
125 const NodeId& referenceType = ReferenceTypeId::HasComponent
126 ) {
127 auto result = services::addVariable(
128 connection_, id_, id, browseName, attributes, variableType, referenceType
129 );
130 return {connection_, result.value()};
131 }
132
133 /// @wrapper{services::addProperty}
135 const NodeId& id, std::string_view browseName, const VariableAttributes& attributes = {}
136 ) {
137 auto result = services::addProperty(connection_, id_, id, browseName, attributes);
138 return {connection_, result.value()};
139 }
140
141#ifdef UA_ENABLE_METHODCALLS
142 /// @wrapper{services::addMethod}
144 const NodeId& id,
145 std::string_view browseName,
147 Span<const Argument> inputArguments,
148 Span<const Argument> outputArguments,
149 const MethodAttributes& attributes = {},
150 const NodeId& referenceType = ReferenceTypeId::HasComponent
151 ) {
152 auto result = services::addMethod(
153 connection_,
154 id_,
155 id,
156 browseName,
157 std::move(callback),
158 inputArguments,
159 outputArguments,
160 attributes,
161 referenceType
162 );
163 return {connection_, result.value()};
164 }
165#endif
166
167 /// @wrapper{services::addObjectType}
169 const NodeId& id,
170 std::string_view browseName,
171 const ObjectTypeAttributes& attributes = {},
172 const NodeId& referenceType = ReferenceTypeId::HasSubtype
173 ) {
174 auto result = services::addObjectType(
175 connection_, id_, id, browseName, attributes, referenceType
176 );
177 return {connection_, result.value()};
178 }
179
180 /// @wrapper{services::addVariableType}
182 const NodeId& id,
183 std::string_view browseName,
184 const VariableTypeAttributes& attributes = {},
185 const NodeId& variableType = VariableTypeId::BaseDataVariableType,
186 const NodeId& referenceType = ReferenceTypeId::HasSubtype
187 ) {
188 auto result = services::addVariableType(
189 connection_, id_, id, browseName, attributes, variableType, referenceType
190 );
191 return {connection_, result.value()};
192 }
193
194 /// @wrapper{services::addReferenceType}
196 const NodeId& id,
197 std::string_view browseName,
198 const ReferenceTypeAttributes& attributes = {},
199 const NodeId& referenceType = ReferenceTypeId::HasSubtype
200 ) {
201 auto result = services::addReferenceType(
202 connection_, id_, id, browseName, attributes, referenceType
203 );
204 return {connection_, result.value()};
205 }
206
207 /// @wrapper{services::addDataType}
209 const NodeId& id,
210 std::string_view browseName,
211 const DataTypeAttributes& attributes = {},
212 const NodeId& referenceType = ReferenceTypeId::HasSubtype
213 ) {
214 auto result = services::addDataType(
215 connection_, id_, id, browseName, attributes, referenceType
216 );
217 return {connection_, result.value()};
218 }
219
220 /// @wrapper{services::addView}
222 const NodeId& id,
223 std::string_view browseName,
224 const ViewAttributes& attributes = {},
225 const NodeId& referenceType = ReferenceTypeId::Organizes
226 ) {
227 auto result = services::addView(
228 connection_, id_, id, browseName, attributes, referenceType
229 );
230 return {connection_, result.value()};
231 }
232
233 /// @wrapper{services::addReference}
234 Node& addReference(const NodeId& targetId, const NodeId& referenceType, bool forward = true) {
235 services::addReference(connection_, id_, targetId, referenceType, forward).value();
236 return *this;
237 }
238
239 /// @wrapper{services::addModellingRule}
241 services::addModellingRule(connection_, id_, rule).value();
242 return *this;
243 }
244
245 /// @wrapper{services::deleteNode}
246 void deleteNode(bool deleteReferences = true) {
247 services::deleteNode(connection_, id_, deleteReferences).value();
248 }
249
250 /// @wrapper{services::deleteReference}
252 const NodeId& targetId,
253 const NodeId& referenceType,
254 bool isForward,
255 bool deleteBidirectional
256 ) {
258 connection_, id_, targetId, referenceType, isForward, deleteBidirectional
259 )
260 .value();
261 return *this;
262 }
263
264 /// Browse references.
265 std::vector<ReferenceDescription> browseReferences(
266 BrowseDirection browseDirection = BrowseDirection::Both,
267 const NodeId& referenceType = ReferenceTypeId::References,
268 bool includeSubtypes = true,
270 ) {
271 const BrowseDescription bd(
272 id_,
273 browseDirection,
274 referenceType,
275 includeSubtypes,
276 nodeClassMask,
278 );
279 return services::browseAll(connection_, bd).value();
280 }
281
282 /// Browse referenced nodes (only local nodes).
283 std::vector<Node> browseReferencedNodes(
284 BrowseDirection browseDirection = BrowseDirection::Both,
285 const NodeId& referenceType = ReferenceTypeId::References,
286 bool includeSubtypes = true,
288 ) {
289 const BrowseDescription bd(
290 id_,
291 browseDirection,
292 referenceType,
293 includeSubtypes,
294 nodeClassMask,
295 BrowseResultMask::TargetInfo // only node id required here
296 );
297 auto refs = services::browseAll(connection_, bd).value();
298 std::vector<Node> nodes;
299 nodes.reserve(refs.size());
300 for (auto&& ref : refs) {
301 if (ref.getNodeId().isLocal()) {
302 nodes.emplace_back(connection_, std::move(ref.getNodeId().getNodeId()));
303 }
304 }
305 return nodes;
306 }
307
308 /// Browse child nodes (only local nodes).
309 std::vector<Node> browseChildren(
310 const NodeId& referenceType = ReferenceTypeId::HierarchicalReferences,
312 ) {
313 return browseReferencedNodes(BrowseDirection::Forward, referenceType, true, nodeClassMask);
314 }
315
316 /// Browse child node specified by its relative path from this node (only local nodes).
317 /// The relative path is specified using browse names.
318 /// @exception BadStatus (BadNoMatch) If path not found
320 auto result = services::browseSimplifiedBrowsePath(connection_, id_, path).value();
321 for (auto&& target : result.getTargets()) {
322 if (target.getTargetId().isLocal()) {
323 return {connection_, std::move(target.getTargetId().getNodeId())};
324 }
325 }
327 }
328
329 /// Browse parent node.
330 /// A Node may have several parents, the first found is returned.
331 /// @exception BadStatus (BadNotFound) If no parent node found
333 const auto nodes = browseReferencedNodes(
336 true,
338 );
339 if (nodes.empty()) {
341 }
342 return nodes[0];
343 }
344
345#ifdef UA_ENABLE_METHODCALLS
346 /// Call a server method and return results.
347 /// @param methodId NodeId of the method (`HasComponent` reference to current node required)
348 /// @param inputArguments Input argument values
349 std::vector<Variant> callMethod(const NodeId& methodId, Span<const Variant> inputArguments) {
350 return services::call(connection_, id_, methodId, inputArguments).value();
351 }
352#endif
353
354 /// @wrapper{services::readNodeClass}
356 return services::readNodeClass(connection_, id_).value();
357 }
358
359 /// @wrapper{services::readBrowseName}
361 return services::readBrowseName(connection_, id_).value();
362 }
363
364 /// @wrapper{services::readDisplayName}
366 return services::readDisplayName(connection_, id_).value();
367 }
368
369 /// @wrapper{services::readDescription}
371 return services::readDescription(connection_, id_).value();
372 }
373
374 /// @wrapper{services::readWriteMask}
376 return services::readWriteMask(connection_, id_).value();
377 }
378
379 /// @wrapper{services::readUserWriteMask}
381 return services::readUserWriteMask(connection_, id_).value();
382 }
383
384 /// @wrapper{services::readIsAbstract}
386 return services::readIsAbstract(connection_, id_).value();
387 }
388
389 /// @wrapper{services::readSymmetric}
391 return services::readSymmetric(connection_, id_).value();
392 }
393
394 /// @wrapper{services::readInverseName}
396 return services::readInverseName(connection_, id_).value();
397 }
398
399 /// @wrapper{services::readContainsNoLoops}
401 return services::readContainsNoLoops(connection_, id_).value();
402 }
403
404 /// @wrapper{services::readEventNotifier}
406 return services::readEventNotifier(connection_, id_).value();
407 }
408
409 /// @wrapper{services::readDataValue}
411 return services::readDataValue(connection_, id_).value();
412 }
413
414 /// @wrapper{services::readValue}
416 return services::readValue(connection_, id_).value();
417 }
418
419 /// Read scalar value from variable node.
420 template <typename T>
422 return readValue().template getScalarCopy<T>();
423 }
424
425 /// Read array value from variable node.
426 template <typename T>
427 std::vector<T> readValueArray() {
428 return readValue().template getArrayCopy<T>();
429 }
430
431 /// @wrapper{services::readDataType}
433 return services::readDataType(connection_, id_).value();
434 }
435
436 /// @wrapper{services::readValueRank}
438 return services::readValueRank(connection_, id_).value();
439 }
440
441 /// @wrapper{services::readArrayDimensions}
442 std::vector<uint32_t> readArrayDimensions() {
443 return services::readArrayDimensions(connection_, id_).value();
444 }
445
446 /// @wrapper{services::readAccessLevel}
448 return services::readAccessLevel(connection_, id_).value();
449 }
450
451 /// @wrapper{services::readUserAccessLevel}
453 return services::readUserAccessLevel(connection_, id_).value();
454 }
455
456 /// @wrapper{services::readMinimumSamplingInterval}
458 return services::readMinimumSamplingInterval(connection_, id_).value();
459 }
460
461 /// @wrapper{services::readHistorizing}
463 return services::readHistorizing(connection_, id_).value();
464 }
465
466 /// @wrapper{services::readExecutable}
468 return services::readExecutable(connection_, id_).value();
469 }
470
471 /// @wrapper{services::readUserExecutable}
473 return services::readUserExecutable(connection_, id_).value();
474 }
475
476 /// Read the value of an object property.
477 /// @param propertyName Browse name of the property (variable node)
479 return browseObjectProperty(propertyName).readValue();
480 }
481
482 /// @wrapper{services::writeDisplayName}
484 services::writeDisplayName(connection_, id_, name).value();
485 return *this;
486 }
487
488 /// @wrapper{services::writeDescription}
490 services::writeDescription(connection_, id_, desc).value();
491 return *this;
492 }
493
494 /// @wrapper{services::writeWriteMask}
496 services::writeWriteMask(connection_, id_, mask).value();
497 return *this;
498 }
499
500 /// @wrapper{services::writeWriteMask}
502 services::writeUserWriteMask(connection_, id_, mask).value();
503 return *this;
504 }
505
506 /// @wrapper{services::writeIsAbstract}
507 Node& writeIsAbstract(bool isAbstract) {
508 services::writeIsAbstract(connection_, id_, isAbstract).value();
509 return *this;
510 }
511
512 /// @wrapper{services::writeSymmetric}
513 Node& writeSymmetric(bool symmetric) {
514 services::writeSymmetric(connection_, id_, symmetric).value();
515 return *this;
516 }
517
518 /// @wrapper{services::writeInverseName}
520 services::writeInverseName(connection_, id_, name).value();
521 return *this;
522 }
523
524 /// @wrapper{services::writeContainsNoLoops}
525 Node& writeContainsNoLoops(bool containsNoLoops) {
526 services::writeContainsNoLoops(connection_, id_, containsNoLoops).value();
527 return *this;
528 }
529
530 /// @wrapper{services::writeEventNotifier}
532 services::writeEventNotifier(connection_, id_, mask).value();
533 return *this;
534 }
535
536 /// @wrapper{services::writeDataValue}
538 services::writeDataValue(connection_, id_, value).value();
539 return *this;
540 }
541
542 /// @wrapper{services::writeValue}
543 Node& writeValue(const Variant& value) {
544 services::writeValue(connection_, id_, value).value();
545 return *this;
546 }
547
548 /// Write scalar to variable node.
549 template <typename T>
550 Node& writeValueScalar(const T& value) {
551 // NOLINTNEXTLINE, variant isn't modified, try to avoid copy
552 writeValue(Variant::fromScalar<VariantPolicy::ReferenceIfPossible>(const_cast<T&>(value)));
553 return *this;
554 }
555
556 /// Write array value to variable node.
557 template <typename ArrayLike>
558 Node& writeValueArray(ArrayLike&& array) {
560 Variant::fromArray<VariantPolicy::ReferenceIfPossible>(std::forward<ArrayLike>(array))
561 );
562 return *this;
563 }
564
565 /// Write range of elements as array value to variable node.
566 template <typename InputIt>
567 Node& writeValueArray(InputIt first, InputIt last) {
568 writeValue(Variant::fromArray<VariantPolicy::ReferenceIfPossible>(first, last));
569 return *this;
570 }
571
572 /// @wrapper{services::writeDataType}
573 Node& writeDataType(const NodeId& typeId) {
574 services::writeDataType(connection_, id_, typeId).value();
575 return *this;
576 }
577
578 /// @overload
579 /// Deduce the `typeId` from the template type.
580 template <typename T>
582 return writeDataType(asWrapper<NodeId>(getDataType<T>().typeId));
583 }
584
585 /// @wrapper{services::writeValueRank}
587 services::writeValueRank(connection_, id_, valueRank).value();
588 return *this;
589 }
590
591 /// @wrapper{services::writeArrayDimensions}
593 services::writeArrayDimensions(connection_, id_, dimensions).value();
594 return *this;
595 }
596
597 /// @wrapper{services::writeAccessLevel}
599 services::writeAccessLevel(connection_, id_, mask).value();
600 return *this;
601 }
602
603 /// @wrapper{services::writeUserAccessLevel}
605 services::writeUserAccessLevel(connection_, id_, mask).value();
606 return *this;
607 }
608
609 /// @wrapper{services::writeMinimumSamplingInterval}
610 Node& writeMinimumSamplingInterval(double milliseconds) {
611 services::writeMinimumSamplingInterval(connection_, id_, milliseconds).value();
612 return *this;
613 }
614
615 /// @wrapper{services::writeHistorizing}
616 Node& writeHistorizing(bool historizing) {
617 services::writeHistorizing(connection_, id_, historizing).value();
618 return *this;
619 }
620
621 /// @wrapper{services::writeExecutable}
622 Node& writeExecutable(bool executable) {
623 services::writeExecutable(connection_, id_, executable).value();
624 return *this;
625 }
626
627 /// @wrapper{services::writeUserExecutable}
628 Node& writeUserExecutable(bool userExecutable) {
629 services::writeUserExecutable(connection_, id_, userExecutable).value();
630 return *this;
631 }
632
633 /// Write the value of an object property.
634 /// @param propertyName Browse name of the property (variable node)
635 /// @param value New value
636 Node& writeObjectProperty(const QualifiedName& propertyName, const Variant& value) {
637 browseObjectProperty(propertyName).writeValue(value);
638 return *this;
639 }
640
641private:
642 Node browseObjectProperty(const QualifiedName& propertyName) {
643 auto result =
645 connection_,
646 BrowsePath(id_, {{ReferenceTypeId::HasProperty, false, true, propertyName}})
647 ).value();
648 result.getStatusCode().throwIfBad();
649 for (auto&& target : result.getTargets()) {
650 if (target.getTargetId().isLocal()) {
651 return {connection_, std::move(target.getTargetId().getNodeId())};
652 }
653 }
654 throw BadStatus(UA_STATUSCODE_BADNOTFOUND);
655 }
656
657 Connection& connection_;
658 NodeId id_;
659};
660
661/* ---------------------------------------------------------------------------------------------- */
662
663template <typename Connection>
664bool operator==(const Node<Connection>& lhs, const Node<Connection>& rhs) noexcept {
665 return (lhs.connection() == rhs.connection()) && (lhs.id() == rhs.id());
666}
667
668template <typename Connection>
669bool operator!=(const Node<Connection>& lhs, const Node<Connection>& rhs) noexcept {
670 return !(lhs == rhs);
671}
672
673} // namespace opcua
Exception for bad status codes from open62541 UA_STATUSCODE_*.
Bitmask using (scoped) enums.
Definition Bitmask.h:108
UA_BrowseDescription wrapper class.
Definition Composed.h:963
UA_DataTypeAttributes wrapper class.
Definition Composed.h:539
UA_DataValue wrapper class.
Definition DataValue.h:20
UA_LocalizedText wrapper class.
Definition Builtin.h:288
UA_MethodAttributes wrapper class.
Definition Composed.h:436
UA_NodeId wrapper class.
Definition NodeId.h:36
High-level node class to access node attribute, browse and populate address space.
Definition Node.h:42
double readMinimumSamplingInterval()
Read the AttributeId::MinimumSamplingInterval attribute of a node.
Definition Node.h:457
bool readIsAbstract()
Read the AttributeId::IsAbstract attribute of a node.
Definition Node.h:385
Node & writeUserAccessLevel(Bitmask< AccessLevel > mask)
Write the AttributeId::UserAccessLevel attribute of a node.
Definition Node.h:604
QualifiedName readBrowseName()
Read the AttributeId::BrowseName attribute of a node.
Definition Node.h:360
Bitmask< AccessLevel > readUserAccessLevel()
Read the AttributeId::UserAccessLevel attribute of a node.
Definition Node.h:452
Variant readObjectProperty(const QualifiedName &propertyName)
Read the value of an object property.
Definition Node.h:478
LocalizedText readDisplayName()
Read the AttributeId::DisplayName attribute of a node.
Definition Node.h:365
Node & writeArrayDimensions(Span< const uint32_t > dimensions)
Write the AttributeId::ArrayDimensions attribute of a node.
Definition Node.h:592
Node & writeUserWriteMask(Bitmask< WriteMask > mask)
Write the AttributeId::WriteMask attribute of a node.
Definition Node.h:501
const Connection & getConnection() const noexcept
Definition Node.h:72
Node & writeDisplayName(const LocalizedText &name)
Write the AttributeId::DisplayName attribute of a node.
Definition Node.h:483
Node & writeInverseName(const LocalizedText &name)
Write the AttributeId::InverseName attribute of a node.
Definition Node.h:519
Node addView(const NodeId &id, std::string_view browseName, const ViewAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::Organizes)
Add view.
Definition Node.h:221
Node & writeValueScalar(const T &value)
Write scalar to variable node.
Definition Node.h:550
Node & writeContainsNoLoops(bool containsNoLoops)
Write the AttributeId::ContainsNoLoops attribute of a node.
Definition Node.h:525
DataValue readDataValue()
Read the AttributeId::Value attribute of a node as a DataValue object.
Definition Node.h:410
Node & addModellingRule(ModellingRule rule)
Add modelling rule.
Definition Node.h:240
Node addObjectType(const NodeId &id, std::string_view browseName, const ObjectTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype)
Add object type.
Definition Node.h:168
std::vector< Variant > callMethod(const NodeId &methodId, Span< const Variant > inputArguments)
Call a server method and return results.
Definition Node.h:349
Node addProperty(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={})
Add property.
Definition Node.h:134
Connection & connection() noexcept
Get the server/client instance.
Definition Node.h:55
Node & writeValueArray(ArrayLike &&array)
Write array value to variable node.
Definition Node.h:558
Node & writeUserExecutable(bool userExecutable)
Write the AttributeId::UserExecutable attribute of a node.
Definition Node.h:628
Node & writeObjectProperty(const QualifiedName &propertyName, const Variant &value)
Write the value of an object property.
Definition Node.h:636
std::vector< Node > browseChildren(const NodeId &referenceType=ReferenceTypeId::HierarchicalReferences, Bitmask< NodeClass > nodeClassMask=NodeClass::Unspecified)
Browse child nodes (only local nodes).
Definition Node.h:309
Node(Connection &connection, const NodeId &id)
Create a Node object.
Definition Node.h:45
void deleteNode(bool deleteReferences=true)
Delete node.
Definition Node.h:246
Node & writeHistorizing(bool historizing)
Write the AttributeId::Historizing attribute of a node.
Definition Node.h:616
LocalizedText readInverseName()
Read the AttributeId::InverseName attribute of a node.
Definition Node.h:395
NodeClass readNodeClass()
Read the AttributeId::NodeClass attribute of a node.
Definition Node.h:355
Node & writeSymmetric(bool symmetric)
Write the AttributeId::Symmetric attribute of a node.
Definition Node.h:513
bool exists() noexcept
Check if the Node exists in the most efficient manner.
Node addFolder(const NodeId &id, std::string_view browseName, const ObjectAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add folder.
Definition Node.h:93
std::vector< uint32_t > readArrayDimensions()
Read the AttributeId::ArrayDimensions attribute of a node.
Definition Node.h:442
Node & writeDataValue(const DataValue &value)
Write the AttributeId::Value attribute of a node as a DataValue object.
Definition Node.h:537
Node addObject(const NodeId &id, std::string_view browseName, const ObjectAttributes &attributes={}, const NodeId &objectType=ObjectTypeId::BaseObjectType, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add object.
Definition Node.h:106
const NodeId & getNodeId() const noexcept
Definition Node.h:83
std::vector< Node > browseReferencedNodes(BrowseDirection browseDirection=BrowseDirection::Both, const NodeId &referenceType=ReferenceTypeId::References, bool includeSubtypes=true, Bitmask< NodeClass > nodeClassMask=NodeClass::Unspecified)
Browse referenced nodes (only local nodes).
Definition Node.h:283
Node addDataType(const NodeId &id, std::string_view browseName, const DataTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype)
Add data type.
Definition Node.h:208
std::vector< ReferenceDescription > browseReferences(BrowseDirection browseDirection=BrowseDirection::Both, const NodeId &referenceType=ReferenceTypeId::References, bool includeSubtypes=true, Bitmask< NodeClass > nodeClassMask=NodeClass::Unspecified)
Browse references.
Definition Node.h:265
T readValueScalar()
Read scalar value from variable node.
Definition Node.h:421
bool readExecutable()
Read the AttributeId::Executable attribute of a node.
Definition Node.h:467
bool readContainsNoLoops()
Read the AttributeId::ContainsNoLoops attribute of a node.
Definition Node.h:400
Bitmask< AccessLevel > readAccessLevel()
Read the AttributeId::AccessLevel attribute of a node.
Definition Node.h:447
Node addReferenceType(const NodeId &id, std::string_view browseName, const ReferenceTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype)
Add reference type.
Definition Node.h:195
Variant readValue()
Read the AttributeId::Value attribute of a node.
Definition Node.h:415
Node & writeValueRank(ValueRank valueRank)
Write the AttributeId::ValueRank attribute of a node.
Definition Node.h:586
Node(Connection &connection, NodeId &&id)
Create a Node object.
Definition Node.h:50
bool readSymmetric()
Read the AttributeId::Symmetric attribute of a node.
Definition Node.h:390
Node & writeDataType(const NodeId &typeId)
Write the AttributeId::DataType attribute of a node.
Definition Node.h:573
Node & writeIsAbstract(bool isAbstract)
Write the AttributeId::IsAbstract attribute of a node.
Definition Node.h:507
Node & deleteReference(const NodeId &targetId, const NodeId &referenceType, bool isForward, bool deleteBidirectional)
Delete reference.
Definition Node.h:251
LocalizedText readDescription()
Read the AttributeId::Description attribute of a node.
Definition Node.h:370
Node addVariableType(const NodeId &id, std::string_view browseName, const VariableTypeAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasSubtype)
Add variable type.
Definition Node.h:181
Bitmask< WriteMask > readUserWriteMask()
Read the AttributeId::UserWriteMask attribute of a node.
Definition Node.h:380
Node & writeDataType()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Node.h:581
Connection & getConnection() noexcept
Definition Node.h:66
Node & writeValue(const Variant &value)
Write the AttributeId::Value attribute of a node.
Definition Node.h:543
bool readHistorizing()
Read the AttributeId::Historizing attribute of a node.
Definition Node.h:462
ValueRank readValueRank()
Read the AttributeId::ValueRank attribute of a node.
Definition Node.h:437
Node & writeExecutable(bool executable)
Write the AttributeId::Executable attribute of a node.
Definition Node.h:622
Node & writeWriteMask(Bitmask< WriteMask > mask)
Write the AttributeId::WriteMask attribute of a node.
Definition Node.h:495
Node & writeEventNotifier(Bitmask< EventNotifier > mask)
Write the AttributeId::EventNotifier attribute of a node.
Definition Node.h:531
Node & addReference(const NodeId &targetId, const NodeId &referenceType, bool forward=true)
Add reference.
Definition Node.h:234
NodeId readDataType()
Read the AttributeId::DataType attribute of a node.
Definition Node.h:432
std::vector< T > readValueArray()
Read array value from variable node.
Definition Node.h:427
const Connection & connection() const noexcept
Get the server/client instance.
Definition Node.h:60
Node addVariable(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add variable.
Definition Node.h:120
Node & writeValueArray(InputIt first, InputIt last)
Write range of elements as array value to variable node.
Definition Node.h:567
Node & writeAccessLevel(Bitmask< AccessLevel > mask)
Write the AttributeId::AccessLevel attribute of a node.
Definition Node.h:598
Node addMethod(const NodeId &id, std::string_view browseName, services::MethodCallback callback, Span< const Argument > inputArguments, Span< const Argument > outputArguments, const MethodAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add method.
Definition Node.h:143
Node browseParent()
Browse parent node.
Definition Node.h:332
Bitmask< WriteMask > readWriteMask()
Read the AttributeId::WriteMask attribute of a node.
Definition Node.h:375
Node & writeDescription(const LocalizedText &desc)
Write the AttributeId::Description attribute of a node.
Definition Node.h:489
bool readUserExecutable()
Read the AttributeId::UserExecutable attribute of a node.
Definition Node.h:472
const NodeId & id() const noexcept
Get the node id.
Definition Node.h:77
Bitmask< EventNotifier > readEventNotifier()
Read the AttributeId::EventNotifier attribute of a node.
Definition Node.h:405
Node & writeMinimumSamplingInterval(double milliseconds)
Write the AttributeId::MinimumSamplingInterval attribute of a node.
Definition Node.h:610
Node browseChild(Span< const QualifiedName > path)
Browse child node specified by its relative path from this node (only local nodes).
Definition Node.h:319
UA_ObjectAttributes wrapper class.
Definition Composed.h:356
UA_ObjectTypeAttributes wrapper class.
Definition Composed.h:454
UA_QualifiedName wrapper class.
Definition Builtin.h:253
UA_ReferenceTypeAttributes wrapper class.
Definition Composed.h:519
constexpr void value() const
Get the value of the Result.
Definition Result.h:389
View to a contiguous sequence of objects, similar to std::span in C++20.
Definition Span.h:27
UA_VariableAttributes wrapper class.
Definition Composed.h:374
UA_VariableAttributes wrapper class.
Definition Composed.h:471
UA_Variant wrapper class.
Definition Variant.h:46
UA_ViewAttributes wrapper class.
Definition Composed.h:555
Result< NodeId > addReferenceType(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const ReferenceTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype) noexcept
Add reference type.
Result< NodeId > addVariableType(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const VariableTypeAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasSubtype) noexcept
Add variable type.
Result< NodeId > addObject(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const ObjectAttributes &attributes={}, const NodeId &objectType=ObjectTypeId::BaseObjectType, const NodeId &referenceType=ReferenceTypeId::HasComponent) noexcept
Add object.
std::function< void(Span< const Variant > input, Span< Variant > output)> MethodCallback
Method callback.
Result< NodeId > addView(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const ViewAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::Organizes) noexcept
Add view.
Result< NodeId > addProperty(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}) noexcept
Add property.
Result< NodeId > addDataType(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const DataTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype) noexcept
Add data type.
Result< NodeId > addVariable(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasComponent) noexcept
Add variable.
Result< NodeId > addObjectType(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const ObjectTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype) noexcept
Add object type.
Result< NodeId > addFolder(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const ObjectAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasComponent) noexcept
Add folder.
Result< NodeId > addMethod(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, MethodCallback callback, Span< const Argument > inputArguments, Span< const Argument > outputArguments, const MethodAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasComponent) noexcept
Add method.
Result< void > addReference(T &connection, const NodeId &sourceId, const NodeId &targetId, const NodeId &referenceType, bool forward=true) noexcept
Add reference.
Result< void > addModellingRule(T &connection, const NodeId &id, ModellingRule rule) noexcept
Add modelling rule.
Result< std::vector< ReferenceDescription > > browseAll(T &connection, const BrowseDescription &bd, uint32_t maxReferences=0)
Discover all the references of a specified node (without calling browseNext).
Definition View.h:366
CallResponse call(Client &connection, const CallRequest &request) noexcept
Call server methods.
Result< void > deleteNode(T &connection, const NodeId &id, bool deleteReferences=true) noexcept
Delete node.
Result< void > deleteReference(T &connection, const NodeId &sourceId, const NodeId &targetId, const NodeId &referenceType, bool isForward, bool deleteBidirectional) noexcept
Delete reference.
Result< bool > readContainsNoLoops(T &connection, const NodeId &id) noexcept
Read the AttributeId::ContainsNoLoops attribute of a node.
Result< double > readMinimumSamplingInterval(T &connection, const NodeId &id) noexcept
Read the AttributeId::MinimumSamplingInterval attribute of a node.
Result< NodeId > readDataType(T &connection, const NodeId &id) noexcept
Read the AttributeId::DataType attribute of a node.
Result< bool > readUserExecutable(T &connection, const NodeId &id) noexcept
Read the AttributeId::UserExecutable attribute of a node.
Result< LocalizedText > readInverseName(T &connection, const NodeId &id) noexcept
Read the AttributeId::InverseName attribute of a node.
Result< NodeClass > readNodeClass(T &connection, const NodeId &id) noexcept
Read the AttributeId::NodeClass attribute of a node.
Result< Bitmask< EventNotifier > > readEventNotifier(T &connection, const NodeId &id) noexcept
Read the AttributeId::EventNotifier attribute of a node.
Result< DataValue > readDataValue(T &connection, const NodeId &id) noexcept
Read the AttributeId::Value attribute of a node as a DataValue object.
Definition Attribute.h:296
Result< Bitmask< WriteMask > > readUserWriteMask(T &connection, const NodeId &id) noexcept
Read the AttributeId::UserWriteMask attribute of a node.
Result< bool > readHistorizing(T &connection, const NodeId &id) noexcept
Read the AttributeId::Historizing attribute of a node.
Result< LocalizedText > readDisplayName(T &connection, const NodeId &id) noexcept
Read the AttributeId::DisplayName attribute of a node.
Result< QualifiedName > readBrowseName(T &connection, const NodeId &id) noexcept
Read the AttributeId::BrowseName attribute of a node.
Result< bool > readExecutable(T &connection, const NodeId &id) noexcept
Read the AttributeId::Executable attribute of a node.
Result< Bitmask< WriteMask > > readWriteMask(T &connection, const NodeId &id) noexcept
Read the AttributeId::WriteMask attribute of a node.
Result< LocalizedText > readDescription(T &connection, const NodeId &id) noexcept
Read the AttributeId::Description attribute of a node.
Result< Variant > readValue(T &connection, const NodeId &id) noexcept
Read the AttributeId::Value attribute of a node.
Result< ValueRank > readValueRank(T &connection, const NodeId &id) noexcept
Read the AttributeId::ValueRank attribute of a node.
Result< bool > readIsAbstract(T &connection, const NodeId &id) noexcept
Read the AttributeId::IsAbstract attribute of a node.
Result< bool > readSymmetric(T &connection, const NodeId &id) noexcept
Read the AttributeId::Symmetric attribute of a node.
Result< Bitmask< AccessLevel > > readUserAccessLevel(T &connection, const NodeId &id) noexcept
Read the AttributeId::UserAccessLevel attribute of a node.
Result< Bitmask< AccessLevel > > readAccessLevel(T &connection, const NodeId &id) noexcept
Read the AttributeId::AccessLevel attribute of a node.
Result< std::vector< uint32_t > > readArrayDimensions(T &connection, const NodeId &id) noexcept
Read the AttributeId::ArrayDimensions attribute of a node.
Result< BrowsePathResult > browseSimplifiedBrowsePath(T &connection, const NodeId &origin, Span< const QualifiedName > browsePath)
A simplified version of translateBrowsePathToNodeIds.
Definition View.h:255
Result< BrowsePathResult > translateBrowsePathToNodeIds(T &connection, const BrowsePath &browsePath) noexcept
Translate a browse path to NodeIds.
Result< void > writeEventNotifier(T &connection, const NodeId &id, Bitmask< EventNotifier > eventNotifier) noexcept
Write the AttributeId::EventNotifier attribute of a node.
Result< void > writeMinimumSamplingInterval(T &connection, const NodeId &id, double minimumSamplingInterval) noexcept
Write the AttributeId::MinimumSamplingInterval attribute of a node.
Result< void > writeHistorizing(T &connection, const NodeId &id, bool historizing) noexcept
Write the AttributeId::Historizing attribute of a node.
Result< void > writeDescription(T &connection, const NodeId &id, const LocalizedText &description) noexcept
Write the AttributeId::Description attribute of a node.
Result< void > writeAccessLevel(T &connection, const NodeId &id, Bitmask< AccessLevel > accessLevel) noexcept
Write the AttributeId::AccessLevel attribute of a node.
Result< void > writeContainsNoLoops(T &connection, const NodeId &id, const bool &containsNoLoops) noexcept
Write the AttributeId::ContainsNoLoops attribute of a node.
Result< void > writeValueRank(T &connection, const NodeId &id, ValueRank valueRank) noexcept
Write the AttributeId::ValueRank attribute of a node.
Result< void > writeWriteMask(T &connection, const NodeId &id, Bitmask< WriteMask > writeMask) noexcept
Write the AttributeId::WriteMask attribute of a node.
Result< void > writeDisplayName(T &connection, const NodeId &id, const LocalizedText &displayName) noexcept
Write the AttributeId::DisplayName attribute of a node.
Result< void > writeDataValue(T &connection, const NodeId &id, const DataValue &value) noexcept
Write the AttributeId::Value attribute of a node as a DataValue object.
Definition Attribute.h:325
Result< void > writeUserAccessLevel(T &connection, const NodeId &id, Bitmask< AccessLevel > userAccessLevel) noexcept
Write the AttributeId::UserAccessLevel attribute of a node.
Result< void > writeDataType(T &connection, const NodeId &id, const NodeId &dataType) noexcept
Write the AttributeId::DataType attribute of a node.
Result< void > writeUserWriteMask(T &connection, const NodeId &id, Bitmask< WriteMask > userWriteMask) noexcept
Write the AttributeId::UserWriteMask attribute of a node.
Result< void > writeInverseName(T &connection, const NodeId &id, const LocalizedText &inverseName) noexcept
Write the AttributeId::InverseName attribute of a node.
Result< void > writeExecutable(T &connection, const NodeId &id, bool executable) noexcept
Write the AttributeId::Executable attribute of a node.
Result< void > writeArrayDimensions(T &connection, const NodeId &id, Span< const uint32_t > arrayDimensions) noexcept
Write the AttributeId::ArrayDimensions attribute of a node.
Result< void > writeValue(T &connection, const NodeId &id, const Variant &value) noexcept
Write the AttributeId::Value attribute of a node.
Result< void > writeUserExecutable(T &connection, const NodeId &id, bool userExecutable) noexcept
Write the AttributeId::UserExecutable attribute of a node.
Result< void > writeIsAbstract(T &connection, const NodeId &id, bool isAbstract) noexcept
Write the AttributeId::IsAbstract attribute of a node.
Result< void > writeSymmetric(T &connection, const NodeId &id, bool symmetric) noexcept
Write the AttributeId::Symmetric attribute of a node.
NodeClass
Node class.
Definition Common.h:138
ValueRank
Value rank.
Definition Common.h:224
BrowseDirection
Browse direction.
Definition Common.h:273
bool operator!=(const Client &lhs, const Client &rhs) noexcept
Definition Client.h:204
ModellingRule
Modelling rules.
Definition Common.h:257
bool operator==(const Client &lhs, const Client &rhs) noexcept
Definition Client.h:200
#define UA_STATUSCODE_BADNOTFOUND
#define UA_STATUSCODE_BADNOMATCH
UA_NODECLASS_UNSPECIFIED