IDS peak genericC++  v1.7.1
peak_integer_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 
24 namespace peak
25 {
26 namespace core
27 {
28 namespace nodes
29 {
30 
35 class IntegerNode : public Node
36 {
37 public:
38  IntegerNode() = delete;
39  ~IntegerNode() override = default;
40  IntegerNode(const IntegerNode& other) = delete;
41  IntegerNode& operator=(const IntegerNode& other) = delete;
42  IntegerNode(IntegerNode&& other) = delete;
43  IntegerNode& operator=(IntegerNode&& other) = delete;
44 
46  int64_t Minimum() const;
47 
49  int64_t Maximum() const;
50 
52  int64_t Increment() const;
53 
56 
58  std::vector<int64_t> ValidValues() const;
59 
62 
64  std::string Unit() const;
65 
67  int64_t Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
68 
70  void SetValue(int64_t value);
71 
72 private:
73  friend ClassCreator<IntegerNode>;
74  IntegerNode(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
75  PEAK_INTEGER_NODE_HANDLE m_backendHandle;
76 };
77 
78 } /* namespace nodes */
79 } /* namespace core */
80 } /* namespace peak */
81 
82 /* Implementation */
83 namespace peak
84 {
85 namespace core
86 {
87 namespace nodes
88 {
89 
91  PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
92  : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
93  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_ToNode(integerNodeHandle, nodeHandle);
94  }),
95  parentNodeMap)
96  , m_backendHandle(integerNodeHandle)
97 {}
98 
99 inline int64_t IntegerNode::Minimum() const
100 {
101  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* minimum) {
102  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMinimum(m_backendHandle, minimum);
103  });
104 }
105 
106 inline int64_t IntegerNode::Maximum() const
107 {
108  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* maximum) {
109  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMaximum(m_backendHandle, maximum);
110  });
111 }
112 
113 inline int64_t IntegerNode::Increment() const
114 {
115  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* increment) {
116  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrement(m_backendHandle, increment);
117  });
118 }
119 
121 {
122  return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
123  [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
124  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrementType(m_backendHandle, incrementType);
125  }));
126 }
127 
128 inline std::vector<int64_t> IntegerNode::ValidValues() const
129 {
130  return QueryNumericArrayFromCInterfaceFunction<int64_t>([&](int64_t* validValues, size_t* validValuesSize) {
131  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
132  });
133 }
134 
136 {
137  return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
138  [&](PEAK_NODE_REPRESENTATION* representation) {
139  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetRepresentation(m_backendHandle, representation);
140  }));
141 }
142 
143 inline std::string IntegerNode::Unit() const
144 {
145  return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
146  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetUnit(m_backendHandle, unit, unitSize);
147  });
148 }
149 
150 inline int64_t IntegerNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
151 {
152  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* value) {
154  m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
155  });
156 }
157 
158 inline void IntegerNode::SetValue(int64_t value)
159 {
160  CallAndCheckCInterfaceFunction(
161  [&] { return PEAK_C_ABI_PREFIX PEAK_IntegerNode_SetValue(m_backendHandle, value); });
162 }
163 
164 } /* namespace nodes */
165 } /* namespace core */
166 } /* namespace peak */
PEAK_C_API PEAK_IntegerNode_GetIncrement(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *increment)
Asks the given integer node for its increment.
NodeRepresentation Representation() const
Returns the representation.
Definition: peak_integer_node.hpp:135
Represents a GenAPI integer node.
Definition: peak_integer_node.hpp:35
PEAK_C_API PEAK_IntegerNode_GetMinimum(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *minimum)
Asks the given integer node for its minimum.
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_ToNode(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given integer node to a node.
void SetValue(int64_t value)
Sets the given value.
Definition: peak_integer_node.hpp:158
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
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:415
NodeCacheUsePolicy
Definition: peak_common_node_enums.hpp:24
int32_t PEAK_NODE_INCREMENT_TYPE
Definition: peak_backend.h:243
PEAK_C_API PEAK_IntegerNode_GetMaximum(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t *maximum)
Asks the given integer node for its maximum.
int64_t Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition: peak_integer_node.hpp:150
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition: peak_backend.h:411
NodeIncrementType
Definition: peak_common_node_enums.hpp:33
std::vector< int64_t > ValidValues() const
Returns the valid values.
Definition: peak_integer_node.hpp:128
PEAK_C_API PEAK_IntegerNode_SetValue(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, int64_t value)
Tells the given integer node to set the given value.
IntegerNode & operator=(const IntegerNode &other)=delete
NodeIncrementType IncrementType() const
Returns the increment type.
Definition: peak_integer_node.hpp:120
int64_t Maximum() const
Returns the maximum.
Definition: peak_integer_node.hpp:106
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.
int64_t Increment() const
Returns the increment.
Definition: peak_integer_node.hpp:113
~IntegerNode() override=default
#define PEAK_C_ABI_PREFIX
Definition: peak_dll_defines.h:16
NodeRepresentation
Definition: peak_common_node_enums.hpp:43
PEAK_C_API PEAK_IntegerNode_GetRepresentation(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, PEAK_NODE_REPRESENTATION *representation)
Asks the given integer node for its representation.
int64_t Minimum() const
Returns the minimum.
Definition: peak_integer_node.hpp:99
Represents a GenAPI node.
Definition: peak_node.hpp:121
int32_t PEAK_NODE_REPRESENTATION
Definition: peak_backend.h:264
std::string Unit() const
Returns the unit.
Definition: peak_integer_node.hpp:143