IDS peak genericC++ v1.14.0
Loading...
Searching...
No Matches
peak_float_node.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
15#include <peak/dll_interface/peak_dll_interface_util.hpp>
18
19#include <cstdint>
20#include <string>
21#include <vector>
22#include <type_traits>
23
24
25namespace peak
26{
27namespace core
28{
29namespace nodes
30{
31
42
47class FloatNode : public Node
48{
49public:
50 static constexpr auto NodeType = nodes::NodeType::Float;
51 using NodeDataType = double;
52 using NodeHasRange = std::true_type;
53
54 FloatNode() = delete;
55 ~FloatNode() override = default;
56 FloatNode(const FloatNode& other) = delete;
57 FloatNode& operator=(const FloatNode& other) = delete;
58 FloatNode(FloatNode&& other) = delete;
59 FloatNode& operator=(FloatNode&& other) = delete;
60
71 double Minimum() const;
72
83 double Maximum() const;
84
95 double Increment() const;
96
107
120 std::vector<double> ValidValues() const;
121
132
142 std::string Unit() const;
143
154
164 int64_t DisplayPrecision() const;
165
176 bool HasConstantIncrement() const;
177
190 double Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
191
202 void SetValue(double value);
203
204private:
205 friend ClassCreator<FloatNode>;
206 FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
207 PEAK_FLOAT_NODE_HANDLE m_backendHandle;
208};
209
210} /* namespace nodes */
211} /* namespace core */
212} /* namespace peak */
213
214/* Implementation */
215namespace peak
216{
217namespace core
218{
219namespace nodes
220{
221
222inline std::string ToString(NodeDisplayNotation entry)
223{
224 std::string entryString;
225
227 {
228 entryString = "Automatic";
229 }
230 else if (entry == NodeDisplayNotation::Fixed)
231 {
232 entryString = "Fixed";
233 }
234 else if (entry == NodeDisplayNotation::Scientific)
235 {
236 entryString = "Scientific";
237 }
238
239 return entryString;
240}
241
242inline FloatNode::FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
243 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
244 return PEAK_C_ABI_PREFIX PEAK_FloatNode_ToNode(floatNodeHandle, nodeHandle);
245 }),
246 parentNodeMap)
247 , m_backendHandle(floatNodeHandle)
248{}
249
250inline double FloatNode::Minimum() const
251{
252 return QueryNumericFromCInterfaceFunction<double>(
253 [&](double* minimum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMinimum(m_backendHandle, minimum); });
254}
255
256inline double FloatNode::Maximum() const
257{
258 return QueryNumericFromCInterfaceFunction<double>(
259 [&](double* maximum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMaximum(m_backendHandle, maximum); });
260}
261
262inline double FloatNode::Increment() const
263{
264 return QueryNumericFromCInterfaceFunction<double>([&](double* increment) {
265 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrement(m_backendHandle, increment);
266 });
267}
268
270{
271 return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
272 [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
273 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrementType(m_backendHandle, incrementType);
274 }));
275}
276
277inline std::vector<double> FloatNode::ValidValues() const
278{
279 return QueryNumericArrayFromCInterfaceFunction<double>([&](double* validValues, size_t* validValuesSize) {
280 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
281 });
282}
283
285{
286 return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
287 [&](PEAK_NODE_REPRESENTATION* representation) {
288 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetRepresentation(m_backendHandle, representation);
289 }));
290}
291
292inline std::string FloatNode::Unit() const
293{
294 return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
295 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetUnit(m_backendHandle, unit, unitSize);
296 });
297}
298
300{
301 return static_cast<NodeDisplayNotation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_DISPLAY_NOTATION>(
302 [&](PEAK_NODE_DISPLAY_NOTATION* displayNotation) {
303 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayNotation(m_backendHandle, displayNotation);
304 }));
305}
306
307inline int64_t FloatNode::DisplayPrecision() const
308{
309 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* displayPrecision) {
310 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayPrecision(m_backendHandle, displayPrecision);
311 });
312}
313
315{
316 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](PEAK_BOOL8* hasConstantIncrement) {
317 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetHasConstantIncrement(m_backendHandle, hasConstantIncrement);
318 }) > 0;
319}
320
321inline double FloatNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
322{
323 return QueryNumericFromCInterfaceFunction<double>([&](double* value) {
325 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
326 });
327}
328
329inline void FloatNode::SetValue(double value)
330{
331 CallAndCheckCInterfaceFunction(
332 [&] { return PEAK_C_ABI_PREFIX PEAK_FloatNode_SetValue(m_backendHandle, value); });
333}
334
335} /* namespace nodes */
336} /* namespace core */
337} /* namespace peak */
NodeIncrementType IncrementType() const
Returns the increment type.
Definition peak_float_node.hpp:269
FloatNode & operator=(const FloatNode &other)=delete
FloatNode & operator=(FloatNode &&other)=delete
~FloatNode() override=default
void SetValue(double value)
Sets the given value.
Definition peak_float_node.hpp:329
static constexpr auto NodeType
Definition peak_float_node.hpp:50
bool HasConstantIncrement() const
Checks whether the node has a constant increment.
Definition peak_float_node.hpp:314
std::vector< double > ValidValues() const
Returns the valid values.
Definition peak_float_node.hpp:277
double Increment() const
Returns the increment.
Definition peak_float_node.hpp:262
double Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_float_node.hpp:321
double Maximum() const
Returns the maximum.
Definition peak_float_node.hpp:256
NodeDisplayNotation DisplayNotation() const
Returns the display notation.
Definition peak_float_node.hpp:299
NodeRepresentation Representation() const
Returns the representation.
Definition peak_float_node.hpp:284
double Minimum() const
Returns the minimum.
Definition peak_float_node.hpp:250
std::string Unit() const
Returns the unit.
Definition peak_float_node.hpp:292
int64_t DisplayPrecision() const
Returns the display precision.
Definition peak_float_node.hpp:307
std::true_type NodeHasRange
Definition peak_float_node.hpp:52
FloatNode(FloatNode &&other)=delete
FloatNode(const FloatNode &other)=delete
double NodeDataType
Definition peak_float_node.hpp:51
NodeIncrementType
Definition peak_common_node_enums.hpp:36
NodeDisplayNotation
Display notation for numbers in FloatNode.
Definition peak_float_node.hpp:37
NodeCacheUsePolicy
Definition peak_common_node_enums.hpp:26
NodeRepresentation
Definition peak_common_node_enums.hpp:47
@ Float
Definition peak_node.hpp:95
@ Automatic
Definition peak_float_node.hpp:38
@ Scientific
Definition peak_float_node.hpp:40
@ Fixed
Definition peak_float_node.hpp:39
@ UseCache
Definition peak_common_node_enums.hpp:27
The "nodes" namespace contains all GenAPI node types.
Definition peak_boolean_node.hpp:26
std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:57
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
PEAK_C_API PEAK_FloatNode_GetIncrementType(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_INCREMENT_TYPE *incrementType)
Asks the given float node for its increment type.
PEAK_C_API PEAK_FloatNode_GetDisplayNotation(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_DISPLAY_NOTATION *displayNotation)
Asks the given float node for its display notation.
PEAK_C_API PEAK_FloatNode_GetIncrement(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *increment)
Asks the given float node for its increment.
int32_t PEAK_NODE_INCREMENT_TYPE
Definition peak_backend.h:260
PEAK_C_API PEAK_FloatNode_ToNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given float node to a node.
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition peak_backend.h:429
PEAK_C_API PEAK_FloatNode_GetHasConstantIncrement(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_BOOL8 *hasConstantIncrement)
Asks the given float node whether it has a constant increment.
int32_t PEAK_NODE_REPRESENTATION
Definition peak_backend.h:281
PEAK_C_API PEAK_FloatNode_GetValidValues(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *validValues, size_t *validValuesSize)
Asks the given float node for its valid values.
PEAK_C_API PEAK_FloatNode_GetUnit(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, char *unit, size_t *unitSize)
Asks the given float node for its unit.
struct PEAK_FLOAT_NODE * PEAK_FLOAT_NODE_HANDLE
Definition peak_backend.h:445
PEAK_C_API PEAK_FloatNode_GetMinimum(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *minimum)
Asks the given float node for its minimum.
int32_t PEAK_NODE_CACHE_USE_POLICY
Definition peak_backend.h:242
int8_t PEAK_BOOL8
Definition peak_backend.h:43
PEAK_C_API PEAK_FloatNode_GetDisplayPrecision(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, int64_t *displayPrecision)
Asks the given float node for its display precision.
PEAK_C_API PEAK_FloatNode_SetValue(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double value)
Tells the given float node to set the given value.
PEAK_C_API PEAK_FloatNode_GetMaximum(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *maximum)
Asks the given float node for its maximum.
PEAK_C_API PEAK_FloatNode_GetValue(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_CACHE_USE_POLICY cacheUsePolicy, double *value)
Asks the given float node for its value.
int32_t PEAK_NODE_DISPLAY_NOTATION
Definition peak_backend.h:251
PEAK_C_API PEAK_FloatNode_GetRepresentation(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_REPRESENTATION *representation)
Asks the given float node for its representation.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16