object_node.hpp
1 #pragma once
2 
3 #include "../global.hpp"
4 
5 #include "opcua.hpp"
6 #include "exception.hpp"
7 
8 #include "base_node.hpp"
9 
10 namespace Cvb
11 {
12 CVB_BEGIN_INLINE_NS
13 
14 template <>
15 inline HandleGuard<OpcUa::ObjectNode>::HandleGuard(void * handle) noexcept
16  : HandleGuard<OpcUa::ObjectNode>(handle, [](void* handle)
17 {
18  CVB_CALL_CAPI(ReleaseObject(handle));
19 })
20 {
21 }
22 namespace OpcUa
23 {
24 
36 {
37 public:
50  const std::uint16_t NameSpaceIndex, const Cvb::String & Name, const OpcUa::NodeID & Parent, const OpcUa::NodeID & TypeDefinition
51  )
52  {
53  std::function<CExports::CVOPCNODE(void)> maker = [&](void)
54  {
55  auto node = CExports::__CreateCVOPCObjectFromTypeNode(
56  static_cast<CExports::cvbuint16_t>(NameSpaceIndex), Name.c_str(), Parent.Handle(), TypeDefinition.Handle());
57  if (node)
58  return node;
60  };
61  HandleGuard<BaseNode> guard(maker());
62 
63  if (!guard.Handle())
65 
66  return ObjectNodePtr(new ObjectNode(std::move(guard)));
67  }
68 protected:
69 
70 
71  explicit ObjectNode(OpcUa::BaseNode && node) noexcept
72  : OpcUa::BaseNode(std::move(node))
73  {
74  }
75 
76 
77 };
78 
79 CVB_END_INLINE_NS
80 }
81 }
STL class.
An OPCUA NodeID object. NodeIDs provide a unique identifier for OPCUA nodes, i.e. they help with node...
Definition: node_id.hpp:37
const int CVB_ERROR
Generic unspecified error.
Definition: exception.hpp:24
std::shared_ptr< ObjectNode > ObjectNodePtr
Convenience shared pointer for ObjectNode.
Definition: opcua.hpp:75
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
An OPCUA Object Node object. This is the "base" of many more complex node. However the defining featu...
Definition: object_node.hpp:35
const int CVB_NOTSUPPORTED
A certain feature is not supported.
Definition: exception.hpp:60
void * Handle() const noexcept
Return the C-API handle.
Definition: node_id.hpp:171
Special runtime exception to carry a native error code.
Definition: exception.hpp:24
static ObjectNodePtr CreateFromType(const std::uint16_t NameSpaceIndex, const Cvb::String &Name, const OpcUa::NodeID &Parent, const OpcUa::NodeID &TypeDefinition)
Creates a OPCUA object node with a given type definition.
Definition: object_node.hpp:49
An OPCUA BaseNode. This is the base for all other node classes. For instantiation of a specific node ...
Definition: decl_base_node.hpp:34