CVB++ 15.0
string_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "selector_node.hpp"
6
8#include "_detail/ihas_value_config.hpp"
9#include "_detail/iconfigurable_register_node.hpp"
11
12namespace Cvb
13{
14 CVB_BEGIN_INLINE_NS
15 namespace GevServer
16 {
18
20 class StringNode
21 : public SelectorNode
23 , public Private::IHasValueConfig<StringNodePtr>
25 {
26 public:
27 explicit StringNode(HandleGuard<Node> &&guard)
28 : SelectorNode(std::move(guard))
29 {
30 }
31
42 static StringNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
43 {
44 String okName = EnsureNodeNameOnly(name);
45 return std::make_shared<StringNode>(HandleGuard<Node>(
46 CExports::CreateGSStringNodeExTyped(okName.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
47 }
48
62 static StringNodePtr Create(const String &name)
63 {
64 return Create(ParseName(name), ParseNamespace(name));
65 }
66
72 {
73 auto value = GetTerminalRegisterNode<StringNode, StringNodePtr>(this, [](Node *node) {
74 return dynamic_cast<GevServer::Private::IConfigurableRegisterNode *>(node) ? true : false;
75 });
76 if (value == nullptr)
78 else
79 return value->AccessMode();
80 }
81
87 {
89 this, [](Node *node) { return dynamic_cast<Private::IConfigurableRegisterNode *>(node) ? true : false; });
90 if (value == nullptr)
92 else
93 return value->CacheMode();
94 }
95
96 StringNodePtr ValueConfigAsNode() const override;
97
99
103 String Value() const
104 {
105 return ToString();
106 }
107
109
113 void SetValue(const String &value)
114 {
115 FromString(value);
116 }
117
127 template <class T>
128 T ValueConfig() const
129 {
130 throw std::runtime_error(
131 "requested value config type must be derived from StringNode or be "
132 "of type Cvb::String");
133 }
134
148 template <class T>
149 void SetValueConfig(const T & /*value*/)
150 {
151 throw std::runtime_error(
152 "requested value config type must be derived from "
153 "StringNode or be of Cvb::String type");
154 }
155 };
156
157 template <>
158 inline Cvb::String StringNode::ValueConfig<Cvb::String>() const
159 {
160 return GetInfoAsString(NodeInfo::Value);
161 }
162
163 template <>
164 inline void StringNode::SetValueConfig<Cvb::String>(const Cvb::String &value)
165 {
166 SetInfoAsString(NodeInfo::Value, value);
167 }
168
169 } // namespace GevServer
170 CVB_END_INLINE_NS
171} // namespace Cvb
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 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
ValueNodePtr GetTerminalRegisterNode(const NodeT *node, std::function< bool(Node *)> f) const
Try to get terminal register node.
Definition detail_node.hpp:708
void SetValue(const String &value)
Sets the string value.
Definition string_node.hpp:113
String Value() const
Gets the string value.
Definition string_node.hpp:103
void SetValueConfig(const T &)
Sets the value configuration of this string node.
Definition string_node.hpp:149
static StringNodePtr Create(const String &name)
Creates a new StringNode with the given name .
Definition string_node.hpp:62
GenApi::CacheMode CacheMode() const override
Gets the cache mode of this node.
Definition string_node.hpp:86
T ValueConfig() const
Gets the value configuration of this string node.
Definition string_node.hpp:128
GenApi::AccessMode AccessMode() const override
Gets the access mode of this node.
Definition string_node.hpp:71
static StringNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new StringNode with the given name and nameSpace .
Definition string_node.hpp:42
virtual String ToString() const
Returns this node's value as a string representation.
Definition value_node.hpp:94
virtual void FromString(const String &value)
Sets this node's value from the string value.
Definition value_node.hpp:109
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< StringNode > StringNodePtr
Convenience shared pointer for StringNode.
Definition gevserver.hpp:48
@ Value
Accesses the value configuration.
Definition gevserver.hpp:210
@ 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
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49