float_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 // implements same integer interface
24  {
25  public:
26  FloatBaseNode(HandleGuard<Node>&& guard) noexcept : SelectorNode(std::move(guard)) {}
27 
29 
36  double Increment() const { return GetInfoAsFloat(NodeInfo::Increment); }
37 
39 
43  double Max() const { return GetInfoAsFloat(NodeInfo::Max); }
44 
46 
50  double Min() const { return GetInfoAsFloat(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  double Value() const
77  {
78  return NativeCall<double>([&](double& value) { return CVB_CALL_CAPI(GSNGetAsFloat(Handle(), value)); });
79  }
80 
82 
86  void SetValue(double value)
87  {
88  NativeCall([&]() { return CVB_CALL_CAPI(GSNSetAsFloat(Handle(), value)); });
89  }
90 
95  void FromString(const String& value) override
96  {
97  NativeCall([&]() { return CExports::GSNSetAsStringTyped(Handle(), value.data()); });
98  }
99 
106  String ToString() const override
107  {
108  size_t nameLength = 0;
109  auto resultNameLength = CExports::GSNGetAsStringTyped(Handle(), reinterpret_cast<Char*>(0), nameLength);
110  if (resultNameLength < 0)
111  std::rethrow_exception(
112  CvbException::FromCvbResult(resultNameLength, "failed to get string representation name length"));
113 
114  nameLength += sizeof(Char);
115  std::vector<Char> buffer(static_cast<size_t>(nameLength));
116 
117  auto resultBuffer = CExports::GSNGetAsStringTyped(Handle(), buffer.data(), nameLength);
118  if (resultBuffer < 0)
119  std::rethrow_exception(
120  CvbException::FromCvbResult(resultBuffer, "failed to get string representation of this node"));
121 
122  return buffer.data();
123  }
124  };
125  }
126  CVB_END_INLINE_NS
127 }
Represents a floating point number.
Definition: float_base_node.hpp:19
void SetValue(double value)
Sets the value of this float node.
Definition: float_base_node.hpp:86
Gets the maximum value.
double Increment() const
Gets the increment of this value.
Definition: float_base_node.hpp:36
void FromString(const String &value) override
Sets this node's value from the string value .
Definition: float_base_node.hpp:95
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
GenApi::NumberRepresentation Representation() const
Gets how the value is to be represented.
Definition: float_base_node.hpp:57
Gets the minimum value.
char Char
Character type for wide characters or unicode characters.
Definition: string.hpp:59
double Max() const
Gets the maximal allowed number for this value.
Definition: float_base_node.hpp:43
NumberRepresentation
Defines how a number is to be interpreted/displayed in a graphical user interface.
Definition: genapi.hpp:138
double Min() const
Gets the minimal allowed number for this value.
Definition: float_base_node.hpp:50
Groups other nodes that are dependent on this one.
Definition: selector_node.hpp:24
STL class.
double Value() const
Gets the value of this float node.
Definition: float_base_node.hpp:76
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:101
Accesses the representation of a number.
String ToString() const override
Gets the string representation of this node.
Definition: float_base_node.hpp:106
void SetRepresentation(const GenApi::NumberRepresentation &representation)
Sets how the value is to be represented.
Definition: float_base_node.hpp:66