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