CVB++ 14.1
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{
15CVB_BEGIN_INLINE_NS
16namespace GevServer
17{
19
22 : public IntegerBaseNode
24 , public Private::IHasValueConfig<IntegerBaseNodePtr>
26{
27public:
28 explicit IntegerNode(HandleGuard<Node> &&guard) : IntegerBaseNode(std::move(guard)) {}
29
40 static IntegerNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
41 {
42 return std::make_shared<IntegerNode>(HandleGuard<Node>(
43 CExports::CreateGSIntegerNodeTyped(name.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
44 }
45
59 static IntegerNodePtr Create(const String &name) { return Create(ParseName(name), ParseNamespace(name)); }
60
74 template <class T> T IncrementConfig() const
75 {
76 throw std::runtime_error("requested increment config type must be derived from IntegerBaseNode or "
77 "be "
78 "of type int64_t");
79 }
80
82
88 template <class T> void SetIncrementConfig(const T & /*value*/)
89 {
90 throw std::runtime_error("requested value config type must be derived from "
91 "IntegerBaseNode or be of type std::int64_t");
92 }
93
99 {
100 auto value = GetTerminalRegisterNode<IntegerNode, IntegerBaseNodePtr>(
101 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode*>(node) ? true : false; });
102 if (value == nullptr)
104 else
105 return value->AccessMode();
106 }
107
113 {
114 auto value = GetTerminalRegisterNode<IntegerNode, IntegerBaseNodePtr>(
115 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode*>(node) ? true : false; });
116 if (value == nullptr)
118 else
119 return value->CacheMode();
120 }
121
126 template <class Rep, class Period> std::chrono::duration<Rep, Period> PollingTime() const
127 {
128 auto value = GetTerminalRegisterNode<IntegerNode, IntegerBaseNodePtr>(this, [](Node *node) {
129 auto isRegisterNode = dynamic_cast<Private::IConfigurableRegisterNode*>(node);
130 auto isCommandNode = dynamic_cast<Private::IConfigurableCommandNode *>(node);
131 return (isRegisterNode || isCommandNode) ? true : false;
132 });
133 if (value == nullptr)
135 else
136 return value->template PollingTime<Rep, Period>();
137 }
138
147 template <class T> T MaxConfig() const
148 {
149 throw std::runtime_error("requested max config type must be derived from IntegerBaseNode or be "
150 "of type int64_t");
151 }
152
165 template <class T> void SetMaxConfig(const T & /*value*/)
166 {
167 throw std::runtime_error("requested value config type must be derived from "
168 "IntegerBaseNode or be of type std::int64_t");
169 }
170
179 template <class T> T MinConfig() const
180 {
181 throw std::runtime_error("requested min config type must be derived from IntegerBaseNode or be "
182 "of type int64_t");
183 }
184
197 template <class T> void SetMinConfig(const T & /*value*/)
198 {
199 throw std::runtime_error("requested min config type must be derived from "
200 "IntegerBaseNode or be of type std::int64_t");
201 }
202
203 IntegerBaseNodePtr ValueConfigAsNode() const override;
204
214 template <class T> T ValueConfig() const
215 {
216 throw std::runtime_error("requested value config type must be derived from IntegerBaseNode or be "
217 "of type int64_t");
218 }
219
233 template <class T> void SetValueConfig(const T & /*value*/)
234 {
235 throw std::runtime_error("requested value config type must be derived from "
236 "IntegerBaseNode or be of integral type");
237 }
238
239
241
245 String Unit() const override
246 {
247 return {}; // Not implemented in register map
248 }
249
250 void SetUnit(const String& /*unit*/) override
251 {
252 //SetInfo(NodeInfo::Unit, unit); // not implemented in register map
253 }
254};
255
256template <> inline std::int64_t IntegerNode::MaxConfig<std::int64_t>() const
257{
258 return GetInfoAsInt(NodeInfo::Max);
259}
260
261template <> inline void IntegerNode::SetMaxConfig<std::int64_t>(const std::int64_t &value)
262{
263 SetInfoAsInt(NodeInfo::Max, value);
264}
265
266template <> inline std::int64_t IntegerNode::MinConfig<std::int64_t>() const
267{
268 return GetInfoAsInt(NodeInfo::Min);
269}
270
271template <> inline void IntegerNode::SetMinConfig<std::int64_t>(const std::int64_t &value)
272{
273 SetInfoAsInt(NodeInfo::Min, value);
274}
275
276template <> inline std::int64_t IntegerNode::ValueConfig<std::int64_t>() const
277{
278 return GetInfoAsInt(NodeInfo::Value);
279}
280
281template <> inline std::int64_t IntegerNode::IncrementConfig<std::int64_t>() const
282{
283 return GetInfoAsInt(NodeInfo::Increment);
284}
285
286template <> inline void IntegerNode::SetIncrementConfig<std::int64_t>(const std::int64_t &value)
287{
288 SetInfoAsInt(NodeInfo::Increment, value);
289}
290
291template <> inline void IntegerNode::SetValueConfig<std::int64_t>(const std::int64_t &value)
292{
293 SetInfoAsInt(NodeInfo::Value, value);
294}
295
296}
297CVB_END_INLINE_NS
298}
Represents an integer number.
Definition: integer_base_node.hpp:19
Represents a integer number.
Definition: integer_node.hpp:26
void SetMinConfig(const T &)
Sets the minimum configuration of this integer node.
Definition: integer_node.hpp:197
void SetMaxConfig(const T &)
Sets the maximum configuration of this integer node.
Definition: integer_node.hpp:165
String Unit() const override
Gets the unit of this node's value.
Definition: integer_node.hpp:245
T MaxConfig() const
Gets the maximum configuration of this integer node.
Definition: integer_node.hpp:147
void SetIncrementConfig(const T &)
Sets the increment of this value.
Definition: integer_node.hpp:88
void SetValueConfig(const T &)
Sets the value configuration of this integer node.
Definition: integer_node.hpp:233
T MinConfig() const
Gets the minimum configuration of this integer node.
Definition: integer_node.hpp:179
GenApi::CacheMode CacheMode() const override
Gets the cache mode by querying all ValueConfigs for it.
Definition: integer_node.hpp:112
T ValueConfig() const
Gets the value configuration of this integer node.
Definition: integer_node.hpp:214
GenApi::AccessMode AccessMode() const override
Gets the access mode by querying all ValueConfigs for it.
Definition: integer_node.hpp:98
static IntegerNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new IntegerNode with the given name and nameSpace .
Definition: integer_node.hpp:40
static IntegerNodePtr Create(const String &name)
Creates a new IntegerNode with the given name .
Definition: integer_node.hpp:59
T IncrementConfig() const
Gets and sets the increment configuration of this integer node.
Definition: integer_node.hpp:74
std::chrono::duration< Rep, Period > PollingTime() const
Gets the polling time by querying all ValueConfigs for it.
Definition: integer_node.hpp:126
Basic GevServer node for device feature access.
Definition: decl_node.hpp:36
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:567
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:588
CacheMode
Defines how the value is cached.
Definition: genapi.hpp:220
@ NoCache
No caching used.
AccessMode
Access possibility of the node.
Definition: genapi.hpp:185
@ ReadWrite
Node can be read and written to.
Namespace
The possible name spaces a node can be in.
Definition: gevserver.hpp:147
@ Value
Accesses the value configuration.
@ Max
Gets the maximum value.
@ Increment
Gets the increment.
@ Min
Gets the minimum value.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24