IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_integer_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
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 PEAK_COMMON_NO_DISCARD int64_t Minimum() const;
53
55 PEAK_COMMON_NO_DISCARD int64_t Maximum() const;
56
58 PEAK_COMMON_NO_DISCARD int64_t Increment() const;
59
62
76
88
90 PEAK_COMMON_NO_DISCARD std::vector<int64_t> ValidValues() const;
91
94
96 PEAK_COMMON_NO_DISCARD std::string Unit() const;
97
100
102 void SetValue(int64_t value);
103
104private:
105 friend ClassCreator<IntegerNode>;
106 IntegerNode(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
107 PEAK_INTEGER_NODE_HANDLE m_backendHandle;
108};
109
110} /* namespace nodes */
111} /* namespace core */
112} /* namespace peak */
113
114/* Implementation */
115namespace peak
116{
117namespace core
118{
119namespace nodes
120{
121
123 PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
124 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
125 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_ToNode(integerNodeHandle, nodeHandle);
126 }),
127 parentNodeMap)
128 , m_backendHandle(integerNodeHandle)
129{}
130
131inline int64_t IntegerNode::Minimum() const
132{
133 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* minimum) {
134 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMinimum(m_backendHandle, minimum);
135 });
136}
137
138inline int64_t IntegerNode::Maximum() const
139{
140 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* maximum) {
141 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMaximum(m_backendHandle, maximum);
142 });
143}
144
145inline int64_t IntegerNode::Increment() const
146{
147 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* increment) {
148 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrement(m_backendHandle, increment);
149 });
150}
151
153{
154 return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
155 [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
156 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrementType(m_backendHandle, incrementType);
157 }));
158}
159
164
166{
167 return { Minimum(), Maximum() };
168}
169
170inline std::vector<int64_t> IntegerNode::ValidValues() const
171{
172 return QueryNumericArrayFromCInterfaceFunction<int64_t>([&](int64_t* validValues, size_t* validValuesSize) {
173 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
174 });
175}
176
178{
179 return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
180 [&](PEAK_NODE_REPRESENTATION* representation) {
181 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetRepresentation(m_backendHandle, representation);
182 }));
183}
184
185inline std::string IntegerNode::Unit() const
186{
187 return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
188 return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetUnit(m_backendHandle, unit, unitSize);
189 });
190}
191
192inline int64_t IntegerNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
193{
194 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* value) {
196 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
197 });
198}
199
200inline void IntegerNode::SetValue(int64_t value)
201{
202 CallAndCheckCInterfaceFunction(
203 [&] { return PEAK_C_ABI_PREFIX PEAK_IntegerNode_SetValue(m_backendHandle, value); });
204}
205
206} /* namespace nodes */
207} /* namespace core */
208} /* namespace peak */
IntegerNode & operator=(const IntegerNode &other)=delete
IntegerNode(const IntegerNode &other)=delete
PEAK_COMMON_NO_DISCARD int64_t Minimum() const
Returns the minimum.
Definition peak_integer_node.hpp:131
PEAK_COMMON_NO_DISCARD int64_t Maximum() const
Returns the maximum.
Definition peak_integer_node.hpp:138
PEAK_COMMON_NO_DISCARD int64_t Increment() const
Returns the increment.
Definition peak_integer_node.hpp:145
int64_t NodeDataType
Definition peak_integer_node.hpp:41
PEAK_COMMON_NO_DISCARD int64_t Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_integer_node.hpp:192
IntegerNode & operator=(IntegerNode &&other)=delete
PEAK_COMMON_NO_DISCARD peak::common::Interval64 Interval() const
Returns the interval of value values for this node.
Definition peak_integer_node.hpp:165
static constexpr auto NodeType
Definition peak_integer_node.hpp:40
PEAK_COMMON_NO_DISCARD NodeIncrementType IncrementType() const
Returns the increment type.
Definition peak_integer_node.hpp:152
PEAK_COMMON_NO_DISCARD NodeRepresentation Representation() const
Returns the representation.
Definition peak_integer_node.hpp:177
~IntegerNode() override=default
IntegerNode(IntegerNode &&other)=delete
PEAK_COMMON_NO_DISCARD peak::common::Range64 Range() const
Returns the range of value values for this node.
Definition peak_integer_node.hpp:160
std::true_type NodeHasRange
Definition peak_integer_node.hpp:42
PEAK_COMMON_NO_DISCARD std::string Unit() const
Returns the unit.
Definition peak_integer_node.hpp:185
void SetValue(int64_t value)
Sets the given value.
Definition peak_integer_node.hpp:200
PEAK_COMMON_NO_DISCARD std::vector< int64_t > ValidValues() const
Returns the valid values.
Definition peak_integer_node.hpp:170
detail::IntervalT< int64_t > Interval64
Interval with signed 64-bit integer boundaries.
Definition peak_common_interval.hpp:258
detail::RangeT< int64_t > Range64
Alias for a range of 64-bit signed integers.
Definition peak_common_range.hpp:252
NodeIncrementType
Definition peak_common_node_enums.hpp:48
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
@ FixedIncrement
Definition peak_common_node_enums.hpp:50
@ Integer
Definition peak_node.hpp:89
@ UseCache
Definition peak_common_node_enums.hpp:38
The "nodes" namespace contains all GenAPI node types.
Definition peak_utils.hpp:31
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_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:258
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition peak_backend.h:427
int32_t PEAK_NODE_REPRESENTATION
Definition peak_backend.h:279
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:240
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:431
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:89
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:13