CVB++ 14.1
enum_entry_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "selector_node.hpp"
6
7
8
9namespace Cvb
10{
11CVB_BEGIN_INLINE_NS
12namespace GevServer
13{
15
20 : public ValueNode
21{
22public:
23 explicit EnumEntryNode(HandleGuard<Node> &&guard) : ValueNode(std::move(guard)) {}
24
35 static EnumEntryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
36 {
37 String okName = EnsureNodeNameOnly(name);
38 return std::make_shared<EnumEntryNode>(HandleGuard<Node>(
39 CreateGSEnumEntryNodeTyped(okName.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
40 }
41
56 static EnumEntryNodePtr Create(const String &name) { return Create(ParseName(name), ParseNamespace(name)); }
57
63
68 GenApi::CacheMode CacheMode() const noexcept override { return GenApi::CacheMode::NoCache; }
69
73 bool IsStreamable() const override { return false; }
74
78 [[noreturn]] void SetIsStreamable(const std::int64_t & /*value*/) override
79 {
80 throw std::runtime_error("EnumEntry nodes cannot be streamed");
81 }
82
87 template <class Rep, class Period> std::chrono::duration<Rep, Period> PollingTime() const
88 {
90 }
91
93 std::int64_t NumericValue() const { return GetInfoAsInt(NodeInfo::Value); }
94
96 void SetNumericValue(const std::int64_t &value) { SetInfoAsInt(NodeInfo::Value, value); }
97
99 String SymbolicValue() const { return GetInfoAsString(NodeInfo::Value); }
100
102 void SetSymbolicValue(const String &value) { SetInfo(NodeInfo::Value, value); }
103
108 void FromString(const String & /*value*/) override
109 {
110 throw std::runtime_error("Symbolic values cannot be set as value");
111 }
112
117 String ToString() const override { return SymbolicValue(); }
118};
119}
120CVB_END_INLINE_NS
121}
One entry in an enumeration.
Definition: enum_entry_node.hpp:21
void SetNumericValue(const std::int64_t &value)
Sets the numeric value of this entry.
Definition: enum_entry_node.hpp:96
void SetSymbolicValue(const String &value)
Sets the symbolic value of this entity.
Definition: enum_entry_node.hpp:102
void FromString(const String &) override
Not supported.
Definition: enum_entry_node.hpp:108
bool IsStreamable() const override
EnumEntry nodes are never streamable.
Definition: enum_entry_node.hpp:73
static EnumEntryNodePtr Create(const String &name)
Creates a new EnumEntryNode with the given name .
Definition: enum_entry_node.hpp:56
GenApi::CacheMode CacheMode() const noexcept override
Nothing to cache here.
Definition: enum_entry_node.hpp:68
void SetIsStreamable(const std::int64_t &) override
EnumEntry nodes are never streamable.
Definition: enum_entry_node.hpp:78
GenApi::AccessMode AccessMode() const override
Enum entries are always read only.
Definition: enum_entry_node.hpp:62
static EnumEntryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new EnumEntryNode with the given name and nameSpace .
Definition: enum_entry_node.hpp:35
std::int64_t NumericValue() const
Gets the numeric value of this entry.
Definition: enum_entry_node.hpp:93
String ToString() const override
Returns SymbolicValue.
Definition: enum_entry_node.hpp:117
String SymbolicValue() const
Gets the symbolic value of this entry.
Definition: enum_entry_node.hpp:99
std::chrono::duration< Rep, Period > PollingTime() const
Nothing to poll.
Definition: enum_entry_node.hpp:87
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:567
static String EnsureNodeNameOnly(const String &name)
Throws if the given name has a namespace prefix.
Definition: decl_node.hpp:540
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:588
Base class for all nodes that have a value.
Definition: value_node.hpp:24
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
@ ReadOnly
Node can only be read.
Namespace
The possible name spaces a node can be in.
Definition: gevserver.hpp:147
@ Value
Accesses the value configuration.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24