15#include <peak/dll_interface/peak_dll_interface_util.hpp>
16#include <peak/generic/peak_t_callback_manager.hpp>
116struct NodeChangedCallbackContainer;
127class Node :
public std::enable_shared_from_this<Node>
131 using ChangedCallback = std::function<void(
const std::shared_ptr<Node>& changedNode)>;
151 std::string
Name()
const;
413 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
478 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
535 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
538 auto castedNode = std::dynamic_pointer_cast<NodeType>(
FindSelectedNode(name));
587 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
644 struct NodeChangedCallbackContainer
646 std::shared_ptr<Node> _Node;
651 friend ClassCreator<Node>;
654 std::weak_ptr<NodeMap> m_parentNodeMap;
656 std::unique_ptr<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>
657 m_changedCallbackManager;
662 return QueryStringFromCInterfaceFunction([&](
char* nodeName,
size_t* nodeNameSize) {
683 std::string entryString;
687 entryString =
"NotImplemented";
691 entryString =
"NotAvailable";
695 entryString =
"WriteOnly";
699 entryString =
"ReadOnly";
703 entryString =
"ReadWrite";
711 std::string entryString;
715 entryString =
"NoCache";
719 entryString =
"WriteThrough";
723 entryString =
"WriteAround";
731 std::string entryString;
735 entryString =
"Custom";
739 entryString =
"Standard";
747 std::string entryString;
751 entryString =
"Integer";
755 entryString =
"Boolean";
759 entryString =
"Command";
763 entryString =
"Float";
767 entryString =
"String";
771 entryString =
"Register";
775 entryString =
"Category";
779 entryString =
"Enumeration";
783 entryString =
"EnumerationEntry";
791 std::string entryString;
795 entryString =
"Beginner";
799 entryString =
"Expert";
803 entryString =
"Guru";
807 entryString =
"Invisible";
815 : m_backendHandle(nodeHandle)
816 , m_parentNodeMap(parentNodeMap)
817 , m_changedCallbackManager()
819 m_changedCallbackManager =
820 std::make_unique<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>(
821 [&](
void* callbackContext) {
822 return QueryNumericFromCInterfaceFunction<PEAK_NODE_CHANGED_CALLBACK_HANDLE>(
825 m_backendHandle, ChangedCallbackCWrapper, callbackContext, nodeChangedCallbackHandle);
829 CallAndCheckCInterfaceFunction([&] {
838 m_changedCallbackManager->UnregisterAllCallbacks();
848 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
856 QueryNumericFromCInterfaceFunction<PEAK_NODE_NAMESPACE>([&](
PEAK_NODE_NAMESPACE* _namespace) {
864 QueryNumericFromCInterfaceFunction<PEAK_NODE_VISIBILITY>([&](
PEAK_NODE_VISIBILITY* visibility) {
905 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isCacheable) {
912 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessStatusCacheable) {
919 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isStreamable) {
926 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isDeprecated) {
933 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isFeature) {
948 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* pollingTime_ms) {
955 return QueryStringFromCInterfaceFunction([&](
char* toolTip,
size_t* toolTipSize) {
962 return QueryStringFromCInterfaceFunction([&](
char* description,
size_t* descriptionSize) {
969 return static_cast<NodeType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_TYPE>(
975 return LockOrThrow(m_parentNodeMap);
980 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
982 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
992 auto numInvalidatedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
996 std::vector<std::shared_ptr<Node>> invalidatedNodes;
997 for (
size_t x = 0; x < numInvalidatedNodes; ++x)
999 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1006 invalidatedNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1009 return invalidatedNodes;
1014 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1016 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1026 auto numInvalidatingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
1030 std::vector<std::shared_ptr<Node>> invalidatingNodes;
1031 for (
size_t x = 0; x < numInvalidatingNodes; ++x)
1033 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1040 invalidatingNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1043 return invalidatingNodes;
1048 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1050 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1060 auto numSelectedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectedNodes) {
1064 std::vector<std::shared_ptr<Node>> selectedNodes;
1065 for (
size_t x = 0; x < numSelectedNodes; ++x)
1067 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1074 selectedNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1077 return selectedNodes;
1082 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1084 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1094 auto numSelectingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectingNodes) {
1098 std::vector<std::shared_ptr<Node>> selectingNodes;
1099 for (
size_t x = 0; x < numSelectingNodes; ++x)
1101 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1108 selectingNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1111 return selectingNodes;
1117 m_changedCallbackManager->RegisterCallback(NodeChangedCallbackContainer{ shared_from_this(), callback }));
1122 m_changedCallbackManager->UnregisterCallback(
1128 auto callbackContainer =
static_cast<NodeChangedCallbackContainer*
>(context);
1130 callbackContainer->Callback(callbackContainer->_Node);
The exception thrown for trying to apply an invalid cast.
Definition peak_exception.hpp:142
Represents a GenAPI node map.
Definition peak_node_map.hpp:63
NodeType Type() const
Returns the type.
Definition peak_node.hpp:967
ChangedCallbackHandle RegisterChangedCallback(const ChangedCallback &callback)
Registers a callback for signaling a change to the node.
Definition peak_node.hpp:1114
std::shared_ptr< NodeType > FindSelectingNode(const std::string &name) const
Tries to find a selecting node with the given name and type.
Definition peak_node.hpp:588
std::function< void(const std::shared_ptr< Node > &changedNode)> ChangedCallback
Definition peak_node.hpp:131
bool IsFeature() const
Checks whether the node is a feature, i.e. it can be reached via category nodes from a category node ...
Definition peak_node.hpp:931
bool IsDeprecated() const
Checks whether the node is deprecated.
Definition peak_node.hpp:924
std::string ToolTip() const
Returns the tool tip.
Definition peak_node.hpp:953
std::vector< std::shared_ptr< Node > > SelectedNodes() const
Returns the selected nodes.
Definition peak_node.hpp:1058
std::string DisplayName() const
Returns the display name.
Definition peak_node.hpp:846
Node & operator=(const Node &other)=delete
NodeNamespace Namespace() const
Returns the namespace the node belongs to.
Definition peak_node.hpp:853
Node & operator=(Node &&other)=delete
bool IsWriteable() const
Returns whether the node is currently writeable.
Definition peak_node.hpp:883
std::shared_ptr< Node > FindSelectingNode(const std::string &name) const
Tries to find a selecting node with the given name.
Definition peak_node.hpp:1080
std::shared_ptr< NodeMap > ParentNodeMap() const
Returns the parent node map.
Definition peak_node.hpp:973
std::string Name() const
Returns the name.
Definition peak_node.hpp:841
int64_t PollingTime() const
Returns the polling time.
Definition peak_node.hpp:946
std::shared_ptr< Node > FindInvalidatingNode(const std::string &name) const
Tries to find an invalidating node with the given name.
Definition peak_node.hpp:1012
std::vector< std::shared_ptr< Node > > InvalidatingNodes() const
Returns the invalidating nodes.
Definition peak_node.hpp:1024
virtual ~Node()
Definition peak_node.hpp:836
NodeVisibility Visibility() const
Returns the visibility.
Definition peak_node.hpp:861
bool IsAccessStatusCacheable() const
Checks whether the node's access status is cacheable.
Definition peak_node.hpp:910
bool IsReadable() const
Returns whether the node is currently readable.
Definition peak_node.hpp:877
std::shared_ptr< Node > FindSelectedNode(const std::string &name) const
Tries to find a selected node with the given name.
Definition peak_node.hpp:1046
std::shared_ptr< NodeType > FindSelectedNode(const std::string &name) const
Tries to find a selected node with the given name and type.
Definition peak_node.hpp:536
std::vector< std::shared_ptr< Node > > InvalidatedNodes() const
Returns the invalidated nodes.
Definition peak_node.hpp:990
std::vector< std::shared_ptr< Node > > SelectingNodes() const
Returns the selecting nodes.
Definition peak_node.hpp:1092
std::shared_ptr< NodeType > FindInvalidatedNode(const std::string &name) const
Tries to find an invalidated node with the given name and type.
Definition peak_node.hpp:414
std::shared_ptr< NodeType > FindInvalidatingNode(const std::string &name) const
Tries to find an invalidating node with the given name and type.
Definition peak_node.hpp:479
bool IsCacheable() const
Checks whether the node is cacheable.
Definition peak_node.hpp:903
std::string Description() const
Returns the description.
Definition peak_node.hpp:960
bool IsStreamable() const
Checks whether the node is streamable.
Definition peak_node.hpp:917
Node(Node &&other)=delete
bool IsImplemented() const
Returns whether the node is implemented.
Definition peak_node.hpp:895
bool IsAvailable() const
Returns whether the node is currently either readable or writeable.
Definition peak_node.hpp:889
NodeCachingMode CachingMode() const
Returns the caching mode.
Definition peak_node.hpp:938
std::shared_ptr< Node > FindInvalidatedNode(const std::string &name) const
Tries to find an invalidated node with the given name.
Definition peak_node.hpp:978
ChangedCallback * ChangedCallbackHandle
Definition peak_node.hpp:133
NodeAccessStatus AccessStatus() const
Returns the access status.
Definition peak_node.hpp:869
void UnregisterChangedCallback(ChangedCallbackHandle callbackHandle)
Unregisters a changed callback.
Definition peak_node.hpp:1120
Node(const Node &other)=delete
@ AccessStatus
Definition peak_device_descriptor.hpp:61
NodeVisibility
Definition peak_node.hpp:108
NodeType
Definition peak_node.hpp:91
NodeNamespace
Definition peak_node.hpp:81
NodeCachingMode
Definition peak_node.hpp:60
NodeAccessStatus
Definition peak_node.hpp:46
@ Expert
Definition peak_node.hpp:110
@ Beginner
Definition peak_node.hpp:109
@ Guru
Definition peak_node.hpp:111
@ Invisible
Definition peak_node.hpp:112
@ Register
Definition peak_node.hpp:97
@ Float
Definition peak_node.hpp:95
@ String
Definition peak_node.hpp:96
@ Boolean
Definition peak_node.hpp:93
@ Enumeration
Definition peak_node.hpp:99
@ Category
Definition peak_node.hpp:98
@ Integer
Definition peak_node.hpp:92
@ EnumerationEntry
Definition peak_node.hpp:100
@ Command
Definition peak_node.hpp:94
@ Custom
Definition peak_node.hpp:82
@ Standard
Definition peak_node.hpp:83
@ NoCache
Definition peak_node.hpp:64
@ WriteAround
Definition peak_node.hpp:72
@ WriteThrough
Definition peak_node.hpp:68
@ ReadOnly
Definition peak_node.hpp:50
@ NotAvailable
Definition peak_node.hpp:48
@ WriteOnly
Definition peak_node.hpp:49
@ ReadWrite
Definition peak_node.hpp:51
@ NotImplemented
Definition peak_node.hpp:47
@ Boolean
Definition peak_common_node_enums.hpp:63
The "nodes" namespace contains all GenAPI node types.
Definition peak_boolean_node.hpp:26
std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:70
std::string GetNodeName(PEAK_NODE_HANDLE nodeHandle)
Definition peak_node.hpp:660
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:35
PEAK_C_API PEAK_Node_GetIsFeature(PEAK_NODE_HANDLE nodeHandle, PEAK_BOOL8 *isFeature)
Asks the given node whether it is a feature, i.e. it can be reached via category nodes from a categor...
PEAK_C_API PEAK_Node_FindSelectedNode(PEAK_NODE_HANDLE nodeHandle, const char *name, size_t nameSize, PEAK_NODE_HANDLE *selectedNodeHandle)
Tells the given node to find a selected node with the given name.
PEAK_C_API PEAK_Node_GetToolTip(PEAK_NODE_HANDLE nodeHandle, char *toolTip, size_t *toolTipSize)
Asks the given node for its tooltip.
PEAK_C_API PEAK_Node_GetCachingMode(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_CACHING_MODE *cachingMode)
Asks the given node for its caching mode.
PEAK_NODE_CHANGED_CALLBACK * PEAK_NODE_CHANGED_CALLBACK_HANDLE
Definition peak_backend.h:582
PEAK_C_API PEAK_Node_GetNumSelectedNodes(PEAK_NODE_HANDLE nodeHandle, size_t *numSelectedNodes)
Asks the given node for its number of selected nodes.
PEAK_C_API PEAK_Node_FindSelectingNode(PEAK_NODE_HANDLE nodeHandle, const char *name, size_t nameSize, PEAK_NODE_HANDLE *selectingNodeHandle)
Tells the given node to find a selecting node with the given name.
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition peak_backend.h:429
PEAK_C_API PEAK_Node_GetInvalidatingNode(PEAK_NODE_HANDLE nodeHandle, size_t index, PEAK_NODE_HANDLE *invalidatingNodeHandle)
Asks the given node for the invalidating node with the given index.
PEAK_C_API PEAK_Node_GetNumSelectingNodes(PEAK_NODE_HANDLE nodeHandle, size_t *numSelectingNodes)
Asks the given node for its number of selecting nodes.
PEAK_C_API PEAK_Node_GetSelectingNode(PEAK_NODE_HANDLE nodeHandle, size_t index, PEAK_NODE_HANDLE *selectingNodeHandle)
Asks the given node for the selecting node with the given index.
PEAK_C_API PEAK_Node_GetType(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_TYPE *type)
Asks the given node for its type.
int32_t PEAK_NODE_ACCESS_STATUS
Definition peak_backend.h:225
int32_t PEAK_NODE_TYPE
Definition peak_backend.h:296
PEAK_C_API PEAK_Node_FindInvalidatedNode(PEAK_NODE_HANDLE nodeHandle, const char *name, size_t nameSize, PEAK_NODE_HANDLE *invalidatedNodeHandle)
Tells the given node to find an invalidated node with the given name.
PEAK_C_API PEAK_Node_FindInvalidatingNode(PEAK_NODE_HANDLE nodeHandle, const char *name, size_t nameSize, PEAK_NODE_HANDLE *invalidatingNodeHandle)
Tells the given node to find an invalidating node with the given name.
PEAK_C_API PEAK_Node_GetVisibility(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_VISIBILITY *visibility)
Asks the given node for its visibility.
PEAK_C_API PEAK_Node_RegisterChangedCallback(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_CHANGED_CALLBACK callback, void *callbackContext, PEAK_NODE_CHANGED_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling a change at the given node.
PEAK_C_API PEAK_Node_GetName(PEAK_NODE_HANDLE nodeHandle, char *name, size_t *nameSize)
Asks the given node for its name.
PEAK_C_API PEAK_Node_GetNamespace(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_NAMESPACE *_namespace)
Asks the given node for its namespace.
PEAK_C_API PEAK_Node_GetSelectedNode(PEAK_NODE_HANDLE nodeHandle, size_t index, PEAK_NODE_HANDLE *selectedNodeHandle)
Asks the given node for the selected node with the given index.
PEAK_C_API PEAK_Node_GetDescription(PEAK_NODE_HANDLE nodeHandle, char *description, size_t *descriptionSize)
Asks the given node for its description.
PEAK_C_API PEAK_Node_GetNumInvalidatingNodes(PEAK_NODE_HANDLE nodeHandle, size_t *numInvalidatingNodes)
Asks the given node for its number of invalidating nodes.
int8_t PEAK_BOOL8
Definition peak_backend.h:43
int32_t PEAK_NODE_CACHING_MODE
Definition peak_backend.h:234
PEAK_C_API PEAK_Node_GetNumInvalidatedNodes(PEAK_NODE_HANDLE nodeHandle, size_t *numInvalidatedNodes)
Asks the given node for its number of invalidated nodes.
PEAK_C_API PEAK_Node_GetIsDeprecated(PEAK_NODE_HANDLE nodeHandle, PEAK_BOOL8 *isDeprecated)
Asks the given node whether it is deprecated.
PEAK_C_API PEAK_Node_GetIsStreamable(PEAK_NODE_HANDLE nodeHandle, PEAK_BOOL8 *isStreamable)
Asks the given node whether it is streamable.
PEAK_C_API PEAK_Node_GetAccessStatus(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_ACCESS_STATUS *accessStatus)
Asks the given node for its access status.
PEAK_C_API PEAK_Node_GetIsCacheable(PEAK_NODE_HANDLE nodeHandle, PEAK_BOOL8 *isCacheable)
Asks the given node whether it is cacheable.
int32_t PEAK_NODE_NAMESPACE
Definition peak_backend.h:268
PEAK_C_API PEAK_Node_GetDisplayName(PEAK_NODE_HANDLE nodeHandle, char *displayName, size_t *displayNameSize)
Asks the given node for its display name.
PEAK_C_API PEAK_Node_GetPollingTime(PEAK_NODE_HANDLE nodeHandle, int64_t *pollingTime_ms)
Asks the given node for its polling time.
PEAK_C_API PEAK_Node_GetInvalidatedNode(PEAK_NODE_HANDLE nodeHandle, size_t index, PEAK_NODE_HANDLE *invalidatedNodeHandle)
Asks the given node for the invalidated node with the given index.
PEAK_C_API PEAK_Node_GetIsAccessStatusCacheable(PEAK_NODE_HANDLE nodeHandle, PEAK_BOOL8 *isAccessStatusCacheable)
Asks the given node whether its access status is cacheable.
int32_t PEAK_NODE_VISIBILITY
Definition peak_backend.h:306
PEAK_C_API PEAK_Node_UnregisterChangedCallback(PEAK_NODE_HANDLE nodeHandle, PEAK_NODE_CHANGED_CALLBACK_HANDLE callbackHandle)
Unregisters the changed callback with the given handle from the given node.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16
#define PEAK_CALL_CONV
Definition peak_dynamic_loader.h:30