IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_float_node.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10
12#include <peak/dll_interface/peak_dll_interface_util.hpp>
15
18
19#include <type_traits>
20#include <cstdint>
21#include <string>
22#include <vector>
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 PEAK_COMMON_NO_DISCARD double Minimum() const;
72
83 PEAK_COMMON_NO_DISCARD double Maximum() const;
84
95 PEAK_COMMON_NO_DISCARD double Increment() const;
96
107
121
133
146 PEAK_COMMON_NO_DISCARD std::vector<double> ValidValues() const;
147
158
168 PEAK_COMMON_NO_DISCARD std::string Unit() const;
169
180
191
203
218
229 void SetValue(double value);
230
231private:
232 friend ClassCreator<FloatNode>;
233 FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
234 PEAK_FLOAT_NODE_HANDLE m_backendHandle;
235};
236
237} /* namespace nodes */
238} /* namespace core */
239} /* namespace peak */
240
241/* Implementation */
242namespace peak
243{
244namespace core
245{
246namespace nodes
247{
248
249inline std::string ToString(NodeDisplayNotation entry)
250{
251 std::string entryString;
252
254 {
255 entryString = "Automatic";
256 }
257 else if (entry == NodeDisplayNotation::Fixed)
258 {
259 entryString = "Fixed";
260 }
261 else if (entry == NodeDisplayNotation::Scientific)
262 {
263 entryString = "Scientific";
264 }
265
266 return entryString;
267}
268
269inline FloatNode::FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
270 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
271 return PEAK_C_ABI_PREFIX PEAK_FloatNode_ToNode(floatNodeHandle, nodeHandle);
272 }),
273 parentNodeMap)
274 , m_backendHandle(floatNodeHandle)
275{}
276
277inline double FloatNode::Minimum() const
278{
279 return QueryNumericFromCInterfaceFunction<double>(
280 [&](double* minimum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMinimum(m_backendHandle, minimum); });
281}
282
283inline double FloatNode::Maximum() const
284{
285 return QueryNumericFromCInterfaceFunction<double>(
286 [&](double* maximum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMaximum(m_backendHandle, maximum); });
287}
288
289inline double FloatNode::Increment() const
290{
291 return QueryNumericFromCInterfaceFunction<double>([&](double* increment) {
292 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrement(m_backendHandle, increment);
293 });
294}
295
297{
298 return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
299 [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
300 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrementType(m_backendHandle, incrementType);
301 }));
302}
303
305{
306 return { Minimum(), Maximum(), HasConstantIncrement() ? Increment() : 0.0 };
307}
308
310{
311 return { Minimum(), Maximum() };
312}
313
314inline std::vector<double> FloatNode::ValidValues() const
315{
316 return QueryNumericArrayFromCInterfaceFunction<double>([&](double* validValues, size_t* validValuesSize) {
317 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
318 });
319}
320
322{
323 return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
324 [&](PEAK_NODE_REPRESENTATION* representation) {
325 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetRepresentation(m_backendHandle, representation);
326 }));
327}
328
329inline std::string FloatNode::Unit() const
330{
331 return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
332 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetUnit(m_backendHandle, unit, unitSize);
333 });
334}
335
337{
338 return static_cast<NodeDisplayNotation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_DISPLAY_NOTATION>(
339 [&](PEAK_NODE_DISPLAY_NOTATION* displayNotation) {
340 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayNotation(m_backendHandle, displayNotation);
341 }));
342}
343
344inline int64_t FloatNode::DisplayPrecision() const
345{
346 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* displayPrecision) {
347 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayPrecision(m_backendHandle, displayPrecision);
348 });
349}
350
352{
353 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](PEAK_BOOL8* hasConstantIncrement) {
354 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetHasConstantIncrement(m_backendHandle, hasConstantIncrement);
355 }) > 0;
356}
357
358inline double FloatNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
359{
360 return QueryNumericFromCInterfaceFunction<double>([&](double* value) {
362 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
363 });
364}
365
366inline void FloatNode::SetValue(double value)
367{
368 CallAndCheckCInterfaceFunction(
369 [&] { return PEAK_C_ABI_PREFIX PEAK_FloatNode_SetValue(m_backendHandle, value); });
370}
371
372} /* namespace nodes */
373} /* namespace core */
374} /* namespace peak */
PEAK_COMMON_NO_DISCARD NodeIncrementType IncrementType() const
Returns the increment type.
Definition peak_float_node.hpp:296
FloatNode & operator=(const FloatNode &other)=delete
PEAK_COMMON_NO_DISCARD peak::common::IntervalD Interval() const
Returns the interval of value values for this node.
Definition peak_float_node.hpp:309
FloatNode & operator=(FloatNode &&other)=delete
~FloatNode() override=default
void SetValue(double value)
Sets the given value.
Definition peak_float_node.hpp:366
static constexpr auto NodeType
Definition peak_float_node.hpp:50
PEAK_COMMON_NO_DISCARD bool HasConstantIncrement() const
Checks whether the node has a constant increment.
Definition peak_float_node.hpp:351
PEAK_COMMON_NO_DISCARD std::vector< double > ValidValues() const
Returns the valid values.
Definition peak_float_node.hpp:314
PEAK_COMMON_NO_DISCARD double Increment() const
Returns the increment.
Definition peak_float_node.hpp:289
PEAK_COMMON_NO_DISCARD double Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_float_node.hpp:358
PEAK_COMMON_NO_DISCARD double Maximum() const
Returns the maximum.
Definition peak_float_node.hpp:283
PEAK_COMMON_NO_DISCARD peak::common::RangeD Range() const
Returns the range of value values for this node.
Definition peak_float_node.hpp:304
PEAK_COMMON_NO_DISCARD NodeDisplayNotation DisplayNotation() const
Returns the display notation.
Definition peak_float_node.hpp:336
PEAK_COMMON_NO_DISCARD NodeRepresentation Representation() const
Returns the representation.
Definition peak_float_node.hpp:321
PEAK_COMMON_NO_DISCARD double Minimum() const
Returns the minimum.
Definition peak_float_node.hpp:277
PEAK_COMMON_NO_DISCARD std::string Unit() const
Returns the unit.
Definition peak_float_node.hpp:329
PEAK_COMMON_NO_DISCARD int64_t DisplayPrecision() const
Returns the display precision.
Definition peak_float_node.hpp:344
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
detail::RangeT< double > RangeD
Alias for a range of double-precision floating-point numbers.
Definition peak_common_range.hpp:282
detail::IntervalT< double > IntervalD
Interval with double-precision floating-point boundaries.
Definition peak_common_interval.hpp:291
NodeIncrementType
Definition peak_common_node_enums.hpp:48
NodeDisplayNotation
Display notation for numbers in FloatNode.
Definition peak_float_node.hpp:37
NodeCacheUsePolicy
Defines how node value access should interact with the internal cache.
Definition peak_common_node_enums.hpp:36
NodeRepresentation
Definition peak_common_node_enums.hpp:59
@ Float
Definition peak_node.hpp:92
@ 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:38
The "nodes" namespace contains all GenAPI node types.
Definition peak_utils.hpp:31
PEAK_COMMON_NO_DISCARD std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:69
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
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:258
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:427
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:279
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:443
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:240
int8_t PEAK_BOOL8
Definition peak_backend.h:41
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:249
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_COMMON_NO_DISCARD
Definition peak_common_defines.h:89
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:13