IDS peak genericC++ v1.15.0
Loading...
Searching...
No Matches
peak_integer_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
37class IntegerNode : public Node
38{
39public:
40 static constexpr auto NodeType = nodes::NodeType::Integer;
41 using NodeDataType = int64_t;
42 using NodeHasRange = std::true_type;
43
44 IntegerNode() = delete;
45 ~IntegerNode() override = default;
46 IntegerNode(const IntegerNode& other) = delete;
47 IntegerNode& operator=(const IntegerNode& other) = delete;
48 IntegerNode(IntegerNode&& other) = delete;
49 IntegerNode& operator=(IntegerNode&& other) = delete;
50
52 int64_t Minimum() const;
53
55 int64_t Maximum() const;
56
58 int64_t Increment() const;
59
62
64 std::vector<int64_t> ValidValues() const;
65
68
70 std::string Unit() const;
71
73 int64_t Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
74
76 void SetValue(int64_t value);
77
78private:
79 friend ClassCreator<IntegerNode>;
80 IntegerNode(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
81 PEAK_INTEGER_NODE_HANDLE m_backendHandle;
82};
83
84} /* namespace nodes */
85} /* namespace core */
86} /* namespace peak */
87
88/* Implementation */
89namespace peak
90{
91namespace core
92{
93namespace nodes
94{
95
97 PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
98 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
99 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_ToNode(integerNodeHandle, nodeHandle);
100 }),
101 parentNodeMap)
102 , m_backendHandle(integerNodeHandle)
103{}
104
105inline int64_t IntegerNode::Minimum() const
106{
107 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* minimum) {
108 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMinimum(m_backendHandle, minimum);
109 });
110}
111
112inline int64_t IntegerNode::Maximum() const
113{
114 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* maximum) {
115 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMaximum(m_backendHandle, maximum);
116 });
117}
118
119inline int64_t IntegerNode::Increment() const
120{
121 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* increment) {
122 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrement(m_backendHandle, increment);
123 });
124}
125
127{
128 return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
129 [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
130 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrementType(m_backendHandle, incrementType);
131 }));
132}
133
134inline std::vector<int64_t> IntegerNode::ValidValues() const
135{
136 return QueryNumericArrayFromCInterfaceFunction<int64_t>([&](int64_t* validValues, size_t* validValuesSize) {
137 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
138 });
139}
140
142{
143 return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
144 [&](PEAK_NODE_REPRESENTATION* representation) {
145 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetRepresentation(m_backendHandle, representation);
146 }));
147}
148
149inline std::string IntegerNode::Unit() const
150{
151 return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
152 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetUnit(m_backendHandle, unit, unitSize);
153 });
154}
155
156inline int64_t IntegerNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
157{
158 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* value) {
160 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
161 });
162}
163
164inline void IntegerNode::SetValue(int64_t value)
165{
166 CallAndCheckCInterfaceFunction(
167 [&] { return PEAK_C_ABI_PREFIX PEAK_IntegerNode_SetValue(m_backendHandle, value); });
168}
169
170} /* namespace nodes */
171} /* namespace core */
172} /* namespace peak */
IntegerNode & operator=(const IntegerNode &other)=delete
IntegerNode(const IntegerNode &other)=delete
int64_t Minimum() const
Returns the minimum.
Definition peak_integer_node.hpp:105
int64_t Maximum() const
Returns the maximum.
Definition peak_integer_node.hpp:112
int64_t Increment() const
Returns the increment.
Definition peak_integer_node.hpp:119
int64_t NodeDataType
Definition peak_integer_node.hpp:41
int64_t Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_integer_node.hpp:156
IntegerNode & operator=(IntegerNode &&other)=delete
static constexpr auto NodeType
Definition peak_integer_node.hpp:40
NodeIncrementType IncrementType() const
Returns the increment type.
Definition peak_integer_node.hpp:126
NodeRepresentation Representation() const
Returns the representation.
Definition peak_integer_node.hpp:141
~IntegerNode() override=default
IntegerNode(IntegerNode &&other)=delete
std::true_type NodeHasRange
Definition peak_integer_node.hpp:42
std::string Unit() const
Returns the unit.
Definition peak_integer_node.hpp:149
void SetValue(int64_t value)
Sets the given value.
Definition peak_integer_node.hpp:164
std::vector< int64_t > ValidValues() const
Returns the valid values.
Definition peak_integer_node.hpp:134
NodeIncrementType
Definition peak_common_node_enums.hpp:36
NodeCacheUsePolicy
Definition peak_common_node_enums.hpp:26
NodeRepresentation
Definition peak_common_node_enums.hpp:47
@ Integer
Definition peak_node.hpp:92
@ UseCache
Definition peak_common_node_enums.hpp:27
The "nodes" namespace contains all GenAPI node types.
Definition peak_boolean_node.hpp:26
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_IntegerNode_GetRepresentation(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, PEAK_NODE_REPRESENTATION *representation)
Asks the given integer node for its representation.
PEAK_C_API PEAK_IntegerNode_GetMinimum(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *minimum)
Asks the given integer node for its minimum.
int32_t PEAK_NODE_INCREMENT_TYPE
Definition peak_backend.h:260
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition peak_backend.h:429
int32_t PEAK_NODE_REPRESENTATION
Definition peak_backend.h:281
PEAK_C_API PEAK_IntegerNode_GetMaximum(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *maximum)
Asks the given integer node for its maximum.
PEAK_C_API PEAK_IntegerNode_GetValue(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, PEAK_NODE_CACHE_USE_POLICY cacheUsePolicy, int64_t *value)
Asks the given integer node for its value.
PEAK_C_API PEAK_IntegerNode_ToNode(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given integer node to a node.
int32_t PEAK_NODE_CACHE_USE_POLICY
Definition peak_backend.h:242
PEAK_C_API PEAK_IntegerNode_GetValidValues(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *validValues, size_t *validValuesSize)
Asks the given integer node for its valid values.
PEAK_C_API PEAK_IntegerNode_SetValue(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t value)
Tells the given integer node to set the given value.
PEAK_C_API PEAK_IntegerNode_GetIncrement(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *increment)
Asks the given integer node for its increment.
PEAK_C_API PEAK_IntegerNode_GetIncrementType(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, PEAK_NODE_INCREMENT_TYPE *incrementType)
Asks the given integer node for its increment type.
PEAK_C_API PEAK_IntegerNode_GetUnit(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, char *unit, size_t *unitSize)
Asks the given integer node for its unit.
struct PEAK_INTEGER_NODE * PEAK_INTEGER_NODE_HANDLE
Definition peak_backend.h:433
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16