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;
397 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
449 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
501 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
504 auto castedNode = std::dynamic_pointer_cast<NodeType>(
FindSelectedNode(name));
553 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
610 struct NodeChangedCallbackContainer
612 std::shared_ptr<Node> _Node;
617 friend ClassCreator<Node>;
620 std::weak_ptr<NodeMap> m_parentNodeMap;
622 std::unique_ptr<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>
623 m_changedCallbackManager;
628 return QueryStringFromCInterfaceFunction([&](
char* nodeName,
size_t* nodeNameSize) {
649 std::string entryString;
653 entryString =
"NotImplemented";
657 entryString =
"NotAvailable";
661 entryString =
"WriteOnly";
665 entryString =
"ReadOnly";
669 entryString =
"ReadWrite";
677 std::string entryString;
681 entryString =
"NoCache";
685 entryString =
"WriteThrough";
689 entryString =
"WriteAround";
697 std::string entryString;
701 entryString =
"Custom";
705 entryString =
"Standard";
713 std::string entryString;
717 entryString =
"Integer";
721 entryString =
"Boolean";
725 entryString =
"Command";
729 entryString =
"Float";
733 entryString =
"String";
737 entryString =
"Register";
741 entryString =
"Category";
745 entryString =
"Enumeration";
749 entryString =
"EnumerationEntry";
757 std::string entryString;
761 entryString =
"Beginner";
765 entryString =
"Expert";
769 entryString =
"Guru";
773 entryString =
"Invisible";
781 : m_backendHandle(nodeHandle)
782 , m_parentNodeMap(parentNodeMap)
783 , m_changedCallbackManager()
785 m_changedCallbackManager =
786 std::make_unique<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>(
787 [&](
void* callbackContext) {
788 return QueryNumericFromCInterfaceFunction<PEAK_NODE_CHANGED_CALLBACK_HANDLE>(
791 m_backendHandle, ChangedCallbackCWrapper, callbackContext, nodeChangedCallbackHandle);
795 CallAndCheckCInterfaceFunction([&] {
804 m_changedCallbackManager->UnregisterAllCallbacks();
814 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
822 QueryNumericFromCInterfaceFunction<PEAK_NODE_NAMESPACE>([&](
PEAK_NODE_NAMESPACE* _namespace) {
830 QueryNumericFromCInterfaceFunction<PEAK_NODE_VISIBILITY>([&](
PEAK_NODE_VISIBILITY* visibility) {
871 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isCacheable) {
878 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessStatusCacheable) {
885 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isStreamable) {
892 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isDeprecated) {
899 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isFeature) {
914 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* pollingTime_ms) {
921 return QueryStringFromCInterfaceFunction([&](
char* toolTip,
size_t* toolTipSize) {
928 return QueryStringFromCInterfaceFunction([&](
char* description,
size_t* descriptionSize) {
935 return static_cast<NodeType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_TYPE>(
941 return LockOrThrow(m_parentNodeMap);
946 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
948 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
958 auto numInvalidatedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
962 std::vector<std::shared_ptr<Node>> invalidatedNodes;
963 for (
size_t x = 0; x < numInvalidatedNodes; ++x)
965 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
972 invalidatedNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
975 return invalidatedNodes;
980 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
982 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
992 auto numInvalidatingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
996 std::vector<std::shared_ptr<Node>> invalidatingNodes;
997 for (
size_t x = 0; x < numInvalidatingNodes; ++x)
999 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1006 invalidatingNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1009 return invalidatingNodes;
1014 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1016 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1026 auto numSelectedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectedNodes) {
1030 std::vector<std::shared_ptr<Node>> selectedNodes;
1031 for (
size_t x = 0; x < numSelectedNodes; ++x)
1033 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1040 selectedNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1043 return selectedNodes;
1048 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1050 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1060 auto numSelectingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectingNodes) {
1064 std::vector<std::shared_ptr<Node>> selectingNodes;
1065 for (
size_t x = 0; x < numSelectingNodes; ++x)
1067 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1074 selectingNodes.emplace_back(
ParentNodeMap()->FindNode(nodeName));
1077 return selectingNodes;
1083 m_changedCallbackManager->RegisterCallback(NodeChangedCallbackContainer{ shared_from_this(), callback }));
1088 m_changedCallbackManager->UnregisterCallback(
1094 auto callbackContainer =
static_cast<NodeChangedCallbackContainer*
>(context);
1096 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:933
ChangedCallbackHandle RegisterChangedCallback(const ChangedCallback &callback)
Registers a callback for signaling a change to the node.
Definition peak_node.hpp:1080
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:554
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:897
bool IsDeprecated() const
Checks whether the node is deprecated.
Definition peak_node.hpp:890
std::string ToolTip() const
Returns the tool tip.
Definition peak_node.hpp:919
std::vector< std::shared_ptr< Node > > SelectedNodes() const
Returns the selected nodes.
Definition peak_node.hpp:1024
std::string DisplayName() const
Returns the display name.
Definition peak_node.hpp:812
Node & operator=(const Node &other)=delete
NodeNamespace Namespace() const
Returns the namespace the node belongs to.
Definition peak_node.hpp:819
Node & operator=(Node &&other)=delete
bool IsWriteable() const
Returns whether the node is currently writeable.
Definition peak_node.hpp:849
std::shared_ptr< Node > FindSelectingNode(const std::string &name) const
Tries to find a selecting node with the given name.
Definition peak_node.hpp:1046
std::shared_ptr< NodeMap > ParentNodeMap() const
Returns the parent node map.
Definition peak_node.hpp:939
std::string Name() const
Returns the name.
Definition peak_node.hpp:807
int64_t PollingTime() const
Returns the polling time.
Definition peak_node.hpp:912
std::shared_ptr< Node > FindInvalidatingNode(const std::string &name) const
Tries to find an invalidating node with the given name.
Definition peak_node.hpp:978
std::vector< std::shared_ptr< Node > > InvalidatingNodes() const
Returns the invalidating nodes.
Definition peak_node.hpp:990
virtual ~Node()
Definition peak_node.hpp:802
NodeVisibility Visibility() const
Returns the visibility.
Definition peak_node.hpp:827
bool IsAccessStatusCacheable() const
Checks whether the node's access status is cacheable.
Definition peak_node.hpp:876
bool IsReadable() const
Returns whether the node is currently readable.
Definition peak_node.hpp:843
std::shared_ptr< Node > FindSelectedNode(const std::string &name) const
Tries to find a selected node with the given name.
Definition peak_node.hpp:1012
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:502
std::vector< std::shared_ptr< Node > > InvalidatedNodes() const
Returns the invalidated nodes.
Definition peak_node.hpp:956
std::vector< std::shared_ptr< Node > > SelectingNodes() const
Returns the selecting nodes.
Definition peak_node.hpp:1058
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:398
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:450
bool IsCacheable() const
Checks whether the node is cacheable.
Definition peak_node.hpp:869
std::string Description() const
Returns the description.
Definition peak_node.hpp:926
bool IsStreamable() const
Checks whether the node is streamable.
Definition peak_node.hpp:883
Node(Node &&other)=delete
bool IsImplemented() const
Returns whether the node is implemented.
Definition peak_node.hpp:861
bool IsAvailable() const
Returns whether the node is currently either readable or writeable.
Definition peak_node.hpp:855
NodeCachingMode CachingMode() const
Returns the caching mode.
Definition peak_node.hpp:904
std::shared_ptr< Node > FindInvalidatedNode(const std::string &name) const
Tries to find an invalidated node with the given name.
Definition peak_node.hpp:944
ChangedCallback * ChangedCallbackHandle
Definition peak_node.hpp:133
NodeAccessStatus AccessStatus() const
Returns the access status.
Definition peak_node.hpp:835
void UnregisterChangedCallback(ChangedCallbackHandle callbackHandle)
Unregisters a changed callback.
Definition peak_node.hpp:1086
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:50
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:57
std::string GetNodeName(PEAK_NODE_HANDLE nodeHandle)
Definition peak_node.hpp:626
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:33
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