CVB++ 14.1
category_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "value_node.hpp"
6
7
8
9namespace Cvb
10{
11CVB_BEGIN_INLINE_NS
12namespace GevServer
13{
15
18 : public ValueNode
19{
20public:
21 explicit CategoryNode(HandleGuard<Node> &&guard) : ValueNode(std::move(guard)) {}
22
33 static CategoryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
34 {
35 CExports::GEVSRV handle = nullptr;
36 handle = CExports::CreateGSCategoryNodeTyped(name.data(), static_cast<CExports::TGSNamespace>(nameSpace));
37
38 HandleGuard<Node> guard(handle);
39 return std::make_shared<CategoryNode>(std::move(guard));
40 }
41
55 static CategoryNodePtr Create(const String &name) { return Create(ParseName(name), ParseNamespace(name)); }
56
58
62 void FromString(const String &value) override
63 {
64 (void)value;
65 throw std::runtime_error("not implemented");
66 }
67
73 String ToString() const override
74 {
75 auto bufferSize = NativeCall<size_t>([&](size_t &size) {
76 return CExports::GSNGetInfoAsStringTyped(
77 Handle(), CExports::TGSNodeInfo::GSNI_Alias, reinterpret_cast<Char *>(0), size);
78 });
79
80 bufferSize += sizeof(Char);
81 std::vector<Char> buffer(bufferSize);
82 NativeCall([&]() {
83 return CExports::GSNGetInfoAsStringTyped(
84 Handle(), CExports::TGSNodeInfo::GSNI_Alias, buffer.data(), bufferSize);
85 });
86
87 return buffer.data() ? String(buffer.data()) : String();
88 }
89
91
94 GenApi::AccessMode AccessMode() const noexcept override { return GenApi::AccessMode::ReadOnly; }
95
97
100 Cvb::GenApi::CacheMode CacheMode() const noexcept override { return GenApi::CacheMode::NoCache; }
101
103
107 template <class Rep, class Period> std::chrono::duration<Rep, Period> PollingTime() const noexcept
108 {
110 }
111
113 bool IsStreamable() const override { return false; }
114
115 [[noreturn]] void SetIsStreamable(const std::int64_t & /*value*/) override
116 {
117 throw std::runtime_error("Category nodes cannot be streamed");
118 }
119
121
125 std::vector<NodePtr> Nodes() const { return GetDependentNodes<Node>(NodeList::Child); }
126};
127}
128CVB_END_INLINE_NS
129}
Node that logically groups other nodes.
Definition: category_node.hpp:19
std::vector< NodePtr > Nodes() const
Gets the nodes categorized by this node.
Definition: category_node.hpp:125
static CategoryNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new CategoryNode with the given name and nameSpace .
Definition: category_node.hpp:33
bool IsStreamable() const override
Categories are never streamable.
Definition: category_node.hpp:113
static CategoryNodePtr Create(const String &name)
Creates a new CategoryNode with the given name .
Definition: category_node.hpp:55
Cvb::GenApi::CacheMode CacheMode() const noexcept override
Nothing to cache here.
Definition: category_node.hpp:100
void FromString(const String &value) override
Not supported.
Definition: category_node.hpp:62
void SetIsStreamable(const std::int64_t &) override
Sets whether this node should be used when the camera settings are stored.
Definition: category_node.hpp:115
std::chrono::duration< Rep, Period > PollingTime() const noexcept
Nothing to poll.
Definition: category_node.hpp:107
GenApi::AccessMode AccessMode() const noexcept override
Categories are always read only.
Definition: category_node.hpp:94
String ToString() const override
Gets the value of the alias node, if any is present. Empty string otherwise.
Definition: category_node.hpp:73
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:567
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:588
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:100
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
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:70