8#include "../../global.hpp"
9#include "../../exception.hpp"
10#include "../../string.hpp"
11#include "../../utilities/system_info.hpp"
13#include "../genapi.hpp"
21 inline HandleGuard<GenApi::Node>::HandleGuard(
void *handle) noexcept
22 : HandleGuard<GenApi::Node>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
41 using GuardType = HandleGuard<Node>;
55 Node(
const Node &other) =
delete;
56 Node &operator=(
const Node &other) =
delete;
57 Node(Node &&other) =
delete;
58 Node &&operator=(Node &&other) =
delete;
62 if (nativeUpdateRegistered_)
63 CExports::NDeregisterUpdate(
Handle(), cbID_);
75 return handle_.Handle();
88 return GetInfoAsString(NodeInfo::Name);
100 return GetInfoAsString(NodeInfo::DisplayName);
110 return GetInfoAsString(NodeInfo::ToolTip);
122 return GetInfoAsString(NodeInfo::Description);
197 return GetInfoAsString(NodeInfo::EventID);
211 return GetInfoAsBool(NodeInfo::Feature);
224 return GetInfoAsBool(NodeInfo::Deprecated);
273 void NativeCall(
std::function<CExports::cvbres_t()> fn)
const
277 Utilities::SystemInfo::ThrowLastError(result);
281 T NativeCall(
std::function<CExports::cvbres_t(T &value)> fn)
const
284 auto result = fn(value);
286 Utilities::SystemInfo::ThrowLastError(result);
290 bool GetInfoAsBool(NodeInfo command)
const
292 return (NativeCall<CExports::cvbbool_t>([&](CExports::cvbbool_t &value) {
293 return CExports::NInfoAsBoolean(
Handle(),
static_cast<CExports::TNodeInfo
>(command), value);
299 std::int64_t GetInfoAsInt(NodeInfo command)
const
301 return static_cast<std::int64_t
>(NativeCall<CExports::cvbint64_t>([&](CExports::cvbint64_t &value) {
302 return CExports::NInfoAsInteger(
Handle(),
static_cast<CExports::TNodeInfo
>(command), value);
306 String GetInfoAsString(NodeInfo command)
const
308 return NativeCall<String>([&](
String &value) {
309 std::size_t bufferSize = 0;
310 auto bufferSizeResult = CExports::NInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeInfo
>(command),
311 reinterpret_cast<Char *
>(0), bufferSize);
312 if (bufferSizeResult < 0)
313 return bufferSizeResult;
315 std::vector<Char> buffer(bufferSize);
316 auto bufferResult = CExports::NInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeInfo
>(command),
317 buffer.data(), bufferSize);
318 if (bufferResult < 0)
321 value =
String(buffer.data());
326 int GetDependentNodeCount(NodeList type)
const
328 CExports::cvbdim_t numNodes = 0;
329 auto result = CExports::NListCount(
Handle(),
static_cast<CExports::TNodeList
>(type), numNodes);
331 std::rethrow_exception(CvbException::FromCvbResult(result,
"failed calling NListCount"));
337 std::vector<std::shared_ptr<T>> GetDependentNodes(NodeList type)
const;
339 explicit Node(HandleGuard<Node> &&guard) noexcept
340 : handle_(std::move(guard))
345 friend class NodeMap;
349 static void __stdcall UpdatedCallback(CExports::NODE,
void *pPrivate)
353 auto node =
reinterpret_cast<Node *
>(pPrivate);
354 node->updatedCarrierContainer_.Call<void(Node &)>(*node);
362 bool IsRegisterNode() const noexcept
364 CExports::cvbint64_t value = 0;
365 return CExports::NInfoAsInteger(
Handle(),
static_cast<CExports::TNodeInfo
>(NodeInfo::RegisterLength), value)
370 HandleGuard<Node> handle_;
374 Internal::CarrierContainer updatedCarrierContainer_;
376 std::mutex nativeUpdateRegistrationMutex_;
378 void *cbID_ =
nullptr;
380 bool nativeUpdateRegistered_ =
false;
Cookie used to unregister event handlers.
Definition global.hpp:591
Basic GenApi node for device feature access.
Definition decl_node.hpp:39
String DisplayName() const
Gets the display name of this node.
Definition decl_node.hpp:98
Cvb::GenApi::Visibility Visibility() const
Gets the complexity level of this node.
Definition decl_node.hpp:232
EventCookie RegisterEventUpdated(std::function< void(Node &)> handler)
Register a listener to node updated event.
Definition detail_node.hpp:133
bool IsFeature() const
Returns whether this node is considered a feature node.
Definition decl_node.hpp:209
bool IsWriteable() const
Helper to check whether this node is writable.
Definition decl_node.hpp:171
bool IsReadable() const
Helper to check whether this node is readable.
Definition decl_node.hpp:161
Cvb::GenApi::CacheMode CacheMode() const
Gets the cache mode of this node.
Definition decl_node.hpp:184
bool IsImplemented() const
Helper to check whether this node is implemented.
Definition decl_node.hpp:140
Cvb::GenApi::AccessMode AccessMode() const
Gets the access mode of this node.
Definition decl_node.hpp:130
String EventID() const
Nodes with an event identifier may become invalidated, if an event / message is delivered from the de...
Definition decl_node.hpp:195
NodeMapPtr NodeMap() const noexcept
Gets the node map this node resides in.
Definition decl_node.hpp:267
String Name() const
Gets the full name of this node.
Definition decl_node.hpp:86
bool IsAvailable() const
Helper to check whether this node is available.
Definition decl_node.hpp:150
bool IsDeprecated() const
Gets whether this node is considered deprecated.
Definition decl_node.hpp:222
String Description() const
Gets the long descriptive text of this node.
Definition decl_node.hpp:120
void UnregisterEventUpdated(EventCookie eventCookie) noexcept
Manually unregister a listener to the node updated event.
Definition detail_node.hpp:153
NodePtr AliasNode() const
Gets the node, that is an alias value for this node.
Definition detail_node.hpp:124
void * Handle() const noexcept
Classic API node handle.
Definition decl_node.hpp:73
String ToolTip() const
Gets the short descriptive text of this node.
Definition decl_node.hpp:108
cvbbool_t ReleaseObject(OBJ &Object)
const int CVB_WRONGOBJECT
Wrong object.
Definition exception.hpp:79
Namespace for GenApi based device configuration.
Definition decl_fw_updater.hpp:29
std::shared_ptr< Node > NodePtr
Convenience shared pointer for Node.
Definition genapi.hpp:71
Visibility
Feature complexity level.
Definition genapi.hpp:238
CacheMode
Defines how the value is cached.
Definition genapi.hpp:223
std::shared_ptr< NodeMap > NodeMapPtr
Convenience shared pointer for NodeMap.
Definition genapi.hpp:27
AccessMode
Access possibility of the node.
Definition genapi.hpp:188
@ ReadOnly
Node can only be read.
Definition genapi.hpp:214
@ NotAvailable
Definition genapi.hpp:202
@ WriteOnly
Node can only be written to.
Definition genapi.hpp:216
@ ReadWrite
Node can be read and written to.
Definition genapi.hpp:218
@ NotImplemented
Definition genapi.hpp:196
Root namespace for the Image Manager interface.
Definition version.hpp:11
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