15#include <peak/dll_interface/peak_dll_interface_util.hpp>
16#include <peak/generic/peak_t_callback_manager.hpp>
111struct NodeChangedCallbackContainer;
121class Node :
public std::enable_shared_from_this<Node>
125 using ChangedCallback = std::function<void(
const std::shared_ptr<Node>& changedNode)>;
145 std::string
Name()
const;
391 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
443 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
495 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
498 auto castedNode = std::dynamic_pointer_cast<NodeType>(
FindSelectedNode(name));
547 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
604 struct NodeChangedCallbackContainer
606 std::shared_ptr<Node> _Node;
611 friend ClassCreator<Node>;
614 std::weak_ptr<NodeMap> m_parentNodeMap;
616 std::unique_ptr<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>
617 m_changedCallbackManager;
622 return QueryStringFromCInterfaceFunction([&](
char* nodeName,
size_t* nodeNameSize) {
643 std::string entryString;
647 entryString =
"NotImplemented";
651 entryString =
"NotAvailable";
655 entryString =
"WriteOnly";
659 entryString =
"ReadOnly";
663 entryString =
"ReadWrite";
671 std::string entryString;
675 entryString =
"NoCache";
679 entryString =
"WriteThrough";
683 entryString =
"WriteAround";
691 std::string entryString;
695 entryString =
"Custom";
699 entryString =
"Standard";
707 std::string entryString;
711 entryString =
"Integer";
715 entryString =
"Boolean";
719 entryString =
"Command";
723 entryString =
"Float";
727 entryString =
"String";
731 entryString =
"Register";
735 entryString =
"Category";
739 entryString =
"Enumeration";
743 entryString =
"EnumerationEntry";
751 std::string entryString;
755 entryString =
"Beginner";
759 entryString =
"Expert";
763 entryString =
"Guru";
767 entryString =
"Invisible";
775 : m_backendHandle(nodeHandle)
776 , m_parentNodeMap(parentNodeMap)
777 , m_changedCallbackManager()
779 m_changedCallbackManager =
780 std::make_unique<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>(
781 [&](
void* callbackContext) {
782 return QueryNumericFromCInterfaceFunction<PEAK_NODE_CHANGED_CALLBACK_HANDLE>(
785 m_backendHandle, ChangedCallbackCWrapper, callbackContext, nodeChangedCallbackHandle);
789 CallAndCheckCInterfaceFunction([&] {
798 m_changedCallbackManager->UnregisterAllCallbacks();
801inline std::string Node::Name()
const
806inline std::string Node::DisplayName()
const
808 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
816 QueryNumericFromCInterfaceFunction<PEAK_NODE_NAMESPACE>([&](
PEAK_NODE_NAMESPACE* _namespace) {
824 QueryNumericFromCInterfaceFunction<PEAK_NODE_VISIBILITY>([&](
PEAK_NODE_VISIBILITY* visibility) {
837inline bool Node::IsReadable()
const
840 return accessStatus == NodeAccessStatus::ReadOnly || accessStatus == NodeAccessStatus::ReadWrite;
843inline bool Node::IsWriteable()
const
846 return accessStatus == NodeAccessStatus::WriteOnly || accessStatus == NodeAccessStatus::ReadWrite;
849inline bool Node::IsAvailable()
const
852 return accessStatus != NodeAccessStatus::NotImplemented && accessStatus != NodeAccessStatus::NotAvailable;
855inline bool Node::IsImplemented()
const
858 return accessStatus != NodeAccessStatus::NotImplemented;
863inline bool Node::IsCacheable()
const
865 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isCacheable) {
870inline bool Node::IsAccessStatusCacheable()
const
872 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessStatusCacheable) {
877inline bool Node::IsStreamable()
const
879 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isStreamable) {
884inline bool Node::IsDeprecated()
const
886 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isDeprecated) {
891inline bool Node::IsFeature()
const
893 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isFeature) {
906inline int64_t Node::PollingTime()
const
908 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* pollingTime_ms) {
913inline std::string Node::ToolTip()
const
915 return QueryStringFromCInterfaceFunction([&](
char* toolTip,
size_t* toolTipSize) {
920inline std::string Node::Description()
const
922 return QueryStringFromCInterfaceFunction([&](
char* description,
size_t* descriptionSize) {
929 return static_cast<NodeType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_TYPE>(
933inline std::shared_ptr<peak::core::NodeMap> Node::ParentNodeMap()
const
935 return LockOrThrow(m_parentNodeMap);
938inline std::shared_ptr<Node> Node::FindInvalidatedNode(
const std::string& name)
const
940 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
942 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
947 return ParentNodeMap()->FindNode(name);
950inline std::vector<std::shared_ptr<Node>> Node::InvalidatedNodes()
const
952 auto numInvalidatedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
956 std::vector<std::shared_ptr<Node>> invalidatedNodes;
957 for (
size_t x = 0; x < numInvalidatedNodes; ++x)
959 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
966 invalidatedNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
969 return invalidatedNodes;
972inline std::shared_ptr<Node> Node::FindInvalidatingNode(
const std::string& name)
const
974 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
976 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
981 return ParentNodeMap()->FindNode(name);
984inline std::vector<std::shared_ptr<Node>> Node::InvalidatingNodes()
const
986 auto numInvalidatingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
990 std::vector<std::shared_ptr<Node>> invalidatingNodes;
991 for (
size_t x = 0; x < numInvalidatingNodes; ++x)
993 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1000 invalidatingNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
1003 return invalidatingNodes;
1006inline std::shared_ptr<Node> Node::FindSelectedNode(
const std::string& name)
const
1008 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1010 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1015 return ParentNodeMap()->FindNode(name);
1018inline std::vector<std::shared_ptr<Node>> Node::SelectedNodes()
const
1020 auto numSelectedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectedNodes) {
1024 std::vector<std::shared_ptr<Node>> selectedNodes;
1025 for (
size_t x = 0; x < numSelectedNodes; ++x)
1027 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1034 selectedNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
1037 return selectedNodes;
1040inline std::shared_ptr<Node> Node::FindSelectingNode(
const std::string& name)
const
1042 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
1044 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
1049 return ParentNodeMap()->FindNode(name);
1052inline std::vector<std::shared_ptr<Node>> Node::SelectingNodes()
const
1054 auto numSelectingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectingNodes) {
1058 std::vector<std::shared_ptr<Node>> selectingNodes;
1059 for (
size_t x = 0; x < numSelectingNodes; ++x)
1061 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1068 selectingNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
1071 return selectingNodes;
1077 m_changedCallbackManager->RegisterCallback(NodeChangedCallbackContainer{ shared_from_this(), callback }));
1082 m_changedCallbackManager->UnregisterCallback(
1088 auto callbackContainer =
static_cast<NodeChangedCallbackContainer*
>(context);
1090 callbackContainer->Callback(callbackContainer->_Node);
The exception thrown for trying to apply an invalid cast.
Definition peak_exception.hpp:82
Represents a GenAPI node.
Definition peak_node.hpp:122
NodeType Type() const
Returns the type.
Definition peak_node.hpp:927
ChangedCallbackHandle RegisterChangedCallback(const ChangedCallback &callback)
Registers a callback for signaling a change to the node.
Definition peak_node.hpp:1074
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:548
std::function< void(const std::shared_ptr< Node > &changedNode)> ChangedCallback
Definition peak_node.hpp:125
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:891
bool IsDeprecated() const
Checks whether the node is deprecated.
Definition peak_node.hpp:884
std::string ToolTip() const
Returns the tool tip.
Definition peak_node.hpp:913
std::vector< std::shared_ptr< Node > > SelectedNodes() const
Returns the selected nodes.
Definition peak_node.hpp:1018
std::string DisplayName() const
Returns the display name.
Definition peak_node.hpp:806
Node & operator=(const Node &other)=delete
NodeNamespace Namespace() const
Returns the namespace the node belongs to.
Definition peak_node.hpp:813
Node & operator=(Node &&other)=delete
bool IsWriteable() const
Returns whether the node is currently writeable.
Definition peak_node.hpp:843
std::shared_ptr< Node > FindSelectingNode(const std::string &name) const
Tries to find a selecting node with the given name.
Definition peak_node.hpp:1040
std::shared_ptr< NodeMap > ParentNodeMap() const
Returns the parent node map.
Definition peak_node.hpp:933
std::string Name() const
Returns the name.
Definition peak_node.hpp:801
int64_t PollingTime() const
Returns the polling time.
Definition peak_node.hpp:906
std::shared_ptr< Node > FindInvalidatingNode(const std::string &name) const
Tries to find an invalidating node with the given name.
Definition peak_node.hpp:972
std::vector< std::shared_ptr< Node > > InvalidatingNodes() const
Returns the invalidating nodes.
Definition peak_node.hpp:984
virtual ~Node()
Definition peak_node.hpp:796
NodeVisibility Visibility() const
Returns the visibility.
Definition peak_node.hpp:821
bool IsAccessStatusCacheable() const
Checks whether the node's access status is cacheable.
Definition peak_node.hpp:870
bool IsReadable() const
Returns whether the node is currently readable.
Definition peak_node.hpp:837
std::shared_ptr< Node > FindSelectedNode(const std::string &name) const
Tries to find a selected node with the given name.
Definition peak_node.hpp:1006
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:496
std::vector< std::shared_ptr< Node > > InvalidatedNodes() const
Returns the invalidated nodes.
Definition peak_node.hpp:950
std::vector< std::shared_ptr< Node > > SelectingNodes() const
Returns the selecting nodes.
Definition peak_node.hpp:1052
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:392
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:444
bool IsCacheable() const
Checks whether the node is cacheable.
Definition peak_node.hpp:863
std::string Description() const
Returns the description.
Definition peak_node.hpp:920
bool IsStreamable() const
Checks whether the node is streamable.
Definition peak_node.hpp:877
Node(Node &&other)=delete
bool IsImplemented() const
Returns whether the node is implemented.
Definition peak_node.hpp:855
bool IsAvailable() const
Returns whether the node is currently either readable or writeable.
Definition peak_node.hpp:849
NodeCachingMode CachingMode() const
Returns the caching mode.
Definition peak_node.hpp:898
std::shared_ptr< Node > FindInvalidatedNode(const std::string &name) const
Tries to find an invalidated node with the given name.
Definition peak_node.hpp:938
ChangedCallback * ChangedCallbackHandle
Definition peak_node.hpp:127
NodeAccessStatus AccessStatus() const
Returns the access status.
Definition peak_node.hpp:829
void UnregisterChangedCallback(ChangedCallbackHandle callbackHandle)
Unregisters a changed callback.
Definition peak_node.hpp:1080
Node(const Node &other)=delete
NodeVisibility
Definition peak_node.hpp:103
NodeType
Definition peak_node.hpp:87
NodeNamespace
Definition peak_node.hpp:78
NodeCachingMode
Definition peak_node.hpp:58
std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:54
NodeAccessStatus
Definition peak_node.hpp:45
std::string GetNodeName(PEAK_NODE_HANDLE nodeHandle)
Definition peak_node.hpp:620
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