CVB++ 14.0
category_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "value_node.hpp"
6
8#include "_detail/iconfigurable_category_node.hpp"
10
11namespace Cvb
12{
13CVB_BEGIN_INLINE_NS
14namespace GevServer
15{
17
20 : public ValueNode
22 , public Private::IConfigurableCategoryNode
24{
25public:
26 CategoryNode(HandleGuard<Node> &&guard) noexcept : ValueNode(std::move(guard)) {}
27
38 static CategoryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
39 {
40 CExports::GEVSRV handle = nullptr;
41 handle = CExports::CreateGSCategoryNodeTyped(name.data(), static_cast<CExports::TGSNamespace>(nameSpace));
42
43 HandleGuard<Node> guard(handle);
44 return std::make_shared<CategoryNode>(std::move(guard));
45 }
46
60 static CategoryNodePtr Create(const String &name) { return Create(ParseName(name), ParseNamespace(name)); }
61
63
67 void FromString(const String &value) override
68 {
69 (void)value;
70 throw std::runtime_error("not implemented");
71 }
72
78 String ToString() const override
79 {
80 auto bufferSize = NativeCall<size_t>([&](size_t &size) {
81 return CExports::GSNGetInfoAsStringTyped(
82 Handle(), CExports::TGSNodeInfo::GSNI_Alias, reinterpret_cast<Char *>(0), size);
83 });
84
85 bufferSize += sizeof(Char);
86 std::vector<Char> buffer(bufferSize);
87 NativeCall([&]() {
88 return CExports::GSNGetInfoAsStringTyped(
89 Handle(), CExports::TGSNodeInfo::GSNI_Alias, buffer.data(), bufferSize);
90 });
91
92 return buffer.data() ? String(buffer.data()) : String();
93 }
94
96
99 GenApi::AccessMode AccessMode() const noexcept override { return GenApi::AccessMode::ReadOnly; }
100
102
105 Cvb::GenApi::CacheMode CacheMode() const noexcept override { return GenApi::CacheMode::NoCache; }
106
108
112 template <class Rep, class Period> std::chrono::duration<Rep, Period> PollingTime() const noexcept
113 {
115 }
116
118 bool IsStreamable() const override { return false; }
119
120 [[noreturn]] void SetIsStreamable(const std::int64_t & /*value*/) override
121 {
122 throw std::runtime_error("Category nodes cannot be streamed");
123 }
124
126
130 std::vector<NodePtr> Nodes() const { return GetDependentNodes<Node>(NodeList::Child); }
131};
132}
133CVB_END_INLINE_NS
134}
Node that logically groups other nodes.
Definition: category_node.hpp:24
std::vector< NodePtr > Nodes() const
Gets the nodes categorized by this node.
Definition: category_node.hpp:130
static CategoryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new CategoryNode with the given name and nameSpace .
Definition: category_node.hpp:38
bool IsStreamable() const override
Categories are never streamable.
Definition: category_node.hpp:118
static CategoryNodePtr Create(const String &name)
Creates a new CategoryNode with the given name .
Definition: category_node.hpp:60
Cvb::GenApi::CacheMode CacheMode() const noexcept override
Nothing to cache here.
Definition: category_node.hpp:105
void FromString(const String &value) override
Not supported.
Definition: category_node.hpp:67
void SetIsStreamable(const std::int64_t &) override
Sets whether this node should be used when the camera settings are stored.
Definition: category_node.hpp:120
std::chrono::duration< Rep, Period > PollingTime() const noexcept
Nothing to poll.
Definition: category_node.hpp:112
GenApi::AccessMode AccessMode() const noexcept override
Categories are always read only.
Definition: category_node.hpp:99
String ToString() const override
Gets the value of the alias node, if any is present. Empty string otherwise.
Definition: category_node.hpp:78
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:585
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:607
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:101
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
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
char Char
Character type for wide characters or unicode characters.
Definition: string.hpp:59