6#include "../../_cexports/c_gev_server.h"
8#include "../../exception.hpp"
9#include "../../global.hpp"
11#include "../_decl/decl_node.hpp"
12#include "../_decl/decl_node_map.hpp"
13#include "../boolean_node.hpp"
14#include "../category_node.hpp"
15#include "../command_node.hpp"
16#include "../enum_entry_node.hpp"
17#include "../enumeration_node.hpp"
18#include "../int_32_reg_node.hpp"
19#include "../int_64_reg_node.hpp"
20#include "../int_reg_node.hpp"
21#include "../float_reg_node.hpp"
22#include "../float_32_reg_node.hpp"
23#include "../float_64_reg_node.hpp"
24#include "../int_swiss_knife_node.hpp"
25#include "../integer_base_node.hpp"
26#include "../integer_node.hpp"
27#include "../float_base_node.hpp"
28#include "../float_node.hpp"
29#include "../string_reg_node.hpp"
30#include "../string_node.hpp"
31#include "../value_node.hpp"
40 CExports::GSNODE handle =
nullptr;
42 auto result = CExports::GSGetNodeTyped(nodeMap->Handle(), name.c_str(), handle);
46 HandleGuard<Node> guard(handle);
48 CExports::TGSNodeType nodeType = CExports::GSNT_Invalid;
49 result = CVB_CALL_CAPI(GSNType(guard.Handle(), nodeType));
56 case CExports::GSNT_Invalid:
59 case CExports::GSNT_Category:
63 case CExports::GSNT_IntReg:
65 CExports::cvbint64_t registerLength = 0;
67 CVB_CALL_CAPI(GSNGetInfoAsInteger(handle, CExports::TGSNodeInfo::GSNI_RegisterLength, registerLength));
71 switch (registerLength)
85 case CExports::GSNT_FloatReg:
87 CExports::cvbint64_t registerLength = 0;
89 CVB_CALL_CAPI(GSNGetInfoAsInteger(handle, CExports::TGSNodeInfo::GSNI_RegisterLength, registerLength));
93 switch (registerLength)
107 case CExports::GSNT_StringReg:
110 case CExports::GSNT_String:
113 case CExports::GSNT_Integer:
116 case CExports::GSNT_Float:
119 case CExports::GSNT_Boolean:
122 case CExports::GSNT_Command:
125 case CExports::GSNT_Enumeration:
128 case CExports::GSNT_EnumEntry:
131 case CExports::GSNT_IntSwissKnife:
140 node->SetNodeMap(nodeMap);
147 CExports::TGSNodeType nodeType = CExports::GSNT_Invalid;
148 auto resultType = CVB_CALL_CAPI(GSNType(guard.Handle(), nodeType));
155 case CExports::GSNT_Invalid:
157 case CExports::GSNT_Category:
160 case CExports::GSNT_IntReg:
164 CVB_CALL_CAPI(GSNGetInfoAsInteger(guard.Handle(), CExports::TGSNodeInfo::GSNI_RegisterLength, length));
182 case CExports::GSNT_FloatReg:
186 CVB_CALL_CAPI(GSNGetInfoAsInteger(guard.Handle(), CExports::TGSNodeInfo::GSNI_RegisterLength, length));
204 case CExports::GSNT_StringReg:
207 case CExports::GSNT_String:
210 case CExports::GSNT_Integer:
213 case CExports::GSNT_Float:
216 case CExports::GSNT_Boolean:
219 case CExports::GSNT_Command:
222 case CExports::GSNT_Enumeration:
225 case CExports::GSNT_EnumEntry:
228 case CExports::GSNT_IntSwissKnife:
236 node->SetNodeMap(nodeMap);
246 auto nodeMap = nodeMap_.lock();
251 bool enumWithInlineEntries =
false;
252 NodePtr nonInlineNode = nodeMap_.lock()->TryGetNode(item->NameOnly());
255 enumWithInlineEntries =
true;
257 if (!enumWithInlineEntries)
258 if (item->NodeMap() !=
NodeMapPtr() && nodeMap->Handle() != item->NodeMap()->Handle())
262 return CVB_CALL_CAPI(GSNAddNode(
Handle(),
static_cast<CExports::TGSNodeList
>(kind), item->Handle()));
266 if (enumWithInlineEntries)
267 item->SetNodeMap(nodeMap);
269 nodeMap->Nodes()[item->NameOnly()] = item;
277 auto nodeMap = nodeMap_.lock();
281 auto nodes_ = nodeMap->Nodes();
282 auto it = nodes_.find(item->NameOnly());
283 if (it != nodes_.end())
287 return CVB_CALL_CAPI(GSNRemoveNode(
Handle(),
static_cast<CExports::TGSNodeList
>(kind), item->Handle()));
326 auto nm = nodeMap_.lock();
332 return IsFeatureIter(root);
339 if (child && child.get() ==
this)
347 if (subCategory && subCategory.get() ==
this)
350 if (IsFeatureIter(subCategory))
388 NativeCall<CExports::cvbint64_t>([&](CExports::cvbint64_t &value) {
389 return CVB_CALL_CAPI(GSNSetInfoAsInteger(
Handle(),
static_cast<CExports::TGSNodeInfo
>(accessMode), value));
400 auto holder = Internal::CbCarrier<void(Node &)>::Create(handler);
401 return updatedCarrierContainer_.Register(holder);
406 updatedCarrierContainer_.Unregister(eventCookie);
412 std::size_t numNodes = GetDependentNodeCount(type);
418 auto bufferSizeResult =
419 CExports::GSNListExTyped(
Handle(),
static_cast<CExports::TGSNodeList
>(type), i,
reinterpret_cast<Char *
>(0),
420 bufferSize,
reinterpret_cast<Char *
>(0), keyBufferSize);
421 if (bufferSizeResult < 0)
424 bufferSize +=
sizeof(
Char);
426 keyBufferSize +=
sizeof(
Char);
429 CExports::cvbres_t bufferResult = 0;
430 bufferResult = CExports::GSNListExTyped(
Handle(),
static_cast<CExports::TGSNodeList
>(type), i,
431 reinterpret_cast<Char *
>(buffer.data()), bufferSize,
432 reinterpret_cast<Char *
>(keyBuffer.data()), keyBufferSize);
433 if (bufferResult < 0)
436 CExports::NODE hChild =
nullptr;
438 CExports::GSNGetNodeTyped(
Handle(),
static_cast<CExports::TGSNodeList
>(type), buffer.data(), hChild);
442 HandleGuard<class Node> guard(hChild);
443 String name(buffer.data());
445 if (nonInlineNode !=
nullptr && (guard.Handle() ==
nullptr || guard.Handle() == nonInlineNode->Handle()))
447 dependentNodes[i] = nonInlineNode;
455 return dependentNodes;
458 inline void Node::SetInfoAsString(
const NodeInfo &command,
const String &value)
461 return CExports::GSNSetInfoAsStringTyped(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command), value.c_str());
468 return CVB_CALL_CAPI(GSNSetInfoAsInteger(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command),
469 static_cast<CExports::cvbint64_t
>(value)));
473 inline double Node::GetInfoAsFloat(
const NodeInfo &command)
const
475 return NativeCall<double>([&](
double &value) {
476 return CVB_CALL_CAPI(GSNGetInfoAsFloat(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command), value));
480 inline void Node::SetInfoAsFloat(
const NodeInfo &command,
const double &value)
483 return CVB_CALL_CAPI(GSNSetInfoAsFloat(
Handle(),
static_cast<CExports::TGSNodeInfo
>(command), value));
487 template <
class NodeT>
488 inline void Node::SetInfo(
const NodeInfo &info,
const NodeT &valueNode)
490 if (valueNode == NodeT())
491 throw std::runtime_error(
"node to set must not be empty");
494 return CVB_CALL_CAPI(GSNSetInfoAsNode(
Handle(),
static_cast<CExports::TGSNodeInfo
>(info), valueNode->Handle()));
498 inline void Node::SetInfo(
const NodeInfo &info,
const String &value)
501 throw std::runtime_error(
"value to set must not be empty");
504 return CExports::GSNSetInfoAsStringTyped(
Handle(),
static_cast<CExports::TGSNodeInfo
>(info), value.data());
508 template <
class NodeT>
509 inline std::shared_ptr<NodeT> Node::GetInfoAs(
const NodeInfo &info)
const
511 CExports::GSNODE handle =
nullptr;
513 return CVB_CALL_CAPI(GSNGetInfoAsNode(
Handle(),
static_cast<CExports::TGSNodeInfo
>(info), handle));
516 if (handle ==
nullptr)
519 HandleGuard<Node> guard(handle);
521 std::shared_ptr<NodeT> tmpNode;
522 tmpNode = std::make_shared<NodeT>(std::move(guard));
524 return nodeMap_.lock()->Node<NodeT>(tmpNode->NameOnly());
707 template <
class NodeT,
class ValueConfigNodeType>
711 auto hasValueConfig =
dynamic_cast<Private::IHasValueConfig<ValueConfigNodeType> *
>(
712 const_cast<NodeT *
>(node));
715 auto otherNode = hasValueConfig->ValueConfigAsNode();
717 if (f(
dynamic_cast<Node *
>(otherNode.get())))
721 auto valNode =
dynamic_cast<ValueNode *
>(otherNode.get());
Cookie used to unregister event handlers.
Definition global.hpp:591
Node that logically groups other nodes.
Definition category_node.hpp:19
void SetValueConfig(const T &)
Sets the value configuration of this boolean node.
Definition boolean_node.hpp:223
T ValueConfig() const
Gets the value configuration of this boolean node.
Definition boolean_node.hpp:201
Node that logically groups other nodes.
Definition category_node.hpp:16
void SetValueConfig(const T &)
Sets the value configuration of this command node.
Definition command_node.hpp:238
T ValueConfig() const
Gets and sets the value configuration of this command node.
Definition command_node.hpp:217
void SetCommandConfig(const T &)
Sets the command value configuration of this command node.
Definition command_node.hpp:196
void SetValueConfig(const T &)
Sets the value configuration of this enumeration node.
Definition enumeration_node.hpp:163
T ValueConfig() const
Gets the value configuration of this enumeration node.
Definition enumeration_node.hpp:141
void SetMinConfig(const T &)
Sets the minimum configuration of this float node.
Definition float_node.hpp:217
void SetMaxConfig(const T &)
Sets the maximum configuration of this float node.
Definition float_node.hpp:181
T MaxConfig() const
Gets the maximum configuration of this float node.
Definition float_node.hpp:161
void SetIncrementConfig(const T &)
Sets the increment of this value.
Definition float_node.hpp:99
void SetValueConfig(const T &)
Sets the value configuration of this float node.
Definition float_node.hpp:329
T MinConfig() const
Gets the minimum configuration of this float node.
Definition float_node.hpp:197
T ValueConfig() const
Gets the value configuration of this float node.
Definition float_node.hpp:308
T IncrementConfig() const
Gets and sets the increment configuration of this float node.
Definition float_node.hpp:81
void SetMinConfig(const T &)
Sets the minimum configuration of this integer node.
Definition integer_node.hpp:215
void SetMaxConfig(const T &)
Sets the maximum configuration of this integer node.
Definition integer_node.hpp:179
T MaxConfig() const
Gets the maximum configuration of this integer node.
Definition integer_node.hpp:159
void SetIncrementConfig(const T &)
Sets the increment of this value.
Definition integer_node.hpp:97
void SetValueConfig(const T &)
Sets the value configuration of this integer node.
Definition integer_node.hpp:255
T MinConfig() const
Gets the minimum configuration of this integer node.
Definition integer_node.hpp:195
T ValueConfig() const
Gets the value configuration of this integer node.
Definition integer_node.hpp:234
T IncrementConfig() const
Gets and sets the increment configuration of this integer node.
Definition integer_node.hpp:81
Basic GevServer node for device feature access.
Definition decl_node.hpp:34
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
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
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
virtual Cvb::GenApi::CacheMode CacheMode() const
Gets the cache mode of this node.
Definition detail_node.hpp:393
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 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 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 Remove(const NodePtr &item, const NodeList &kind)
Remove a single Node item from this collection.
Definition detail_node.hpp:272
virtual GenApi::AccessMode AccessMode() const
Gets the GenApi::AccessMode of this node.
Definition detail_node.hpp:372
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
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
void SetValueConfig(const T &)
Sets the value configuration of this string node.
Definition string_node.hpp:149
T ValueConfig() const
Gets the value configuration of this string node.
Definition string_node.hpp:128
Base class for all nodes that have a value.
Definition value_node.hpp:21
CacheMode
Defines how the value is cached.
Definition genapi.hpp:223
AccessMode
Access possibility of the node.
Definition genapi.hpp:188
@ NotImplemented
Definition genapi.hpp:196
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
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< StringNode > StringNodePtr
Convenience shared pointer for StringNode.
Definition gevserver.hpp:57
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
@ AccessMode
Gets the access mode of the node.
Definition gevserver.hpp:203
@ ImposedAccessMode
Definition gevserver.hpp:224
@ IsAvailable
Accesses the IInteger node defining whether the node is available.
Definition gevserver.hpp:228
@ CachingMode
Gets the caching mode.
Definition gevserver.hpp:209
@ OnValue
Definition gevserver.hpp:220
@ Value
Accesses the value configuration.
Definition gevserver.hpp:219
@ Max
Gets the maximum value.
Definition gevserver.hpp:204
@ Increment
Gets the increment.
Definition gevserver.hpp:206
@ Min
Gets the minimum value.
Definition gevserver.hpp:205
@ IsLocked
Accesses the IInteger node defining whether the node is read only.
Definition gevserver.hpp:229
@ IsImplemented
Access the IInteger node defining whether the node is implemented.
Definition gevserver.hpp:226
@ Alias
Accesses the alias node of this node.
Definition gevserver.hpp:230
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
@ Enumeration
Node is an enumeration node (no reg).
Definition gevserver.hpp:181
std::shared_ptr< FloatBaseNode > FloatBaseNodePtr
Convenience shared pointer for FloatBaseNode.
Definition gevserver.hpp:77
NodeList
Node access.
Definition gevserver.hpp:258
@ Child
Definition gevserver.hpp:259
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
T dynamic_pointer_cast(T... args)
T rethrow_exception(T... args)