CVB++ 15.0
string_reg_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "string_node.hpp"
6
8#include "_detail/iconfigurable_register_node.hpp"
10
11namespace Cvb
12{
13 CVB_BEGIN_INLINE_NS
14 namespace GevServer
15 {
17
19 class StringRegNode
20 : public StringNode
22 , public Private::IConfigurableRegisterNode
24 {
25 public:
26 explicit StringRegNode(HandleGuard<Node> &&guard)
27 : StringNode(std::move(guard))
28 {
29 }
30
43 static StringRegNodePtr Create(const String &name, const GevServer::Namespace &nameSpace,
44 const std::int64_t &address, const std::int64_t &length)
45 {
46 String okName = EnsureNodeNameOnly(name);
47 return std::make_shared<StringRegNode>(HandleGuard<Node>(CExports::CreateGSStringRegNodeTyped(
48 okName.data(), static_cast<CExports::TGSNamespace>(nameSpace), address, length)));
49 }
50
66 static StringRegNodePtr Create(const String &name, const std::int64_t &address, const std::int64_t &length)
67 {
68 return Create(ParseName(name), ParseNamespace(name), address, length);
69 }
70
86 static StringRegNodePtr Create(const String &name, const std::int64_t &length)
87 {
88 return Create(ParseName(name), ParseNamespace(name), -1, length);
89 }
90
95 {
96 return static_cast<GenApi::AccessMode>(GetInfoAsInt(NodeInfo::AccessMode));
97 }
98
107 {
108 SetInfoAsInt(NodeInfo::AccessMode, static_cast<std::int64_t>(value));
109 }
110
112
117 {
118 return StringNode::GetInfoAsInt(NodeInfo::RegisterAddress);
119 }
120
141
146 {
147 return static_cast<GenApi::CacheMode>(GetInfoAsInt(NodeInfo::CachingMode));
148 }
149
158 {
159 SetInfoAsInt(NodeInfo::CachingMode, static_cast<std::int64_t>(value));
160 }
161
176
178
183 {
184 return StringNode::GetInfoAsInt(NodeInfo::RegisterLength);
185 }
186
194 template <class Rep, class Period>
196 {
197 auto timespan = GetInfoAsInt(NodeInfo::PollingTime);
198 if (timespan > 0)
199 return std::chrono::duration<Rep, Period>(timespan);
200 else
202 }
203
216 template <class Rep, class Period>
218 {
220 SetInfoAsInt(NodeInfo::PollingTime, -1);
221 else
223 }
224
226
230 String Value() const
231 {
232 auto bufferSize = NativeCall<size_t>(
233 [&](size_t &size) { return CExports::GSNGetAsStringTyped(Handle(), reinterpret_cast<Char *>(0), size); });
234 bufferSize += sizeof(Char);
235 std::vector<Char> buffer(bufferSize);
236 NativeCall([&]() { return CExports::GSNGetAsStringTyped(Handle(), buffer.data(), bufferSize); });
237 return buffer.data();
238 }
239
241
245 void SetValue(const String &value)
246 {
247 NativeCall([&]() { return CExports::GSNSetAsStringTyped(Handle(), value.data()); });
248 }
249 };
250 } // namespace GevServer
251 CVB_END_INLINE_NS
252} // namespace Cvb
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition decl_node.hpp:591
static String EnsureNodeNameOnly(const String &name)
Throws if the given name has a namespace prefix.
Definition decl_node.hpp:564
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition decl_node.hpp:611
void * Handle() const noexcept
Classic API node handle.
Definition decl_node.hpp:102
std::vector< std::shared_ptr< T > > GetDependentNodes(const NodeList &type) const
Gets the nodes categorized by this node.
Definition detail_node.hpp:410
static StringRegNodePtr Create(const String &name, const std::int64_t &length)
Creates a new StringRegNode with the given name .
Definition string_reg_node.hpp:86
std::vector< IntegerBaseNodePtr > AddressNodes() const
Gets the collection of nodes which define the nodes address.
Definition string_reg_node.hpp:137
void SetValue(const String &value)
Sets the value of this string register node.
Definition string_reg_node.hpp:245
void SetPollingTime(const std::chrono::duration< Rep, Period > &timespan)
Sets the polling time of this value.
Definition string_reg_node.hpp:217
String Value() const
Gets the value of this string register node.
Definition string_reg_node.hpp:230
void SetCacheMode(const GenApi::CacheMode &value)
Sets the caching mode of this register node.
Definition string_reg_node.hpp:157
static StringRegNodePtr Create(const String &name, const GevServer::Namespace &nameSpace, const std::int64_t &address, const std::int64_t &length)
Creates a new StringRegNode with the given name and nameSpace .
Definition string_reg_node.hpp:43
GenApi::CacheMode CacheMode() const override
Gets the caching mode of this register node.
Definition string_reg_node.hpp:145
GenApi::AccessMode AccessMode() const override
Gets the GenApi::AccessMode of this node.
Definition string_reg_node.hpp:94
std::int64_t Length() const
Gets the number of bytes the register occupies.
Definition string_reg_node.hpp:182
std::int64_t Address() const
Gets the registers address.
Definition string_reg_node.hpp:116
void SetAccessMode(const GenApi::AccessMode &value)
Gets the GenApi::AccessMode of this node.
Definition string_reg_node.hpp:106
static StringRegNodePtr Create(const String &name, const std::int64_t &address, const std::int64_t &length)
Creates a new StringRegNode with the given name .
Definition string_reg_node.hpp:66
std::vector< NodePtr > InvalidatorNodes() const noexcept
Gets the collection of nodes which, when changed, invalidate this node's cache.
Definition string_reg_node.hpp:172
std::chrono::duration< Rep, Period > PollingTime() const
Gets the polling time of this value.
Definition string_reg_node.hpp:195
T duration_cast(T... args)
T make_shared(T... args)
T move(T... args)
CacheMode
Defines how the value is cached.
Definition genapi.hpp:218
AccessMode
Access possibility of the node.
Definition genapi.hpp:183
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< StringRegNode > StringRegNodePtr
Convenience shared pointer for StringRegNode.
Definition gevserver.hpp:52
@ AccessMode
Gets the access mode of the node.
Definition gevserver.hpp:194
@ PollingTime
Gets the polling time in ms.
Definition gevserver.hpp:204
@ CachingMode
Gets the caching mode.
Definition gevserver.hpp:200
@ RegisterAddress
Gets the current address of the register (can change).
Definition gevserver.hpp:208
@ RegisterLength
Gets the register nodes length in bytes.
Definition gevserver.hpp:207
@ String
Node is a string node (no reg).
Definition gevserver.hpp:168
@ Addresses
Node accesses the register address nodes (not constants).
Definition gevserver.hpp:256
@ Invalidator
Node accesses the invalidator nodes.
Definition gevserver.hpp:255
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