IDS peak genericC++  v1.6.0
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;
48  int64_t Maximum() const;
50  int64_t Increment() const;
54  std::vector<int64_t> ValidValues() const;
58  std::string Unit() const;
59 
61  int64_t Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
63  void SetValue(int64_t value);
64 
65 private:
66  friend ClassCreator<IntegerNode>;
67  IntegerNode(PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
68  PEAK_INTEGER_NODE_HANDLE m_backendHandle;
69 };
70 
71 } /* namespace nodes */
72 } /* namespace core */
73 } /* namespace peak */
74 
75 /* Implementation */
76 namespace peak
77 {
78 namespace core
79 {
80 namespace nodes
81 {
82 
84  PEAK_INTEGER_NODE_HANDLE integerNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
85  : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
86  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_ToNode(integerNodeHandle, nodeHandle);
87  }),
88  parentNodeMap)
89  , m_backendHandle(integerNodeHandle)
90 {}
91 
92 inline int64_t IntegerNode::Minimum() const
93 {
94  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* minimum) {
95  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMinimum(m_backendHandle, minimum);
96  });
97 }
98 
99 inline int64_t IntegerNode::Maximum() const
100 {
101  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* maximum) {
102  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetMaximum(m_backendHandle, maximum);
103  });
104 }
105 
106 inline int64_t IntegerNode::Increment() const
107 {
108  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* increment) {
109  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrement(m_backendHandle, increment);
110  });
111 }
112 
114 {
115  return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
116  [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
117  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetIncrementType(m_backendHandle, incrementType);
118  }));
119 }
120 
121 inline std::vector<int64_t> IntegerNode::ValidValues() const
122 {
123  return QueryNumericArrayFromCInterfaceFunction<int64_t>([&](int64_t* validValues, size_t* validValuesSize) {
124  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
125  });
126 }
127 
129 {
130  return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
131  [&](PEAK_NODE_REPRESENTATION* representation) {
132  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetRepresentation(m_backendHandle, representation);
133  }));
134 }
135 
136 inline std::string IntegerNode::Unit() const
137 {
138  return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
139  return PEAK_C_ABI_PREFIX PEAK_IntegerNode_GetUnit(m_backendHandle, unit, unitSize);
140  });
141 }
142 
143 inline int64_t IntegerNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
144 {
145  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* value) {
147  m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
148  });
149 }
150 
151 inline void IntegerNode::SetValue(int64_t value)
152 {
153  CallAndCheckCInterfaceFunction(
154  [&] { return PEAK_C_ABI_PREFIX PEAK_IntegerNode_SetValue(m_backendHandle, value); });
155 }
156 
157 } /* namespace nodes */
158 } /* namespace core */
159 } /* 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:128
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:151
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:413
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:143
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition: peak_backend.h:409
NodeIncrementType
Definition: peak_common_node_enums.hpp:33
std::vector< int64_t > ValidValues() const
Returns the valid values.
Definition: peak_integer_node.hpp:121
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:113
int64_t Maximum() const
Returns the maximum.
Definition: peak_integer_node.hpp:99
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:106
~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:92
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:136