6#include "../_cexports/c_gev_server.h"
8#include "../global.hpp"
10#include "_decl/decl_node.hpp"
47 CVB_CALL_CAPI(GSNUnregisterEvent(
Handle(), CExports::TGSNodeEvent::GSNE_Read, readCallbackID_));
50 CVB_CALL_CAPI(GSNUnregisterEvent(
Handle(), CExports::TGSNodeEvent::GSNE_Write, writeCallbackID_));
69 return CVB_CALL_CAPI(GSNSetInfoAsInteger(
Handle(), CExports::TGSNodeInfo::GSNI_Streamable, (value ? 1 : 0)));
96 auto bufferSize = NativeCall<size_t>(
97 [&](
size_t &size) {
return CExports::GSNGetAsStringTyped(
Handle(),
reinterpret_cast<Char *
>(0), size); });
98 bufferSize +=
sizeof(
Char);
100 NativeCall([&]() {
return CExports::GSNGetAsStringTyped(
Handle(), buffer.data(), bufferSize); });
101 return buffer.data();
111 NativeCall([&]() {
return CExports::GSNSetAsStringTyped(
Handle(), value.data()); });
122 auto holder = Internal::CbCarrier<void(
ValueNode &)>::Create(handler);
123 return updatedCarrierContainerWritten_.Register(holder);
133 updatedCarrierContainerWritten_.Unregister(eventCookie);
144 auto holder = Internal::CbCarrier<void(
ValueNode &)>::Create(handler);
145 return updatedCarrierContainerOnRead_.Register(holder);
155 updatedCarrierContainerOnRead_.Unregister(eventCookie);
159 explicit ValueNode(HandleGuard<Node> &&guard) :
Node(std::move(guard))
167 int resultRegister = CVB_CALL_CAPI(GSNRegisterEventWithStatus(
168 Handle(), CExports::TGSNodeEvent::GSNE_Read, &ValueNode::EventOnReadCallback,
this, readCallbackID_));
169 if (resultRegister < 0)
170 std::rethrow_exception(CvbException::FromCvbResult(resultRegister,
"failed to register updated handler"));
172 resultRegister = CVB_CALL_CAPI(GSNRegisterEventWithStatus(
173 Handle(), CExports::TGSNodeEvent::GSNE_Write, &ValueNode::EventWrittenCallback,
this, writeCallbackID_));
174 if (resultRegister < 0)
175 std::rethrow_exception(CvbException::FromCvbResult(resultRegister,
"failed to register updated handler"));
181 static void __stdcall EventWrittenCallback(CExports::cvbres_t &status,
void *pPrivate)
183 if (status == ReplyStatus::Success)
187 auto node =
reinterpret_cast<ValueNode *
>(pPrivate);
188 node->updatedCarrierContainerWritten_.Call<void(ValueNode &)>(*node);
196 case ReplyStatus::Success:
199 case ReplyStatus::AccessDenied:
202 case ReplyStatus::Busy:
205 case ReplyStatus::NotImplemented:
208 case ReplyStatus::DataOverrun:
211 case ReplyStatus::InvalidParameter:
214 case ReplyStatus::WrongConfig:
218 case ReplyStatus::LocalProblem:
224 static void __stdcall EventOnReadCallback(CExports::cvbres_t &status,
void *pPrivate)
226 if (status == ReplyStatus::Success)
230 auto node =
reinterpret_cast<ValueNode *
>(pPrivate);
231 node->updatedCarrierContainerOnRead_.Call<void(ValueNode &)>(*node);
240 case ReplyStatus::Success:
243 case ReplyStatus::AccessDenied:
246 case ReplyStatus::Busy:
249 case ReplyStatus::NotImplemented:
252 case ReplyStatus::DataOverrun:
255 case ReplyStatus::InvalidParameter:
258 case ReplyStatus::WrongConfig:
262 case ReplyStatus::LocalProblem:
268 Internal::CarrierContainer updatedCarrierContainerWritten_;
269 Internal::CarrierContainer updatedCarrierContainerOnRead_;
Cookie used to unregister event handlers.
Definition: global.hpp:566
Basic GevServer node for device feature access.
Definition: decl_node.hpp:36
static GevServer::NodeType NodeType(void *handle)
Gets the node type from the nodes native handle.
Definition: decl_node.hpp:614
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
virtual String ToString() const
Returns this node's value as a string representation.
Definition: value_node.hpp:94
void UnregisterEventOnReadUpdated(EventCookie eventCookie) noexcept
Manually unregister a listener to the node on read event.
Definition: value_node.hpp:153
EventCookie RegisterEventOnReadUpdated(std::function< void(ValueNode &)> handler)
Register a listener to node on read event.
Definition: value_node.hpp:142
virtual void SetIsStreamable(const std::int64_t &value)
Sets whether this node should be used when the camera settings are stored.
Definition: value_node.hpp:66
virtual void FromString(const String &value)
Sets this node's value from the string value.
Definition: value_node.hpp:109
virtual bool IsStreamable() const
Gets whether this node should be used when the camera settings are stored.
Definition: value_node.hpp:59
void UnregisterEventWrittenUpdated(EventCookie eventCookie) noexcept
Manually unregister a listener to the node written event.
Definition: value_node.hpp:131
EventCookie RegisterEventWrittenUpdated(std::function< void(ValueNode &)> handler)
Register a listener to node written event.
Definition: value_node.hpp:120
std::chrono::duration< Rep, Period > PollingTime() const
Gets the polling time of this value.
Definition: value_node.hpp:80
const int CVB_BUSY
Hardware busy.
Definition: exception.hpp:58
const int CVB_ERROR
Generic unspecified error.
Definition: exception.hpp:24
const int CVB_NOTENOUGHDATA
Too few data available for a calculation.
Definition: exception.hpp:66
const int CVB_OK
No error occurred.
Definition: exception.hpp:22
const int CVB_PARAMETER
Parameter error.
Definition: exception.hpp:26
const int CVB_ACCESS
Access error.
Definition: exception.hpp:112
const int CVB_NOTSUPPORTED
A certain feature is not supported.
Definition: exception.hpp:60
const int CVB_OVERFLOW
Input value was too big or did lead to a too big result.
Definition: exception.hpp:108
@ PollingTime
Gets the polling time in ms.
@ Streamable
Information on the streamability of the node.
@ Category
Node is a category node.
@ EnumEntry
Node is an enumeration entry node (no reg).
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