integer_base_node.hpp
1 #pragma once
2 
3 #include "../global.hpp"
4 
5 #include "selector_node.hpp"
6 
8 #include "_detail/iconfigurable_integer_base_node.hpp"
10 
11 namespace Cvb
12 {
13 CVB_BEGIN_INLINE_NS
14 namespace GevServer
15 {
17 
20  : public SelectorNode
22  , public Private::IConfigurableIntegerBaseNode
24 {
25 public:
26  IntegerBaseNode(HandleGuard<Node> &&guard) noexcept : SelectorNode(std::move(guard)) {}
27 
29 
36  std::int64_t Increment() const { return GetInfoAsInt(NodeInfo::Increment); }
37 
39 
43  std::int64_t Max() const { return GetInfoAsInt(NodeInfo::Max); }
44 
46 
50  std::int64_t Min() const { return GetInfoAsInt(NodeInfo::Min); }
51 
53 
58  {
59  return static_cast<GenApi::NumberRepresentation>(GetInfoAsInt(NodeInfo::NumberRepresentation));
60  }
61 
63 
66  void SetRepresentation(const GenApi::NumberRepresentation &representation)
67  {
68  SetInfoAsInt(NodeInfo::NumberRepresentation, static_cast<std::int64_t>(representation));
69  }
70 
72 
76  virtual String Unit() const
77  {
78  return String(); // Not yet implemented
79  }
80 
81  virtual void SetUnit(const String& /*unit*/)
82  {
83  }
84 
86 
91  {
92  return static_cast<std::int64_t>(NativeCall<CExports::cvbint64_t>(
93  [&](CExports::cvbint64_t &value) { return CVB_CALL_CAPI(GSNGetAsInteger(Handle(), value)); }));
94  }
95 
97 
101  void SetValue(const std::int64_t &value)
102  {
103  NativeCall([&]() { return CVB_CALL_CAPI(GSNSetAsInteger(Handle(), static_cast<CExports::cvbint64_t>(value))); });
104  }
105 
110  void FromString(const String &value) override
111  {
112  NativeCall([&]() { return CExports::GSNSetAsStringTyped(Handle(), value.data()); });
113  }
114 
121  String ToString() const override
122  {
123  size_t nameLength = 0;
124  auto resultNameLength = CExports::GSNGetAsStringTyped(Handle(), reinterpret_cast<Char *>(0), nameLength);
125  if (resultNameLength < 0)
126  std::rethrow_exception(
127  CvbException::FromCvbResult(resultNameLength, "failed to get string representation name length"));
128 
129  nameLength += sizeof(Char);
130  std::vector<Char> buffer(static_cast<size_t>(nameLength));
131 
132  auto resultBuffer = CExports::GSNGetAsStringTyped(Handle(), buffer.data(), nameLength);
133  if (resultBuffer < 0)
134  std::rethrow_exception(
135  CvbException::FromCvbResult(resultBuffer, "failed to get string representation of this node"));
136 
137  return buffer.data();
138  }
139 };
140 }
141 CVB_END_INLINE_NS
142 }
Gets the maximum value.
std::int64_t Value() const
Gets the value of this integer node.
Definition: integer_base_node.hpp:90
void SetValue(const std::int64_t &value)
Sets the value of this integer node.
Definition: integer_base_node.hpp:101
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
std::int64_t Max() const
Gets the maximal allowed number for this value.
Definition: integer_base_node.hpp:43
Node is a string node (no reg).
std::int64_t Increment() const
Gets the increment of this value.
Definition: integer_base_node.hpp:36
Gets the minimum value.
char Char
Character type for wide characters or unicode characters.
Definition: string.hpp:59
virtual String Unit() const
Gets the unit of this node's value.
Definition: integer_base_node.hpp:76
void SetRepresentation(const GenApi::NumberRepresentation &representation)
Sets how the value is to be represented.
Definition: integer_base_node.hpp:66
NumberRepresentation
Defines how a number is to be interpreted/displayed in a graphical user interface.
Definition: genapi.hpp:138
void FromString(const String &value) override
Sets this node's value from the string value .
Definition: integer_base_node.hpp:110
GenApi::NumberRepresentation Representation() const
Gets how the value is to be represented.
Definition: integer_base_node.hpp:57
Groups other nodes that are dependent on this one.
Definition: selector_node.hpp:24
STL class.
String ToString() const override
Gets the string representation of this node.
Definition: integer_base_node.hpp:121
std::int64_t Min() const
Gets the minimal allowed number for this value.
Definition: integer_base_node.hpp:50
Represents an integer number.
Definition: integer_base_node.hpp:19
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:101
Accesses the representation of a number.