CVB++ 14.0
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
11namespace Cvb
12{
13CVB_BEGIN_INLINE_NS
14namespace GevServer
15{
17
20 : public SelectorNode
22 , public Private::IConfigurableIntegerBaseNode
24{
25public:
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
68 {
69 SetInfoAsInt(NodeInfo::NumberRepresentation, static_cast<std::int64_t>(representation));
70 }
71
73
77 virtual String Unit() const
78 {
79 return String(); // Not yet implemented
80 }
81
82 virtual void SetUnit(const String& /*unit*/)
83 {
84 }
85
87
92 {
93 return static_cast<std::int64_t>(NativeCall<CExports::cvbint64_t>(
94 [&](CExports::cvbint64_t &value) { return CVB_CALL_CAPI(GSNGetAsInteger(Handle(), value)); }));
95 }
96
98
102 void SetValue(const std::int64_t &value)
103 {
104 NativeCall([&]() { return CVB_CALL_CAPI(GSNSetAsInteger(Handle(), static_cast<CExports::cvbint64_t>(value))); });
105 }
106
111 void FromString(const String &value) override
112 {
113 NativeCall([&]() { return CExports::GSNSetAsStringTyped(Handle(), value.data()); });
114 }
115
122 String ToString() const override
123 {
124 size_t nameLength = 0;
125 auto resultNameLength = CExports::GSNGetAsStringTyped(Handle(), reinterpret_cast<Char *>(0), nameLength);
126 if (resultNameLength < 0)
127 std::rethrow_exception(
128 CvbException::FromCvbResult(resultNameLength, "failed to get string representation name length"));
129
130 nameLength += sizeof(Char);
131 std::vector<Char> buffer(static_cast<size_t>(nameLength));
132
133 auto resultBuffer = CExports::GSNGetAsStringTyped(Handle(), buffer.data(), nameLength);
134 if (resultBuffer < 0)
135 std::rethrow_exception(
136 CvbException::FromCvbResult(resultBuffer, "failed to get string representation of this node"));
137
138 return buffer.data();
139 }
140};
141}
142CVB_END_INLINE_NS
143}
Represents an integer number.
Definition: integer_base_node.hpp:24
void SetRepresentation(const GenApi::NumberRepresentation &representation)
Sets how the value is to be represented.
Definition: integer_base_node.hpp:67
std::int64_t Min() const
Gets the minimal allowed number for this value.
Definition: integer_base_node.hpp:50
std::int64_t Max() const
Gets the maximal allowed number for this value.
Definition: integer_base_node.hpp:43
void FromString(const String &value) override
Sets this node's value from the string value .
Definition: integer_base_node.hpp:111
std::int64_t Value() const
Gets the value of this integer node.
Definition: integer_base_node.hpp:91
virtual String Unit() const
Gets the unit of this node's value.
Definition: integer_base_node.hpp:77
std::int64_t Increment() const
Gets the increment of this value.
Definition: integer_base_node.hpp:36
void SetValue(const std::int64_t &value)
Sets the value of this integer node.
Definition: integer_base_node.hpp:102
String ToString() const override
Gets the string representation of this node.
Definition: integer_base_node.hpp:122
GenApi::NumberRepresentation Representation() const
Gets how the value is to be represented.
Definition: integer_base_node.hpp:57
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:101
Groups other nodes that are dependent on this one.
Definition: selector_node.hpp:31
NumberRepresentation
Defines how a number is to be interpreted/displayed in a graphical user interface.
Definition: genapi.hpp:139
@ Max
Gets the maximum value.
@ Increment
Gets the increment.
@ Min
Gets the minimum value.
@ NumberRepresentation
Accesses the representation of a number.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
char Char
Character type for wide characters or unicode characters.
Definition: string.hpp:59