IDS peak genericC++ v1.8.0
Loading...
Searching...
No Matches
peak_float_node.hpp
Go to the documentation of this file.
1
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
23
24namespace peak
25{
26namespace core
27{
28namespace nodes
29{
30
35{
37 Fixed,
39};
40
44class FloatNode : public Node
45{
46public:
47 FloatNode() = delete;
48 ~FloatNode() override = default;
49 FloatNode(const FloatNode& other) = delete;
50 FloatNode& operator=(const FloatNode& other) = delete;
51 FloatNode(FloatNode&& other) = delete;
52 FloatNode& operator=(FloatNode&& other) = delete;
53
64 double Minimum() const;
65
76 double Maximum() const;
77
88 double Increment() const;
89
100
113 std::vector<double> ValidValues() const;
114
125
135 std::string Unit() const;
136
147
157 int64_t DisplayPrecision() const;
158
169 bool HasConstantIncrement() const;
170
183 double Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
184
195 void SetValue(double value);
196
197private:
198 friend ClassCreator<FloatNode>;
199 FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
200 PEAK_FLOAT_NODE_HANDLE m_backendHandle;
201};
202
203} /* namespace nodes */
204} /* namespace core */
205} /* namespace peak */
206
207/* Implementation */
208namespace peak
209{
210namespace core
211{
212namespace nodes
213{
214
215inline std::string ToString(NodeDisplayNotation entry)
216{
217 std::string entryString;
218
220 {
221 entryString = "Automatic";
222 }
223 else if (entry == NodeDisplayNotation::Fixed)
224 {
225 entryString = "Fixed";
226 }
227 else if (entry == NodeDisplayNotation::Scientific)
228 {
229 entryString = "Scientific";
230 }
231
232 return entryString;
233}
234
235inline FloatNode::FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
236 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
237 return PEAK_C_ABI_PREFIX PEAK_FloatNode_ToNode(floatNodeHandle, nodeHandle);
238 }),
239 parentNodeMap)
240 , m_backendHandle(floatNodeHandle)
241{}
242
243inline double FloatNode::Minimum() const
244{
245 return QueryNumericFromCInterfaceFunction<double>(
246 [&](double* minimum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMinimum(m_backendHandle, minimum); });
247}
248
249inline double FloatNode::Maximum() const
250{
251 return QueryNumericFromCInterfaceFunction<double>(
252 [&](double* maximum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMaximum(m_backendHandle, maximum); });
253}
254
255inline double FloatNode::Increment() const
256{
257 return QueryNumericFromCInterfaceFunction<double>([&](double* increment) {
258 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrement(m_backendHandle, increment);
259 });
260}
261
263{
264 return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
265 [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
266 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrementType(m_backendHandle, incrementType);
267 }));
268}
269
270inline std::vector<double> FloatNode::ValidValues() const
271{
272 return QueryNumericArrayFromCInterfaceFunction<double>([&](double* validValues, size_t* validValuesSize) {
273 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
274 });
275}
276
278{
279 return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
280 [&](PEAK_NODE_REPRESENTATION* representation) {
281 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetRepresentation(m_backendHandle, representation);
282 }));
283}
284
285inline std::string FloatNode::Unit() const
286{
287 return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
288 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetUnit(m_backendHandle, unit, unitSize);
289 });
290}
291
293{
294 return static_cast<NodeDisplayNotation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_DISPLAY_NOTATION>(
295 [&](PEAK_NODE_DISPLAY_NOTATION* displayNotation) {
296 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayNotation(m_backendHandle, displayNotation);
297 }));
298}
299
300inline int64_t FloatNode::DisplayPrecision() const
301{
302 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* displayPrecision) {
303 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayPrecision(m_backendHandle, displayPrecision);
304 });
305}
306
308{
309 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](PEAK_BOOL8* hasConstantIncrement) {
310 return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetHasConstantIncrement(m_backendHandle, hasConstantIncrement);
311 }) > 0;
312}
313
314inline double FloatNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
315{
316 return QueryNumericFromCInterfaceFunction<double>([&](double* value) {
318 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
319 });
320}
321
322inline void FloatNode::SetValue(double value)
323{
324 CallAndCheckCInterfaceFunction(
325 [&] { return PEAK_C_ABI_PREFIX PEAK_FloatNode_SetValue(m_backendHandle, value); });
326}
327
328} /* namespace nodes */
329} /* namespace core */
330} /* namespace peak */
Represents a GenAPI float node.
Definition peak_float_node.hpp:45
NodeIncrementType IncrementType() const
Returns the increment type.
Definition peak_float_node.hpp:262
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:322
bool HasConstantIncrement() const
Checks whether the node has a constant increment.
Definition peak_float_node.hpp:307
std::vector< double > ValidValues() const
Returns the valid values.
Definition peak_float_node.hpp:270
double Increment() const
Returns the increment.
Definition peak_float_node.hpp:255
double Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_float_node.hpp:314
double Maximum() const
Returns the maximum.
Definition peak_float_node.hpp:249
NodeDisplayNotation DisplayNotation() const
Returns the display notation.
Definition peak_float_node.hpp:292
NodeRepresentation Representation() const
Returns the representation.
Definition peak_float_node.hpp:277
double Minimum() const
Returns the minimum.
Definition peak_float_node.hpp:243
std::string Unit() const
Returns the unit.
Definition peak_float_node.hpp:285
int64_t DisplayPrecision() const
Returns the display precision.
Definition peak_float_node.hpp:300
FloatNode(FloatNode &&other)=delete
FloatNode(const FloatNode &other)=delete
Represents a GenAPI node.
Definition peak_node.hpp:122
NodeIncrementType
Definition peak_common_node_enums.hpp:34
std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:54
NodeDisplayNotation
Display notation for numbers in FloatNode.
Definition peak_float_node.hpp:35
NodeCacheUsePolicy
Definition peak_common_node_enums.hpp:25
NodeRepresentation
Definition peak_common_node_enums.hpp:44
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:32
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:243
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:412
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:264
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:428
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:225
int8_t PEAK_BOOL8
Definition peak_backend.h:26
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:234
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