CVB++ 15.0
value_node.hpp
1#pragma once
2
3#include <vector>
4
5#include "../_cexports/c_gen_api.h"
6
7#include "../global.hpp"
8
9#include "_decl/decl_node.hpp"
10
11namespace Cvb
12{
13
14 CVB_BEGIN_INLINE_NS
15
16 namespace GenApi
17 {
18
20
22 class ValueNode : public Node
23 {
24 public:
26
33 {
34 NativeCall([&]() { return CExports::NInvalidate(Handle()); });
35 }
36
38
42 bool IsStreamable() const
43 {
44 return GetInfoAsBool(NodeInfo::Streamable);
45 }
46
48
52 virtual String ToString() const
53 {
54 auto bufferSize = NativeCall<size_t>(
55 [&](size_t &size) { return CExports::NGetAsStringTyped(Handle(), reinterpret_cast<Char *>(0), size); });
56 bufferSize += sizeof(Char);
57 std::vector<Char> buffer(bufferSize);
58 NativeCall([&]() { return CExports::NGetAsStringTyped(Handle(), &buffer[0], bufferSize); });
59 return String(&buffer[0]);
60 }
61
63
67 virtual void FromString(const String &value)
68 {
69 NativeCall([&]() { return CExports::NSetAsStringTyped(Handle(), value.c_str()); });
70 }
71
73
78 {
79 return NativeCall<ReadWriteVerify>([&](ReadWriteVerify &value) {
80 return CExports::NGetVerifyMode(Handle(), reinterpret_cast<CExports::TVerifyMode &>(value));
81 });
82 }
83
85
89 void SetVerifyMode(ReadWriteVerify readWriteVerify)
90 {
91 NativeCall(
92 [&]() { return CExports::NSetVerifyMode(Handle(), static_cast<CExports::TVerifyMode>(readWriteVerify)); });
93 }
94
96
103 {
104 auto timeMs = GetInfoAsInt(NodeInfo::PollingTime);
105 if (timeMs > 0)
106 return std::chrono::milliseconds(timeMs);
107 else
109 }
110
111 protected:
112 explicit ValueNode(HandleGuard<Node> &&guard) noexcept
113 : Node(std::move(guard))
114 {
115 }
116 };
117
118 } // namespace GenApi
119
120 using GenApi::ValueNode;
121
122 CVB_END_INLINE_NS
123
124} // namespace Cvb
Basic GenApi node for device feature access.
Definition decl_node.hpp:38
void * Handle() const noexcept
Classic API node handle.
Definition decl_node.hpp:71
Base class for all nodes, that have a value.
Definition value_node.hpp:23
virtual String ToString() const
Returns this node's value as a string representation.
Definition value_node.hpp:52
bool IsStreamable() const
Returns whether this node should be used when saving camera settings.
Definition value_node.hpp:42
void SetVerifyMode(ReadWriteVerify readWriteVerify)
Sets how values are verified in this node.
Definition value_node.hpp:89
ReadWriteVerify VerifyMode() const
Returns how the values in this node are verified.
Definition value_node.hpp:77
std::chrono::milliseconds PollingTime() const
Gets the polling time of this value.
Definition value_node.hpp:102
virtual void FromString(const String &value)
Sets the value of this node from the string value.
Definition value_node.hpp:67
void Invalidate()
Invalidates the values of this node.
Definition value_node.hpp:32
T move(T... args)
Namespace for GenApi based device configuration.
Definition decl_fw_updater.hpp:29
ReadWriteVerify
Controls how read/write operations are verified by the GenApi.
Definition genapi.hpp:172
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49