IDS peak genericC++ v1.11.1
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
41
45class FloatNode : public Node
46{
47public:
48 static constexpr auto NodeType = nodes::NodeType::Float;
49 using NodeDataType = double;
50 using NodeHasRange = std::true_type;
51
52 FloatNode() = delete;
53 ~FloatNode() override = default;
54 FloatNode(const FloatNode& other) = delete;
55 FloatNode& operator=(const FloatNode& other) = delete;
56 FloatNode(FloatNode&& other) = delete;
57 FloatNode& operator=(FloatNode&& other) = delete;
58
69 double Minimum() const;
70
81 double Maximum() const;
82
93 double Increment() const;
94
105
118 std::vector<double> ValidValues() const;
119
130
140 std::string Unit() const;
141
152
162 int64_t DisplayPrecision() const;
163
174 bool HasConstantIncrement() const;
175
188 double Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
189
200 void SetValue(double value);
201
202private:
203 friend ClassCreator<FloatNode>;
204 FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
205 PEAK_FLOAT_NODE_HANDLE m_backendHandle;
206};
207
208} /* namespace nodes */
209} /* namespace core */
210} /* namespace peak */
211
212/* Implementation */
213namespace peak
214{
215namespace core
216{
217namespace nodes
218{
219
220inline std::string ToString(NodeDisplayNotation entry)
221{
222 std::string entryString;
223
225 {
226 entryString = "Automatic";
227 }
228 else if (entry == NodeDisplayNotation::Fixed)
229 {
230 entryString = "Fixed";
231 }
232 else if (entry == NodeDisplayNotation::Scientific)
233 {
234 entryString = "Scientific";
235 }
236
237 return entryString;
238}
239
240inline FloatNode::FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
241 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
242 return PEAK_C_ABI_PREFIX PEAK_FloatNode_ToNode(floatNodeHandle, nodeHandle);
243 }),
244 parentNodeMap)
245 , m_backendHandle(floatNodeHandle)
246{}
247
248inline double FloatNode::Minimum() const
249{
250 return QueryNumericFromCInterfaceFunction<double>(
251 [&](double* minimum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMinimum(m_backendHandle, minimum); });
252}
253
254inline double FloatNode::Maximum() const
255{
256 return QueryNumericFromCInterfaceFunction<double>(
257 [&](double* maximum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMaximum(m_backendHandle, maximum); });
258}
259
260inline double FloatNode::Increment() const
261{
262 return QueryNumericFromCInterfaceFunction<double>([&](double* increment) {
263 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrement(m_backendHandle, increment);
264 });
265}
266
268{
269 return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
270 [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
271 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrementType(m_backendHandle, incrementType);
272 }));
273}
274
275inline std::vector<double> FloatNode::ValidValues() const
276{
277 return QueryNumericArrayFromCInterfaceFunction<double>([&](double* validValues, size_t* validValuesSize) {
278 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
279 });
280}
281
283{
284 return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
285 [&](PEAK_NODE_REPRESENTATION* representation) {
286 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetRepresentation(m_backendHandle, representation);
287 }));
288}
289
290inline std::string FloatNode::Unit() const
291{
292 return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
293 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetUnit(m_backendHandle, unit, unitSize);
294 });
295}
296
298{
299 return static_cast<NodeDisplayNotation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_DISPLAY_NOTATION>(
300 [&](PEAK_NODE_DISPLAY_NOTATION* displayNotation) {
301 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayNotation(m_backendHandle, displayNotation);
302 }));
303}
304
305inline int64_t FloatNode::DisplayPrecision() const
306{
307 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* displayPrecision) {
308 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayPrecision(m_backendHandle, displayPrecision);
309 });
310}
311
313{
314 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](PEAK_BOOL8* hasConstantIncrement) {
315 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetHasConstantIncrement(m_backendHandle, hasConstantIncrement);
316 }) > 0;
317}
318
319inline double FloatNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
320{
321 return QueryNumericFromCInterfaceFunction<double>([&](double* value) {
323 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
324 });
325}
326
327inline void FloatNode::SetValue(double value)
328{
329 CallAndCheckCInterfaceFunction(
330 [&] { return PEAK_C_ABI_PREFIX PEAK_FloatNode_SetValue(m_backendHandle, value); });
331}
332
333} /* namespace nodes */
334} /* namespace core */
335} /* namespace peak */
NodeIncrementType IncrementType() const
Returns the increment type.
Definition peak_float_node.hpp:267
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:327
static constexpr auto NodeType
Definition peak_float_node.hpp:48
bool HasConstantIncrement() const
Checks whether the node has a constant increment.
Definition peak_float_node.hpp:312
std::vector< double > ValidValues() const
Returns the valid values.
Definition peak_float_node.hpp:275
double Increment() const
Returns the increment.
Definition peak_float_node.hpp:260
double Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_float_node.hpp:319
double Maximum() const
Returns the maximum.
Definition peak_float_node.hpp:254
NodeDisplayNotation DisplayNotation() const
Returns the display notation.
Definition peak_float_node.hpp:297
NodeRepresentation Representation() const
Returns the representation.
Definition peak_float_node.hpp:282
double Minimum() const
Returns the minimum.
Definition peak_float_node.hpp:248
std::string Unit() const
Returns the unit.
Definition peak_float_node.hpp:290
int64_t DisplayPrecision() const
Returns the display precision.
Definition peak_float_node.hpp:305
std::true_type NodeHasRange
Definition peak_float_node.hpp:50
FloatNode(FloatNode &&other)=delete
FloatNode(const FloatNode &other)=delete
double NodeDataType
Definition peak_float_node.hpp:49
The "nodes" namespace contains all GenAPI node types.
Definition peak_boolean_node.hpp:26
NodeIncrementType
Definition peak_common_node_enums.hpp:34
@ Float
Definition peak_node.hpp:91
std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:54
NodeDisplayNotation
Display notation for numbers in FloatNode.
Definition peak_float_node.hpp:36
@ Automatic
Definition peak_float_node.hpp:37
@ Scientific
Definition peak_float_node.hpp:39
@ Fixed
Definition peak_float_node.hpp:38
NodeCacheUsePolicy
Definition peak_common_node_enums.hpp:25
@ UseCache
Definition peak_common_node_enums.hpp:26
NodeRepresentation
Definition peak_common_node_enums.hpp:44
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:31
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