CVB++ 15.0
float_base_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "selector_node.hpp"
6
7
8
9namespace Cvb
10{
11 CVB_BEGIN_INLINE_NS
12 namespace GevServer
13 {
15
18 : public SelectorNode
19 {
20 public:
21 explicit FloatBaseNode(HandleGuard<Node>&& guard) : SelectorNode(std::move(guard)) {}
22
24
31 double Increment() const { return GetInfoAsFloat(NodeInfo::Increment); }
32
34
38 double Max() const { return GetInfoAsFloat(NodeInfo::Max); }
39
41
45 double Min() const { return GetInfoAsFloat(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 double Value() const
72 {
73 return NativeCall<double>([&](double& value) { return CVB_CALL_CAPI(GSNGetAsFloat(Handle(), value)); });
74 }
75
77
81 void SetValue(double value)
82 {
83 NativeCall([&]() { return CVB_CALL_CAPI(GSNSetAsFloat(Handle(), value)); });
84 }
85
90 void FromString(const String& value) override
91 {
92 NativeCall([&]() { return CExports::GSNSetAsStringTyped(Handle(), value.data()); });
93 }
94
101 String ToString() const override
102 {
103 size_t nameLength = 0;
104 auto resultNameLength = CExports::GSNGetAsStringTyped(Handle(), reinterpret_cast<Char*>(0), nameLength);
105 if (resultNameLength < 0)
106 std::rethrow_exception(
107 CvbException::FromCvbResult(resultNameLength, "failed to get string representation name length"));
108
109 nameLength += sizeof(Char);
110 std::vector<Char> buffer(static_cast<size_t>(nameLength));
111
112 auto resultBuffer = CExports::GSNGetAsStringTyped(Handle(), buffer.data(), nameLength);
113 if (resultBuffer < 0)
114 std::rethrow_exception(
115 CvbException::FromCvbResult(resultBuffer, "failed to get string representation of this node"));
116
117 return buffer.data();
118 }
119 };
120 }
121 CVB_END_INLINE_NS
122}
Represents a floating point number.
Definition: float_base_node.hpp:19
void SetRepresentation(const GenApi::NumberRepresentation &representation)
Sets how the value is to be represented.
Definition: float_base_node.hpp:61
double Increment() const
Gets the increment of this value.
Definition: float_base_node.hpp:31
void SetValue(double value)
Sets the value of this float node.
Definition: float_base_node.hpp:81
double Value() const
Gets the value of this float node.
Definition: float_base_node.hpp:71
void FromString(const String &value) override
Sets this node's value from the string value .
Definition: float_base_node.hpp:90
double Min() const
Gets the minimal allowed number for this value.
Definition: float_base_node.hpp:45
double Max() const
Gets the maximal allowed number for this value.
Definition: float_base_node.hpp:38
String ToString() const override
Gets the string representation of this node.
Definition: float_base_node.hpp:101
GenApi::NumberRepresentation Representation() const
Gets how the value is to be represented.
Definition: float_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