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 
11 namespace Cvb
12 {
13 CVB_BEGIN_INLINE_NS
14 namespace GevServer
15 {
17 
22  : public ValueNode
24  , public Private::IConfigurableEnumEntryNode
26 {
27 public:
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 }
125 CVB_END_INLINE_NS
126 }
STL class.
std::chrono::duration< Rep, Period > PollingTime() const
Nothing to poll.
Definition: enum_entry_node.hpp:92
Base class for all nodes that have a value.
Definition: value_node.hpp:27
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:606
void SetNumericValue(const std::int64_t &value)
Sets the numeric value of this entry.
Definition: enum_entry_node.hpp:101
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
String SymbolicValue() const
Gets the symbolic value of this entry.
Definition: enum_entry_node.hpp:104
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:584
Namespace
The possible name spaces a node can be in.
Definition: gevserver.hpp:147
Only read operations are validated.
static String EnsureNodeNameOnly(const String &name)
Throws if the given name has a namespace prefix.
Definition: decl_node.hpp:557
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
GenApi::CacheMode CacheMode() const noexcept override
Nothing to cache here.
Definition: enum_entry_node.hpp:73
std::int64_t NumericValue() const
Gets the numeric value of this entry.
Definition: enum_entry_node.hpp:98
static EnumEntryNodePtr Create(const String &name)
Creates a new EnumEntryNode with the given name .
Definition: enum_entry_node.hpp:61
Accesses the value configuration.
void FromString(const String &) override
Not supported.
Definition: enum_entry_node.hpp:113
void SetIsStreamable(const std::int64_t &) override
EnumEntry nodes are never streamable.
Definition: enum_entry_node.hpp:83
String ToString() const override
Returns SymbolicValue.
Definition: enum_entry_node.hpp:122
GenApi::AccessMode AccessMode() const override
Enum entries are always read only.
Definition: enum_entry_node.hpp:67
void SetSymbolicValue(const String &value)
Sets the symbolic value of this entity.
Definition: enum_entry_node.hpp:107
bool IsStreamable() const override
EnumEntry nodes are never streamable.
Definition: enum_entry_node.hpp:78
One entry in an enumeration.
Definition: enum_entry_node.hpp:21
CacheMode
Defines how the value is cached.
Definition: genapi.hpp:219
AccessMode
Access possibility of the node.
Definition: genapi.hpp:184