CVB++ 15.0
float_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "value_node.hpp"
6
7namespace Cvb
8{
9
10 CVB_BEGIN_INLINE_NS
11
12 namespace GenApi
13 {
14
16
18 class FloatNode : public ValueNode
19 {
20 public:
21 explicit FloatNode(HandleGuard<Node> &&guard) noexcept
22 : ValueNode(std::move(guard))
23 {
24 }
25
27
31 double Value() const
32 {
33 return NativeCall<double>([&](double &value) { return CExports::NGetAsFloat(Handle(), value); });
34 }
35
37
41 void SetValue(double value)
42 {
43 NativeCall([&]() { return CExports::NSetAsFloat(Handle(), value); });
44 }
45
47
51 double Min() const
52 {
53 return GetInfoAsFloat(NodeInfo::Min);
54 }
55
57
61 double Max() const
62 {
63 return GetInfoAsFloat(NodeInfo::Max);
64 }
65
67
75 double Increment() const
76 {
78 auto result = CExports::NInfoAsFloat(Handle(), static_cast<CExports::TNodeInfo>(NodeInfo::Increment), value);
79 if (result < 0)
80 {
81 if (result == ErrorCodes::CVB_NOTSUPPORTED)
83 else
84 std::rethrow_exception(CvbException::FromCvbResult(result, "failed to get increment"));
85 }
86 return value;
87 }
88
90
95 {
96 return static_cast<NumberRepresentation>(GetInfoAsInt(NodeInfo::Representation));
97 }
98
100
104 String Unit() const
105 {
106 return GetInfoAsString(NodeInfo::Unit);
107 }
108
109 private:
110 double GetInfoAsFloat(NodeInfo command) const
111 {
112 return NativeCall<double>([&](double &value) {
113 return CExports::NInfoAsFloat(Handle(), static_cast<CExports::TNodeInfo>(command), value);
114 });
115 }
116 };
117
118 } // namespace GenApi
119
120 using GenApi::FloatNode;
121
122 CVB_END_INLINE_NS
123
124} // namespace Cvb
Represents a floating point number.
Definition float_node.hpp:19
NumberRepresentation Representation() const
Gets how the value is to be represented.
Definition float_node.hpp:94
double Increment() const
Gets the increment of this value.
Definition float_node.hpp:75
void SetValue(double value)
Sets the value of this floating point node.
Definition float_node.hpp:41
String Unit() const
Gets the unit of this node's value.
Definition float_node.hpp:104
double Value() const
Gets the value of this floating point node.
Definition float_node.hpp:31
double Min() const
Gets the minimal allowed number for this value.
Definition float_node.hpp:51
double Max() const
Gets the maximal allowed number for this value.
Definition float_node.hpp:61
void * Handle() const noexcept
Classic API node handle.
Definition decl_node.hpp:71
T move(T... args)
const int CVB_NOTSUPPORTED
A certain feature is not supported.
Definition exception.hpp:59
Namespace for GenApi based device configuration.
Definition decl_fw_updater.hpp:29
NumberRepresentation
Defines how a number is to be interpreted/displayed in a graphical user interface.
Definition genapi.hpp:143
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
T quiet_NaN(T... args)
T rethrow_exception(T... args)