integer_node.hpp
1 #pragma once
2 
3 #include "../global.hpp"
4 
5 #include "opcua.hpp"
6 #include "exception.hpp"
7 
8 #include "variable_node.hpp"
9 
10 namespace Cvb
11 {
12 
13 CVB_BEGIN_INLINE_NS;
14 
15 namespace OpcUa
16 {
25 {
26  friend class Client;
27  friend class Server;
28 
29 public:
30 
46  static IntegerNodePtr Create(std::uint16_t namespaceIndex, const Cvb::String & name, const OpcUa::NodeID & parentNodeID, std::int64_t value)
47  {
48  std::function<CExports::CVOPCNODE(void)> maker = [&](void)
49  {
50  auto node = CExports::__CreateCVOPCIntegerNode(static_cast<CExports::cvbuint16_t>(namespaceIndex), name.c_str(), parentNodeID.Handle(), CExports::CVOPC_VT_DataVariable, CExports::TCVOPCDataType::CVOPC_DT_Int64, value);
51  if (node)
52  return node;
54  };
55  auto vnode(new VariableNode(std::move(*OpcUa::BaseNode::CreateHelper(maker))));
56  auto fnode = IntegerNodePtr(new IntegerNode(std::move(*vnode)));
57  if (!fnode)
59  return fnode;
60  }
61 
68  {
70  }
71 
77  void SetValue(std::int64_t value)
78  {
80  }
81 
82 private:
83 
84  explicit IntegerNode(VariableNode && variableNode) noexcept
85  : VariableNode(std::move(variableNode))
86  {
87  }
88 };
89 }
90 CVB_END_INLINE_NS
91 }
std::int64_t Value() const
Returns the saved value of the node.
Definition: integer_node.hpp:67
void SetAttributeAsInt(AttributeID attributeID, std::int64_t value)
Set specific Information about a Opcua::BaseNode.
Definition: decl_base_node.hpp:177
STL class.
static IntegerNodePtr Create(std::uint16_t namespaceIndex, const Cvb::String &name, const OpcUa::NodeID &parentNodeID, std::int64_t value)
Creates an OPCUA Variable with the specified parameter, data type and set its value as an integer.
Definition: integer_node.hpp:46
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
Value of the node (VariableNode (See OpcUa::DataType))
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
A Node with integer values provides an interface for storage and manipulation of integer (default int...
Definition: integer_node.hpp:24
std::int64_t GetAttributeAsInt(AttributeID attributeID) const
Return specific Information about a Opcua::BaseNode.
Definition: decl_base_node.hpp:162
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
void SetValue(std::int64_t value)
Set value of the node to the given value.
Definition: integer_node.hpp:77
std::shared_ptr< IntegerNode > IntegerNodePtr
Convenience shared pointer for IntegerNode.
Definition: opcua.hpp:85
An OPCUA VariableNode object. It handles the data modeling acording to the OPCUA specification.
Definition: variable_node.hpp:25
An OPCUA Client object. This class handles the client side of the OPCUA client/server interaction.
Definition: decl_client.hpp:33
An OPCUA server object.
Definition: decl_server.hpp:33