lordgamez commented on code in PR #2261:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2261#discussion_r4016174813
##########
extensions/opc/include/OPCCommon.h:
##########
@@ -58,6 +58,43 @@ enum class OPCNodeDataType{
String
};
+// RAII owner for a UA_NodeId that calls UA_NodeId_clear to free node id
allocation
+class NodeId {
+ public:
+ NodeId() = default;
+ explicit NodeId(UA_NodeId id) noexcept : id_(id) {} // takes ownership of
an already-built node id
+ NodeId(const NodeId&) = delete;
+ NodeId& operator=(const NodeId&) = delete;
+ NodeId(NodeId&& other) noexcept : id_(other.id_) { other.id_ =
UA_NODEID_NULL; }
+ NodeId& operator=(NodeId&& other) noexcept {
+ if (this != &other) {
+ UA_NodeId_clear(&id_);
+ id_ = other.id_;
+ other.id_ = UA_NODEID_NULL;
+ }
+ return *this;
+ }
+ ~NodeId() noexcept { UA_NodeId_clear(&id_); }
Review Comment:
Yes, UA_NODEID_NULL is a numeric node id with 0 namespace and 0 id, when
UA_NodeId_clear is called that is what the id is set to after the free
operation. The UA_NodeId_clear operation is no-op for all numeric node ids, so
nothing is done when it is called for an already cleared object.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]