CVB++ 15.0
integer_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "integer_base_node.hpp"
6
8#include "_detail/ihas_value_config.hpp"
9#include "_detail/iconfigurable_register_node.hpp"
10#include "_detail/iconfigurable_command_node.hpp"
12
13namespace Cvb
14{
15 CVB_BEGIN_INLINE_NS
16 namespace GevServer
17 {
19
21 class IntegerNode
22 : public IntegerBaseNode
24 , public Private::IHasValueConfig<IntegerBaseNodePtr>
26 {
27 public:
28 explicit IntegerNode(HandleGuard<Node> &&guard)
29 : IntegerBaseNode(std::move(guard))
30 {
31 }
32
43 static IntegerNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
44 {
45 return std::make_shared<IntegerNode>(HandleGuard<Node>(
46 CExports::CreateGSIntegerNodeTyped(name.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
47 }
48
62 static IntegerNodePtr Create(const String &name)
63 {
64 return Create(ParseName(name), ParseNamespace(name));
65 }
66
80 template <class T>
82 {
84 "requested increment config type must be derived from IntegerBaseNode or "
85 "be "
86 "of type int64_t");
87 }
88
90
96 template <class T>
97 void SetIncrementConfig(const T & /*value*/)
98 {
100 "requested value config type must be derived from "
101 "IntegerBaseNode or be of type std::int64_t");
102 }
103
109 {
111 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode *>(node) ? true : false; });
112 if (value == nullptr)
114 else
115 return value->AccessMode();
116 }
117
123 {
125 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode *>(node) ? true : false; });
126 if (value == nullptr)
128 else
129 return value->CacheMode();
130 }
131
136 template <class Rep, class Period>
138 {
140 auto isRegisterNode = dynamic_cast<Private::IConfigurableRegisterNode *>(node);
141 auto isCommandNode = dynamic_cast<Private::IConfigurableCommandNode *>(node);
142 return (isRegisterNode || isCommandNode) ? true : false;
143 });
144 if (value == nullptr)
146 else
147 return value->template PollingTime<Rep, Period>();
148 }
149
158 template <class T>
159 T MaxConfig() const
160 {
161 throw std::runtime_error(
162 "requested max config type must be derived from IntegerBaseNode or be "
163 "of type int64_t");
164 }
165
178 template <class T>
179 void SetMaxConfig(const T & /*value*/)
180 {
181 throw std::runtime_error(
182 "requested value config type must be derived from "
183 "IntegerBaseNode or be of type std::int64_t");
184 }
185
194 template <class T>
195 T MinConfig() const
196 {
197 throw std::runtime_error(
198 "requested min config type must be derived from IntegerBaseNode or be "
199 "of type int64_t");
200 }
201
214 template <class T>
215 void SetMinConfig(const T & /*value*/)
216 {
217 throw std::runtime_error(
218 "requested min config type must be derived from "
219 "IntegerBaseNode or be of type std::int64_t");
220 }
221
222 IntegerBaseNodePtr ValueConfigAsNode() const override;
223
233 template <class T>
234 T ValueConfig() const
235 {
236 throw std::runtime_error(
237 "requested value config type must be derived from IntegerBaseNode or be "
238 "of type int64_t");
239 }
240
254 template <class T>
255 void SetValueConfig(const T & /*value*/)
256 {
257 throw std::runtime_error(
258 "requested value config type must be derived from "
259 "IntegerBaseNode or be of integral type");
260 }
261
263
267 String Unit() const override
268 {
269 return {}; // Not implemented in register map
270 }
271
272 void SetUnit(const String & /*unit*/) override
273 {
274 // SetInfo(NodeInfo::Unit, unit); // not implemented in register map
275 }
276 };
277
278 template <>
279 inline std::int64_t IntegerNode::MaxConfig<std::int64_t>() const
280 {
281 return GetInfoAsInt(NodeInfo::Max);
282 }
283
284 template <>
285 inline void IntegerNode::SetMaxConfig<std::int64_t>(const std::int64_t &value)
286 {
287 SetInfoAsInt(NodeInfo::Max, value);
288 }
289
290 template <>
291 inline std::int64_t IntegerNode::MinConfig<std::int64_t>() const
292 {
293 return GetInfoAsInt(NodeInfo::Min);
294 }
295
296 template <>
297 inline void IntegerNode::SetMinConfig<std::int64_t>(const std::int64_t &value)
298 {
299 SetInfoAsInt(NodeInfo::Min, value);
300 }
301
302 template <>
303 inline std::int64_t IntegerNode::ValueConfig<std::int64_t>() const
304 {
305 return GetInfoAsInt(NodeInfo::Value);
306 }
307
308 template <>
309 inline std::int64_t IntegerNode::IncrementConfig<std::int64_t>() const
310 {
311 return GetInfoAsInt(NodeInfo::Increment);
312 }
313
314 template <>
315 inline void IntegerNode::SetIncrementConfig<std::int64_t>(const std::int64_t &value)
316 {
317 SetInfoAsInt(NodeInfo::Increment, value);
318 }
319
320 template <>
321 inline void IntegerNode::SetValueConfig<std::int64_t>(const std::int64_t &value)
322 {
323 SetInfoAsInt(NodeInfo::Value, value);
324 }
325
326 } // namespace GevServer
327 CVB_END_INLINE_NS
328} // namespace Cvb
void SetMinConfig(const T &)
Sets the minimum configuration of this integer node.
Definition integer_node.hpp:215
void SetMaxConfig(const T &)
Sets the maximum configuration of this integer node.
Definition integer_node.hpp:179
String Unit() const override
Gets the unit of this node's value.
Definition integer_node.hpp:267
T MaxConfig() const
Gets the maximum configuration of this integer node.
Definition integer_node.hpp:159
void SetIncrementConfig(const T &)
Sets the increment of this value.
Definition integer_node.hpp:97
void SetValueConfig(const T &)
Sets the value configuration of this integer node.
Definition integer_node.hpp:255
T MinConfig() const
Gets the minimum configuration of this integer node.
Definition integer_node.hpp:195
GenApi::CacheMode CacheMode() const override
Gets the cache mode by querying all ValueConfigs for it.
Definition integer_node.hpp:122
T ValueConfig() const
Gets the value configuration of this integer node.
Definition integer_node.hpp:234
GenApi::AccessMode AccessMode() const override
Gets the access mode by querying all ValueConfigs for it.
Definition integer_node.hpp:108
static IntegerNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new IntegerNode with the given name and nameSpace .
Definition integer_node.hpp:43
static IntegerNodePtr Create(const String &name)
Creates a new IntegerNode with the given name .
Definition integer_node.hpp:62
T IncrementConfig() const
Gets and sets the increment configuration of this integer node.
Definition integer_node.hpp:81
std::chrono::duration< Rep, Period > PollingTime() const
Gets the polling time by querying all ValueConfigs for it.
Definition integer_node.hpp:137
Basic GevServer node for device feature access.
Definition decl_node.hpp:34
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition decl_node.hpp:591
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition decl_node.hpp:611
ValueNodePtr GetTerminalRegisterNode(const NodeT *node, std::function< bool(Node *)> f) const
Try to get terminal register node.
Definition detail_node.hpp:708
T make_shared(T... args)
T move(T... args)
CacheMode
Defines how the value is cached.
Definition genapi.hpp:218
@ NoCache
No caching used.
Definition genapi.hpp:220
AccessMode
Access possibility of the node.
Definition genapi.hpp:183
@ ReadWrite
Node can be read and written to.
Definition genapi.hpp:213
Describes a GenICam Pixel Format Naming Convention (PFNC) compatible image memory buffer with possibl...
Definition decl_int_swiss_knife_node.hpp:11
Namespace
The possible name spaces a node can be in.
Definition gevserver.hpp:147
std::shared_ptr< IntegerBaseNode > IntegerBaseNodePtr
Convenience shared pointer for IntegerBaseNode.
Definition gevserver.hpp:64
std::shared_ptr< IntegerNode > IntegerNodePtr
Convenience shared pointer for IntegerNode.
Definition gevserver.hpp:72
@ Value
Accesses the value configuration.
Definition gevserver.hpp:210
@ Max
Gets the maximum value.
Definition gevserver.hpp:195
@ Increment
Gets the increment.
Definition gevserver.hpp:197
@ Min
Gets the minimum value.
Definition gevserver.hpp:196
@ String
Node is a string node (no reg).
Definition gevserver.hpp:168
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17