CVB++ 15.0
integer_base_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "selector_node.hpp"
6
7
8
9namespace Cvb
10{
11CVB_BEGIN_INLINE_NS
12namespace GevServer
13{
15
18 : public SelectorNode
19{
20public:
21 explicit IntegerBaseNode(HandleGuard<Node> &&guard) : SelectorNode(std::move(guard)) {}
22
24
31 std::int64_t Increment() const { return GetInfoAsInt(NodeInfo::Increment); }
32
34
38 std::int64_t Max() const { return GetInfoAsInt(NodeInfo::Max); }
39
41
45 std::int64_t Min() const { return GetInfoAsInt(NodeInfo::Min); }
46
48
53 {
54 return static_cast<GenApi::NumberRepresentation>(GetInfoAsInt(NodeInfo::NumberRepresentation));
55 }
56
58
62 {
63 SetInfoAsInt(NodeInfo::NumberRepresentation, static_cast<std::int64_t>(representation));
64 }
65
67
71 virtual String Unit() const
72 {
73 return String(); // Not yet implemented
74 }
75
76 virtual void SetUnit(const String& /*unit*/)
77 {
78 }
79
81
86 {
87 return static_cast<std::int64_t>(NativeCall<CExports::cvbint64_t>(
88 [&](CExports::cvbint64_t &value) { return CVB_CALL_CAPI(GSNGetAsInteger(Handle(), value)); }));
89 }
90
92
96 void SetValue(const std::int64_t &value)
97 {
98 NativeCall([&]() { return CVB_CALL_CAPI(GSNSetAsInteger(Handle(), static_cast<CExports::cvbint64_t>(value))); });
99 }
100
105 void FromString(const String &value) override
106 {
107 NativeCall([&]() { return CExports::GSNSetAsStringTyped(Handle(), value.data()); });
108 }
109
116 String ToString() const override
117 {
118 size_t nameLength = 0;
119 auto resultNameLength = CExports::GSNGetAsStringTyped(Handle(), reinterpret_cast<Char *>(0), nameLength);
120 if (resultNameLength < 0)
121 std::rethrow_exception(
122 CvbException::FromCvbResult(resultNameLength, "failed to get string representation name length"));
123
124 nameLength += sizeof(Char);
125 std::vector<Char> buffer(static_cast<size_t>(nameLength));
126
127 auto resultBuffer = CExports::GSNGetAsStringTyped(Handle(), buffer.data(), nameLength);
128 if (resultBuffer < 0)
129 std::rethrow_exception(
130 CvbException::FromCvbResult(resultBuffer, "failed to get string representation of this node"));
131
132 return buffer.data();
133 }
134};
135}
136CVB_END_INLINE_NS
137}
Represents an integer number.
Definition: integer_base_node.hpp:19
void SetRepresentation(const GenApi::NumberRepresentation &representation)
Sets how the value is to be represented.
Definition: integer_base_node.hpp:61
std::int64_t Min() const
Gets the minimal allowed number for this value.
Definition: integer_base_node.hpp:45
std::int64_t Max() const
Gets the maximal allowed number for this value.
Definition: integer_base_node.hpp:38
void FromString(const String &value) override
Sets this node's value from the string value .
Definition: integer_base_node.hpp:105
std::int64_t Value() const
Gets the value of this integer node.
Definition: integer_base_node.hpp:85
virtual String Unit() const
Gets the unit of this node's value.
Definition: integer_base_node.hpp:71
std::int64_t Increment() const
Gets the increment of this value.
Definition: integer_base_node.hpp:31
void SetValue(const std::int64_t &value)
Sets the value of this integer node.
Definition: integer_base_node.hpp:96
String ToString() const override
Gets the string representation of this node.
Definition: integer_base_node.hpp:116
GenApi::NumberRepresentation Representation() const
Gets how the value is to be represented.
Definition: integer_base_node.hpp:52
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:100
Groups other nodes that are dependent on this one.
Definition: selector_node.hpp:24
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:70