CVB++ 14.0
enum_entry_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "selector_node.hpp"
6
8#include "_detail/iconfigurable_enum_entry_node.hpp"
10
11namespace Cvb
12{
13CVB_BEGIN_INLINE_NS
14namespace GevServer
15{
17
22 : public ValueNode
24 , public Private::IConfigurableEnumEntryNode
26{
27public:
28 EnumEntryNode(HandleGuard<Node> &&guard) noexcept : ValueNode(std::move(guard)) {}
29
40 static EnumEntryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
41 {
42 String okName = EnsureNodeNameOnly(name);
43 return std::make_shared<EnumEntryNode>(HandleGuard<Node>(
44 CreateGSEnumEntryNodeTyped(okName.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
45 }
46
61 static EnumEntryNodePtr Create(const String &name) { return Create(ParseName(name), ParseNamespace(name)); }
62
68
73 GenApi::CacheMode CacheMode() const noexcept override { return GenApi::CacheMode::NoCache; }
74
78 bool IsStreamable() const override { return false; }
79
83 [[noreturn]] void SetIsStreamable(const std::int64_t & /*value*/) override
84 {
85 throw std::runtime_error("EnumEntry nodes cannot be streamed");
86 }
87
92 template <class Rep, class Period> std::chrono::duration<Rep, Period> PollingTime() const
93 {
95 }
96
98 std::int64_t NumericValue() const { return GetInfoAsInt(NodeInfo::Value); }
99
101 void SetNumericValue(const std::int64_t &value) { SetInfoAsInt(NodeInfo::Value, value); }
102
104 String SymbolicValue() const { return GetInfoAsString(NodeInfo::Value); }
105
107 void SetSymbolicValue(const String &value) { SetInfo(NodeInfo::Value, value); }
108
113 void FromString(const String & /*value*/) override
114 {
115 throw std::runtime_error("Symbolic values cannot be set as value");
116 }
117
122 String ToString() const override { return SymbolicValue(); }
123};
124}
125CVB_END_INLINE_NS
126}
One entry in an enumeration.
Definition: enum_entry_node.hpp:26
void SetNumericValue(const std::int64_t &value)
Sets the numeric value of this entry.
Definition: enum_entry_node.hpp:101
void SetSymbolicValue(const String &value)
Sets the symbolic value of this entity.
Definition: enum_entry_node.hpp:107
void FromString(const String &) override
Not supported.
Definition: enum_entry_node.hpp:113
bool IsStreamable() const override
EnumEntry nodes are never streamable.
Definition: enum_entry_node.hpp:78
static EnumEntryNodePtr Create(const String &name)
Creates a new EnumEntryNode with the given name .
Definition: enum_entry_node.hpp:61
GenApi::CacheMode CacheMode() const noexcept override
Nothing to cache here.
Definition: enum_entry_node.hpp:73
void SetIsStreamable(const std::int64_t &) override
EnumEntry nodes are never streamable.
Definition: enum_entry_node.hpp:83
GenApi::AccessMode AccessMode() const override
Enum entries are always read only.
Definition: enum_entry_node.hpp:67
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:40
std::int64_t NumericValue() const
Gets the numeric value of this entry.
Definition: enum_entry_node.hpp:98
String ToString() const override
Returns SymbolicValue.
Definition: enum_entry_node.hpp:122
String SymbolicValue() const
Gets the symbolic value of this entry.
Definition: enum_entry_node.hpp:104
std::chrono::duration< Rep, Period > PollingTime() const
Nothing to poll.
Definition: enum_entry_node.hpp:92
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:585
static String EnsureNodeNameOnly(const String &name)
Throws if the given name has a namespace prefix.
Definition: decl_node.hpp:558
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:607
Base class for all nodes that have a value.
Definition: value_node.hpp:32
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:148
@ Value
Accesses the value configuration.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24