CVB++ 15.0
float_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "float_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 FloatNode
22 : public FloatBaseNode
24 , public Private::IHasValueConfig<FloatBaseNodePtr>
26 {
27 public:
28 explicit FloatNode(HandleGuard<Node> &&guard)
29 : FloatBaseNode(std::move(guard))
30 {
31 }
32
43 static FloatNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
44 {
45 return std::make_shared<FloatNode>(HandleGuard<Node>(
46 CExports::CreateGSFloatNodeTyped(name.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
47 }
48
62 static FloatNodePtr 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 FloatNode or "
85 "be "
86 "of type double");
87 }
88
90
98 template <class T>
99 void SetIncrementConfig(const T & /*value*/)
100 {
101 throw std::runtime_error(
102 "requested value config type must be derived from "
103 "FloatNode or be of type double");
104 }
105
111 {
113 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode *>(node) ? true : false; });
114 if (value == nullptr)
116 else
117 return value->AccessMode();
118 }
119
125 {
127 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode *>(node) ? true : false; });
128 if (value == nullptr)
130 else
131 return value->CacheMode();
132 }
133
138 template <class Rep, class Period>
140 {
142 auto isRegisterNode = dynamic_cast<Private::IConfigurableRegisterNode *>(node);
143 auto isCommandNode = dynamic_cast<Private::IConfigurableCommandNode *>(node);
144 return (isRegisterNode || isCommandNode) ? true : false;
145 });
146 if (value == nullptr)
148 else
149 return value->template PollingTime<Rep, Period>();
150 }
151
160 template <class T>
161 T MaxConfig() const
162 {
163 throw std::runtime_error(
164 "requested max config type must be derived from FloatNode or be "
165 "of type double");
166 }
167
180 template <class T>
181 void SetMaxConfig(const T & /*value*/)
182 {
183 throw std::runtime_error(
184 "requested value config type must be derived from "
185 "FloatNode or be of type double");
186 }
187
196 template <class T>
197 T MinConfig() const
198 {
199 throw std::runtime_error(
200 "requested min config type must be derived from FloatNode or be "
201 "of type double");
202 }
203
216 template <class T>
217 void SetMinConfig(const T & /*value*/)
218 {
219 throw std::runtime_error(
220 "requested min config type must be derived from "
221 "FloatNode or be of type double");
222 }
223
225
229 String Unit() const
230 {
231 auto bufferSize = NativeCall<size_t>([&](size_t &size) {
232 return CExports::GSNGetInfoAsStringTyped(Handle(), CExports::TGSNodeInfo::GSNI_Unit,
233 reinterpret_cast<Char *>(0), size);
234 });
235
236 bufferSize += sizeof(Char);
237 std::vector<Char> buffer(bufferSize);
238 NativeCall([&]() {
239 return CExports::GSNGetInfoAsStringTyped(Handle(), CExports::TGSNodeInfo::GSNI_Unit, buffer.data(),
240 bufferSize);
241 });
242
243 return buffer.data() ? String(buffer.data()) : String();
244 }
245
247
251 void SetUnit(const String &unit)
252 {
253 SetInfo(NodeInfo::Unit, unit);
254 }
255
257 // TODO: This is currently not implemented in the RegMap. As I did not find it in a camera xml either (not
258 // important?!), I'd like to keep this TODO rather then a "not implemented" which makes customers want this.
261 // * \return Display notation of this node as text.
262 // * \throws Any exception derived from std::exception including CvbException.
263 // */
264 // String DisplayNotation() const
265 //{
266
267 //}
268
269 // void SetDisplayNotation(const String& displayNotation)
270 //{
271
272 //}
274
276
280 double DisplayPrecision() const
281 {
282 return GetInfoAsFloat(NodeInfo::DisplayPrecision);
283 }
284
286
291 void SetDisplayPrecision(const double displayPrecision)
292 {
293 SetInfoAsFloat(NodeInfo::DisplayPrecision, displayPrecision);
294 }
295
296 FloatBaseNodePtr ValueConfigAsNode() const override;
297
307 template <class T>
308 T ValueConfig() const
309 {
310 throw std::runtime_error(
311 "requested value config type must be derived from FloatNode or be "
312 "of type double");
313 }
314
328 template <class T>
329 void SetValueConfig(const T & /*value*/)
330 {
331 throw std::runtime_error(
332 "requested value config type must be derived from "
333 "FloatNode or be of type double");
334 }
335 };
336
337 template <>
338 inline double FloatNode::MaxConfig<double>() const
339 {
340 return GetInfoAsFloat(NodeInfo::Max);
341 }
342
343 template <>
344 inline void FloatNode::SetMaxConfig<double>(const double &value)
345 {
346 SetInfoAsFloat(NodeInfo::Max, value);
347 }
348
349 template <>
350 inline double FloatNode::MinConfig<double>() const
351 {
352 return GetInfoAsFloat(NodeInfo::Min);
353 }
354
355 template <>
356 inline void FloatNode::SetMinConfig<double>(const double &value)
357 {
358 SetInfoAsFloat(NodeInfo::Min, value);
359 }
360
361 template <>
362 inline double FloatNode::ValueConfig<double>() const
363 {
364 return GetInfoAsFloat(NodeInfo::Value);
365 }
366
367 template <>
368 inline double FloatNode::IncrementConfig<double>() const
369 {
370 return GetInfoAsFloat(NodeInfo::Increment);
371 }
372
373 template <>
374 inline void FloatNode::SetIncrementConfig<double>(const double &value)
375 {
376 SetInfoAsFloat(NodeInfo::Increment, value);
377 }
378
379 template <>
380 inline void FloatNode::SetValueConfig<double>(const double &value)
381 {
382 SetInfoAsFloat(NodeInfo::Value, value);
383 }
384
385 } // namespace GevServer
386 CVB_END_INLINE_NS
387} // namespace Cvb
void SetDisplayPrecision(const double displayPrecision)
Sets the display precision of this node's value.
Definition float_node.hpp:291
void SetMinConfig(const T &)
Sets the minimum configuration of this float node.
Definition float_node.hpp:217
void SetMaxConfig(const T &)
Sets the maximum configuration of this float node.
Definition float_node.hpp:181
T MaxConfig() const
Gets the maximum configuration of this float node.
Definition float_node.hpp:161
void SetUnit(const String &unit)
Sets the unit of this node's value.
Definition float_node.hpp:251
void SetIncrementConfig(const T &)
Sets the increment of this value.
Definition float_node.hpp:99
String Unit() const
Gets the unit of this node's value.
Definition float_node.hpp:229
void SetValueConfig(const T &)
Sets the value configuration of this float node.
Definition float_node.hpp:329
T MinConfig() const
Gets the minimum configuration of this float node.
Definition float_node.hpp:197
static FloatNodePtr Create(const String &name)
Creates a new FloatNode with the given name .
Definition float_node.hpp:62
GenApi::CacheMode CacheMode() const override
Gets the cache mode by querying all ValueConfigs for it.
Definition float_node.hpp:124
T ValueConfig() const
Gets the value configuration of this float node.
Definition float_node.hpp:308
GenApi::AccessMode AccessMode() const override
Gets the access mode by querying all ValueConfigs for it.
Definition float_node.hpp:110
double DisplayPrecision() const
Gets the current display precision value.
Definition float_node.hpp:280
T IncrementConfig() const
Gets and sets the increment configuration of this float node.
Definition float_node.hpp:81
static FloatNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new FloatNode with the given name and nameSpace .
Definition float_node.hpp:43
std::chrono::duration< Rep, Period > PollingTime() const
Gets the polling time by querying all ValueConfigs for it.
Definition float_node.hpp:139
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
void * Handle() const noexcept
Classic API node handle.
Definition decl_node.hpp:102
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
@ DisplayPrecision
Accesses the float node's display precision configuration.
Definition gevserver.hpp:224
@ Unit
Accesses the unit of a node as string.
Definition gevserver.hpp:223
@ 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
std::shared_ptr< FloatNode > FloatNodePtr
Convenience shared pointer for FloatNode.
Definition gevserver.hpp:76
@ String
Node is a string node (no reg).
Definition gevserver.hpp:168
std::shared_ptr< FloatBaseNode > FloatBaseNodePtr
Convenience shared pointer for FloatBaseNode.
Definition gevserver.hpp:68
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63