9#include "../../exception.hpp"
10#include "../../global.hpp"
11#include "../../string.hpp"
12#include "../../utilities/system_info.hpp"
14#include "../_detail/ihas_value_config.hpp"
16#include "../../genapi/genapi.hpp"
17#include "../gevserver.hpp"
24 inline HandleGuard<GevServer::Node>::HandleGuard(
void *handle) noexcept
25 : HandleGuard<GevServer::Node>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
38 explicit Node(HandleGuard<Node> &&guard) noexcept
43 Node(
const Node &other) =
delete;
44 Node &operator=(
const Node &other) =
delete;
45 Node(Node &&other) =
delete;
46 Node &operator=(Node &&other) =
delete;
47 virtual ~Node() =
default;
65 template <
class T,
class... ARGS>
104 return handle_.Handle();
111 return nodeMap_.lock();
366 nsName = CVB_LIT(
"Cust::");
369 nsName = CVB_LIT(
"Priv::");
372 nsName = CVB_LIT(
"Std::");
411 CExports::cvbint64_t value{-1};
412 auto result = CVB_CALL_CAPI(GSNGetInfoAsInteger(
Handle(), CExports::TGSNodeInfo::GSNI_EventID, value));
413 if (result < 0 || value < 0)
491 template <
class NodeT,
class ValueConfigNodeType>
498 int result = CVB_CALL_CAPI(GSNListCount(
Handle(),
static_cast<CExports::TGSNodeList
>(type), numNodes));
516 auto res = CVB_CALL_CAPI(GSGetLastErrorString(
nullptr, messageSize));
517 if (!res || messageSize < 2)
520 if (!CVB_CALL_CAPI(GSGetLastErrorString(message.data(), messageSize)))
522 return std::string(message.data());
525 void NativeCall(std::function<CExports::cvbres_t()> fn)
const
529 Utilities::SystemInfo::ThrowLastError(result);
533 T NativeCall(std::function<CExports::cvbres_t(T &value)> fn)
const
536 auto result = fn(value);
538 Utilities::SystemInfo::ThrowLastError(result);
542 static void __stdcall UpdatedCallback(
void *pPrivate)
544 if (
auto pFunction =
reinterpret_cast<std::function<
int(
void)
> *>(pPrivate))
568 if (name.find(CVB_LIT(
"::")) != name.npos)
595 if (name.find(CVB_LIT(
"::")) == name.npos)
598 if (name.find(CVB_LIT(
"Std")) != name.npos)
600 else if (name.find(CVB_LIT(
"Priv")) != name.npos)
616 auto nameStart = name.find(CVB_LIT(
"::"));
617 if (nameStart == name.npos)
619 auto rname = name.substr(nameStart + 2, name.length());
623 bool IsRegisterNode() const noexcept
625 CExports::cvbint64_t value = 0;
626 return CVB_CALL_CAPI(GSNGetInfoAsInteger(
Handle(), CExports::TGSNodeInfo::GSNI_RegisterLength, value)) >= 0
630 template <
class NodeT>
640 CExports::TGSNodeType nodeType = CExports::GSNT_Invalid;
641 auto result = CVB_CALL_CAPI(GSNType(handle, nodeType));
649 auto bufferSize = NativeCall<size_t>([&](
size_t &size) {
650 return CExports::GSNGetInfoAsStringTyped(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command),
651 reinterpret_cast<Char *
>(0), size);
654 bufferSize +=
sizeof(
Char);
657 return CExports::GSNGetInfoAsStringTyped(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command), buffer.data(),
661 return buffer.data();
664 std::int64_t GetInfoAsInt(
const NodeInfo &command)
const
666 return static_cast<std::int64_t
>(NativeCall<CExports::cvbint64_t>([&](CExports::cvbint64_t &value) {
667 return CVB_CALL_CAPI(GSNGetInfoAsInteger(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command), value));
671 void SetInfoAsString(
const NodeInfo &command,
const String &value);
673 void SetInfoAsInt(
const NodeInfo &command,
const std::int64_t &value);
675 double GetInfoAsFloat(
const NodeInfo &command)
const;
677 void SetInfoAsFloat(
const NodeInfo &command,
const double &value);
679 template <
class NodeT>
680 void SetInfo(
const NodeInfo &info,
const NodeT &valueNode);
692 HandleGuard<Node> handle_;
693 std::weak_ptr<class NodeMap> nodeMap_;
695 std::size_t cbIDr_ = 0;
696 std::size_t cbIDw_ = 0;
698 Internal::CarrierContainer updatedCarrierContainer_;
703 class DefaultNode :
public Node
710 explicit DefaultNode(HandleGuard<Node> &&guard) noexcept
711 : Node(std::move(guard))
721 throw std::runtime_error(
"not implemented");
730 throw std::runtime_error(
"not implemented");
Cookie used to unregister event handlers.
Definition global.hpp:591
Basic GevServer node for device feature access.
Definition decl_node.hpp:34
String DisplayName() const
Gets the display name of this node.
Definition decl_node.hpp:455
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition decl_node.hpp:591
void SetToolTip(const String &value)
Sets the short descriptive text of this node.
Definition decl_node.hpp:129
void SetDisplayName(const String &value)
Sets the display name of this node.
Definition decl_node.hpp:467
Cvb::GenApi::Visibility Visibility() const
Gets the complexity level of this node.
Definition decl_node.hpp:310
EventCookie RegisterEventUpdated(std::function< void(Node &)> handler)
Register a listener to node updated event.
Definition detail_node.hpp:398
bool IsFeature() const
Gets whether this node is considered a feature node.
Definition detail_node.hpp:324
IntegerBaseNodePtr IsAvailableConfig() const
Gets the node that specifies whether a node is currently available or not.
Definition detail_node.hpp:304
void SetVisibility(const Cvb::GenApi::Visibility &value)
Gets the complexity level of this node.
Definition decl_node.hpp:319
bool IsReadable() const
Helper to check whether this node is readable.
Definition decl_node.hpp:254
IntegerBaseNodePtr IsImplementedConfig() const
Gets the node that specifies whether a node is implemented in the device or not.
Definition detail_node.hpp:294
IntegerBaseNodePtr IsLockedConfig() const
Gets the node that specifies whether a node is currently read only or not.
Definition detail_node.hpp:314
void SetImposedAccessMode(const Cvb::GenApi::AccessMode &accessMode)
Overrides the node's default AccessMode.
Definition detail_node.hpp:386
bool IsWritable() const
Helper to check whether this node is writable.
Definition decl_node.hpp:264
static std::shared_ptr< T > FromHandle(HandleGuard< Node > &&guard, ARGS &&...args)
Factory to create the appropriate Node object based on the given handle .
Definition decl_node.hpp:66
static NodePtr FromName(const NodeMapPtr &nodeMap, const String &name)
Factory to create the appropriate Node object on the given nodeMap based on the given name .
Definition detail_node.hpp:38
static String EnsureNodeNameOnly(const String &name)
Throws if the given name has a namespace prefix.
Definition decl_node.hpp:564
virtual Cvb::GenApi::CacheMode CacheMode() const
Gets the cache mode of this node.
Definition detail_node.hpp:393
bool IsImplemented() const
Helper to check whether this node is implemented.
Definition decl_node.hpp:186
void SetIsImplementedConfig(const IntegerBaseNodePtr &node)
Sets the node that specifies whether a node is implemented in the device or not.
Definition detail_node.hpp:299
void SetDescription(const String &value)
Sets the long descriptive text of this node.
Definition decl_node.hpp:155
void SetAliasNode(const NodePtr &value)
Sets the node that is an alias value for this node.
Definition detail_node.hpp:367
void SetIsLockedConfig(const IntegerBaseNodePtr &node)
Sets the node that specifies whether a node is currently read only or not.
Definition detail_node.hpp:319
String EventID() const
Nodes with an event identifier may become invalidated if an event/message is delivered from the devic...
Definition decl_node.hpp:409
String Name() const
Gets the full name of this node.
Definition decl_node.hpp:356
Cvb::GenApi::AccessMode ImposedAccessMode() const
Gets the node's default AccessMode.
Definition detail_node.hpp:377
bool IsAvailable() const
Helper to check whether this node is available.
Definition decl_node.hpp:217
static GevServer::NodeType NodeType(void *handle)
Gets the node type from the nodes native handle.
Definition decl_node.hpp:638
bool IsDeprecated() const
Gets whether this node is considered deprecated.
Definition decl_node.hpp:443
bool Remove(const NodePtr &item, const NodeList &kind)
Remove a single Node item from this collection.
Definition detail_node.hpp:272
String Description() const
Gets the long descriptive text of this node.
Definition decl_node.hpp:143
virtual GenApi::AccessMode AccessMode() const
Gets the GenApi::AccessMode of this node.
Definition detail_node.hpp:372
NodeMapPtr NodeMap() const
Gets the node map of this GevServer node.
Definition decl_node.hpp:109
GevServer::Namespace Namespace() const
Gets the namespace this node is in.
Definition decl_node.hpp:398
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition decl_node.hpp:611
void Add(const NodePtr &item, const NodeList &kind)
Adds a Node item .
Definition detail_node.hpp:241
ValueNodePtr GetTerminalRegisterNode(const NodeT *node, std::function< bool(Node *)> f) const
Try to get terminal register node.
Definition detail_node.hpp:708
void UnregisterEventUpdated(EventCookie eventCookie) noexcept
Manually unregister a listener to the node updated event.
Definition detail_node.hpp:404
String NameOnly() const
Gets the name of this node without namespace.
Definition detail_node.hpp:362
NodePtr AliasNode() const
Gets the node that is an alias value for this node.
Definition detail_node.hpp:357
void * Handle() const noexcept
Classic API node handle.
Definition decl_node.hpp:102
String ToolTip() const
Gets the short descriptive text of this node.
Definition decl_node.hpp:119
std::vector< std::shared_ptr< T > > GetDependentNodes(const NodeList &type) const
Gets the nodes categorized by this node.
Definition detail_node.hpp:410
void SetIsAvailableConfig(const IntegerBaseNodePtr &node)
Sets the node that specifies whether a node is currently available or not.
Definition detail_node.hpp:309
cvbbool_t ReleaseObject(OBJ &Object)
const int CVB_WRONGOBJECT
Wrong object.
Definition exception.hpp:79
Visibility
Feature complexity level.
Definition genapi.hpp:238
CacheMode
Defines how the value is cached.
Definition genapi.hpp:223
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
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
Namespace
The possible name spaces a node can be in.
Definition gevserver.hpp:156
@ Private
Private name space.
Definition gevserver.hpp:159
@ Custom
Custom name space.
Definition gevserver.hpp:158
@ Standard
Standard name space.
Definition gevserver.hpp:157
std::shared_ptr< Node > NodePtr
Convenience shared pointer for Node.
Definition gevserver.hpp:41
std::shared_ptr< IntegerBaseNode > IntegerBaseNodePtr
Convenience shared pointer for IntegerBaseNode.
Definition gevserver.hpp:73
std::shared_ptr< NodeMap > NodeMapPtr
Convenience shared pointer for NodeMap.
Definition gevserver.hpp:45
NodeInfo
Possible information a node can hold.
Definition gevserver.hpp:200
@ Visibility
Gets the visibility level.
Definition gevserver.hpp:212
@ DisplayName
Gets the display name of the node.
Definition gevserver.hpp:202
@ Name
Gets the full name of the node.
Definition gevserver.hpp:201
@ Description
Gets the long descriptive text.
Definition gevserver.hpp:211
@ NameSpace
Gets the node namespace.
Definition gevserver.hpp:215
@ ToolTip
Gets the tool tip (short description).
Definition gevserver.hpp:210
std::shared_ptr< ValueNode > ValueNodePtr
Convenience shared pointer for ValueNode.
Definition gevserver.hpp:53
std::shared_ptr< CategoryNode > CategoryNodePtr
Convenience shared pointer for CategoryNode.
Definition gevserver.hpp:69
NodeType
Available node types.
Definition gevserver.hpp:171
@ String
Node is a string node (no reg).
Definition gevserver.hpp:177
NodeList
Node access.
Definition gevserver.hpp:258
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::stringstream StringStream
String stream for wide characters or unicode characters.
Definition string.hpp:56
T rethrow_exception(T... args)