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;
351 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
403 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
455 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
458 auto castedNode = std::dynamic_pointer_cast<NodeType>(
FindSelectedNode(name));
507 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
564 struct NodeChangedCallbackContainer
566 std::shared_ptr<Node> _Node;
571 friend ClassCreator<Node>;
574 std::weak_ptr<NodeMap> m_parentNodeMap;
576 std::unique_ptr<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>
577 m_changedCallbackManager;
582 return QueryStringFromCInterfaceFunction([&](
char* nodeName,
size_t* nodeNameSize) {
603 std::string entryString;
607 entryString =
"NotImplemented";
611 entryString =
"NotAvailable";
615 entryString =
"WriteOnly";
619 entryString =
"ReadOnly";
623 entryString =
"ReadWrite";
631 std::string entryString;
635 entryString =
"NoCache";
639 entryString =
"WriteThrough";
643 entryString =
"WriteAround";
651 std::string entryString;
655 entryString =
"Custom";
659 entryString =
"Standard";
667 std::string entryString;
671 entryString =
"Integer";
675 entryString =
"Boolean";
679 entryString =
"Command";
683 entryString =
"Float";
687 entryString =
"String";
691 entryString =
"Register";
695 entryString =
"Category";
699 entryString =
"Enumeration";
703 entryString =
"EnumerationEntry";
711 std::string entryString;
715 entryString =
"Beginner";
719 entryString =
"Expert";
723 entryString =
"Guru";
727 entryString =
"Invisible";
735 : m_backendHandle(nodeHandle)
736 , m_parentNodeMap(parentNodeMap)
737 , m_changedCallbackManager()
739 m_changedCallbackManager =
740 std::make_unique<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>(
741 [&](
void* callbackContext) {
742 return QueryNumericFromCInterfaceFunction<PEAK_NODE_CHANGED_CALLBACK_HANDLE>(
745 m_backendHandle, ChangedCallbackCWrapper, callbackContext, nodeChangedCallbackHandle);
749 CallAndCheckCInterfaceFunction([&] {
758 m_changedCallbackManager->UnregisterAllCallbacks();
761inline std::string Node::Name()
const
766inline std::string Node::DisplayName()
const
768 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
776 QueryNumericFromCInterfaceFunction<PEAK_NODE_NAMESPACE>([&](
PEAK_NODE_NAMESPACE* _namespace) {
784 QueryNumericFromCInterfaceFunction<PEAK_NODE_VISIBILITY>([&](
PEAK_NODE_VISIBILITY* visibility) {
797inline bool Node::IsCacheable()
const
799 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isCacheable) {
804inline bool Node::IsAccessStatusCacheable()
const
806 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessStatusCacheable) {
811inline bool Node::IsStreamable()
const
813 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isStreamable) {
818inline bool Node::IsDeprecated()
const
820 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isDeprecated) {
825inline bool Node::IsFeature()
const
827 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isFeature) {
840inline int64_t Node::PollingTime()
const
842 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* pollingTime_ms) {
847inline std::string Node::ToolTip()
const
849 return QueryStringFromCInterfaceFunction([&](
char* toolTip,
size_t* toolTipSize) {
854inline std::string Node::Description()
const
856 return QueryStringFromCInterfaceFunction([&](
char* description,
size_t* descriptionSize) {
863 return static_cast<NodeType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_TYPE>(
867inline std::shared_ptr<peak::core::NodeMap> Node::ParentNodeMap()
const
869 return LockOrThrow(m_parentNodeMap);
872inline std::shared_ptr<Node> Node::FindInvalidatedNode(
const std::string& name)
const
874 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
876 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
881 return ParentNodeMap()->FindNode(name);
884inline std::vector<std::shared_ptr<Node>> Node::InvalidatedNodes()
const
886 auto numInvalidatedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
890 std::vector<std::shared_ptr<Node>> invalidatedNodes;
891 for (
size_t x = 0; x < numInvalidatedNodes; ++x)
893 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
900 invalidatedNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
903 return invalidatedNodes;
906inline std::shared_ptr<Node> Node::FindInvalidatingNode(
const std::string& name)
const
908 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
910 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
915 return ParentNodeMap()->FindNode(name);
918inline std::vector<std::shared_ptr<Node>> Node::InvalidatingNodes()
const
920 auto numInvalidatingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
924 std::vector<std::shared_ptr<Node>> invalidatingNodes;
925 for (
size_t x = 0; x < numInvalidatingNodes; ++x)
927 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
934 invalidatingNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
937 return invalidatingNodes;
940inline std::shared_ptr<Node> Node::FindSelectedNode(
const std::string& name)
const
942 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
944 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
949 return ParentNodeMap()->FindNode(name);
952inline std::vector<std::shared_ptr<Node>> Node::SelectedNodes()
const
954 auto numSelectedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectedNodes) {
958 std::vector<std::shared_ptr<Node>> selectedNodes;
959 for (
size_t x = 0; x < numSelectedNodes; ++x)
961 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
968 selectedNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
971 return selectedNodes;
974inline std::shared_ptr<Node> Node::FindSelectingNode(
const std::string& name)
const
976 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
978 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
983 return ParentNodeMap()->FindNode(name);
986inline std::vector<std::shared_ptr<Node>> Node::SelectingNodes()
const
988 auto numSelectingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectingNodes) {
992 std::vector<std::shared_ptr<Node>> selectingNodes;
993 for (
size_t x = 0; x < numSelectingNodes; ++x)
995 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1002 selectingNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
1005 return selectingNodes;
1011 m_changedCallbackManager->RegisterCallback(NodeChangedCallbackContainer{ shared_from_this(), callback }));
1016 m_changedCallbackManager->UnregisterCallback(
1022 auto callbackContainer =
static_cast<NodeChangedCallbackContainer*
>(context);
1024 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:861
ChangedCallbackHandle RegisterChangedCallback(const ChangedCallback &callback)
Registers a callback for signaling a change to the node.
Definition peak_node.hpp:1008
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:508
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:825
bool IsDeprecated() const
Checks whether the node is deprecated.
Definition peak_node.hpp:818
std::string ToolTip() const
Returns the tool tip.
Definition peak_node.hpp:847
std::vector< std::shared_ptr< Node > > SelectedNodes() const
Returns the selected nodes.
Definition peak_node.hpp:952
std::string DisplayName() const
Returns the display name.
Definition peak_node.hpp:766
Node & operator=(const Node &other)=delete
NodeNamespace Namespace() const
Returns the namespace the node belongs to.
Definition peak_node.hpp:773
Node & operator=(Node &&other)=delete
std::shared_ptr< Node > FindSelectingNode(const std::string &name) const
Tries to find a selecting node with the given name.
Definition peak_node.hpp:974
std::shared_ptr< NodeMap > ParentNodeMap() const
Returns the parent node map.
Definition peak_node.hpp:867
std::string Name() const
Returns the name.
Definition peak_node.hpp:761
int64_t PollingTime() const
Returns the polling time.
Definition peak_node.hpp:840
std::shared_ptr< Node > FindInvalidatingNode(const std::string &name) const
Tries to find an invalidating node with the given name.
Definition peak_node.hpp:906
std::vector< std::shared_ptr< Node > > InvalidatingNodes() const
Returns the invalidating nodes.
Definition peak_node.hpp:918
virtual ~Node()
Definition peak_node.hpp:756
NodeVisibility Visibility() const
Returns the visibility.
Definition peak_node.hpp:781
bool IsAccessStatusCacheable() const
Checks whether the node's access status is cacheable.
Definition peak_node.hpp:804
std::shared_ptr< Node > FindSelectedNode(const std::string &name) const
Tries to find a selected node with the given name.
Definition peak_node.hpp:940
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:456
std::vector< std::shared_ptr< Node > > InvalidatedNodes() const
Returns the invalidated nodes.
Definition peak_node.hpp:884
std::vector< std::shared_ptr< Node > > SelectingNodes() const
Returns the selecting nodes.
Definition peak_node.hpp:986
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:352
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:404
bool IsCacheable() const
Checks whether the node is cacheable.
Definition peak_node.hpp:797
std::string Description() const
Returns the description.
Definition peak_node.hpp:854
bool IsStreamable() const
Checks whether the node is streamable.
Definition peak_node.hpp:811
Node(Node &&other)=delete
NodeCachingMode CachingMode() const
Returns the caching mode.
Definition peak_node.hpp:832
std::shared_ptr< Node > FindInvalidatedNode(const std::string &name) const
Tries to find an invalidated node with the given name.
Definition peak_node.hpp:872
ChangedCallback * ChangedCallbackHandle
Definition peak_node.hpp:127
NodeAccessStatus AccessStatus() const
Returns the access status.
Definition peak_node.hpp:789
void UnregisterChangedCallback(ChangedCallbackHandle callbackHandle)
Unregisters a changed callback.
Definition peak_node.hpp:1014
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:580
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:32
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:560
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:411
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:208
int32_t PEAK_NODE_TYPE
Definition peak_backend.h:279
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:26
int32_t PEAK_NODE_CACHING_MODE
Definition peak_backend.h:217
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:251
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:289
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:29