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;
371 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
423 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
475 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
478 auto castedNode = std::dynamic_pointer_cast<NodeType>(
FindSelectedNode(name));
527 template <class NodeType, typename std::enable_if<std::is_base_of<Node, NodeType>::value,
int>::type = 0>
584 struct NodeChangedCallbackContainer
586 std::shared_ptr<Node> _Node;
591 friend ClassCreator<Node>;
594 std::weak_ptr<NodeMap> m_parentNodeMap;
596 std::unique_ptr<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>
597 m_changedCallbackManager;
602 return QueryStringFromCInterfaceFunction([&](
char* nodeName,
size_t* nodeNameSize) {
623 std::string entryString;
627 entryString =
"NotImplemented";
631 entryString =
"NotAvailable";
635 entryString =
"WriteOnly";
639 entryString =
"ReadOnly";
643 entryString =
"ReadWrite";
651 std::string entryString;
655 entryString =
"NoCache";
659 entryString =
"WriteThrough";
663 entryString =
"WriteAround";
671 std::string entryString;
675 entryString =
"Custom";
679 entryString =
"Standard";
687 std::string entryString;
691 entryString =
"Integer";
695 entryString =
"Boolean";
699 entryString =
"Command";
703 entryString =
"Float";
707 entryString =
"String";
711 entryString =
"Register";
715 entryString =
"Category";
719 entryString =
"Enumeration";
723 entryString =
"EnumerationEntry";
731 std::string entryString;
735 entryString =
"Beginner";
739 entryString =
"Expert";
743 entryString =
"Guru";
747 entryString =
"Invisible";
755 : m_backendHandle(nodeHandle)
756 , m_parentNodeMap(parentNodeMap)
757 , m_changedCallbackManager()
759 m_changedCallbackManager =
760 std::make_unique<TCallbackManager<PEAK_NODE_CHANGED_CALLBACK_HANDLE, NodeChangedCallbackContainer>>(
761 [&](
void* callbackContext) {
762 return QueryNumericFromCInterfaceFunction<PEAK_NODE_CHANGED_CALLBACK_HANDLE>(
765 m_backendHandle, ChangedCallbackCWrapper, callbackContext, nodeChangedCallbackHandle);
769 CallAndCheckCInterfaceFunction([&] {
778 m_changedCallbackManager->UnregisterAllCallbacks();
781inline std::string Node::Name()
const
786inline std::string Node::DisplayName()
const
788 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
796 QueryNumericFromCInterfaceFunction<PEAK_NODE_NAMESPACE>([&](
PEAK_NODE_NAMESPACE* _namespace) {
804 QueryNumericFromCInterfaceFunction<PEAK_NODE_VISIBILITY>([&](
PEAK_NODE_VISIBILITY* visibility) {
817inline bool Node::IsReadable()
const
820 return accessStatus == NodeAccessStatus::ReadOnly || accessStatus == NodeAccessStatus::ReadWrite;
823inline bool Node::IsWriteable()
const
826 return accessStatus == NodeAccessStatus::WriteOnly || accessStatus == NodeAccessStatus::ReadWrite;
829inline bool Node::IsCacheable()
const
831 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isCacheable) {
836inline bool Node::IsAccessStatusCacheable()
const
838 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessStatusCacheable) {
843inline bool Node::IsStreamable()
const
845 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isStreamable) {
850inline bool Node::IsDeprecated()
const
852 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isDeprecated) {
857inline bool Node::IsFeature()
const
859 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isFeature) {
872inline int64_t Node::PollingTime()
const
874 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* pollingTime_ms) {
879inline std::string Node::ToolTip()
const
881 return QueryStringFromCInterfaceFunction([&](
char* toolTip,
size_t* toolTipSize) {
886inline std::string Node::Description()
const
888 return QueryStringFromCInterfaceFunction([&](
char* description,
size_t* descriptionSize) {
895 return static_cast<NodeType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_TYPE>(
899inline std::shared_ptr<peak::core::NodeMap> Node::ParentNodeMap()
const
901 return LockOrThrow(m_parentNodeMap);
904inline std::shared_ptr<Node> Node::FindInvalidatedNode(
const std::string& name)
const
906 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](
PEAK_NODE_HANDLE* _nodeHandle) {
908 m_backendHandle, name.c_str(), name.size() + 1, _nodeHandle);
913 return ParentNodeMap()->FindNode(name);
916inline std::vector<std::shared_ptr<Node>> Node::InvalidatedNodes()
const
918 auto numInvalidatedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
922 std::vector<std::shared_ptr<Node>> invalidatedNodes;
923 for (
size_t x = 0; x < numInvalidatedNodes; ++x)
925 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
932 invalidatedNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
935 return invalidatedNodes;
938inline std::shared_ptr<Node> Node::FindInvalidatingNode(
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::InvalidatingNodes()
const
952 auto numInvalidatingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numInvalidatedNodes) {
956 std::vector<std::shared_ptr<Node>> invalidatingNodes;
957 for (
size_t x = 0; x < numInvalidatingNodes; ++x)
959 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
966 invalidatingNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
969 return invalidatingNodes;
972inline std::shared_ptr<Node> Node::FindSelectedNode(
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::SelectedNodes()
const
986 auto numSelectedNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectedNodes) {
990 std::vector<std::shared_ptr<Node>> selectedNodes;
991 for (
size_t x = 0; x < numSelectedNodes; ++x)
993 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1000 selectedNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
1003 return selectedNodes;
1006inline std::shared_ptr<Node> Node::FindSelectingNode(
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::SelectingNodes()
const
1020 auto numSelectingNodes = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numSelectingNodes) {
1024 std::vector<std::shared_ptr<Node>> selectingNodes;
1025 for (
size_t x = 0; x < numSelectingNodes; ++x)
1027 auto nodeHandle = QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>(
1034 selectingNodes.emplace_back(ParentNodeMap()->FindNode(nodeName));
1037 return selectingNodes;
1043 m_changedCallbackManager->RegisterCallback(NodeChangedCallbackContainer{ shared_from_this(), callback }));
1048 m_changedCallbackManager->UnregisterCallback(
1054 auto callbackContainer =
static_cast<NodeChangedCallbackContainer*
>(context);
1056 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:893
ChangedCallbackHandle RegisterChangedCallback(const ChangedCallback &callback)
Registers a callback for signaling a change to the node.
Definition peak_node.hpp:1040
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:528
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:857
bool IsDeprecated() const
Checks whether the node is deprecated.
Definition peak_node.hpp:850
std::string ToolTip() const
Returns the tool tip.
Definition peak_node.hpp:879
std::vector< std::shared_ptr< Node > > SelectedNodes() const
Returns the selected nodes.
Definition peak_node.hpp:984
std::string DisplayName() const
Returns the display name.
Definition peak_node.hpp:786
Node & operator=(const Node &other)=delete
NodeNamespace Namespace() const
Returns the namespace the node belongs to.
Definition peak_node.hpp:793
Node & operator=(Node &&other)=delete
bool IsWriteable() const
Returns whether the node is currently writeable.
Definition peak_node.hpp:823
std::shared_ptr< Node > FindSelectingNode(const std::string &name) const
Tries to find a selecting node with the given name.
Definition peak_node.hpp:1006
std::shared_ptr< NodeMap > ParentNodeMap() const
Returns the parent node map.
Definition peak_node.hpp:899
std::string Name() const
Returns the name.
Definition peak_node.hpp:781
int64_t PollingTime() const
Returns the polling time.
Definition peak_node.hpp:872
std::shared_ptr< Node > FindInvalidatingNode(const std::string &name) const
Tries to find an invalidating node with the given name.
Definition peak_node.hpp:938
std::vector< std::shared_ptr< Node > > InvalidatingNodes() const
Returns the invalidating nodes.
Definition peak_node.hpp:950
virtual ~Node()
Definition peak_node.hpp:776
NodeVisibility Visibility() const
Returns the visibility.
Definition peak_node.hpp:801
bool IsAccessStatusCacheable() const
Checks whether the node's access status is cacheable.
Definition peak_node.hpp:836
bool IsReadable() const
Returns whether the node is currently readable.
Definition peak_node.hpp:817
std::shared_ptr< Node > FindSelectedNode(const std::string &name) const
Tries to find a selected node with the given name.
Definition peak_node.hpp:972
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:476
std::vector< std::shared_ptr< Node > > InvalidatedNodes() const
Returns the invalidated nodes.
Definition peak_node.hpp:916
std::vector< std::shared_ptr< Node > > SelectingNodes() const
Returns the selecting nodes.
Definition peak_node.hpp:1018
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:372
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:424
bool IsCacheable() const
Checks whether the node is cacheable.
Definition peak_node.hpp:829
std::string Description() const
Returns the description.
Definition peak_node.hpp:886
bool IsStreamable() const
Checks whether the node is streamable.
Definition peak_node.hpp:843
Node(Node &&other)=delete
NodeCachingMode CachingMode() const
Returns the caching mode.
Definition peak_node.hpp:864
std::shared_ptr< Node > FindInvalidatedNode(const std::string &name) const
Tries to find an invalidated node with the given name.
Definition peak_node.hpp:904
ChangedCallback * ChangedCallbackHandle
Definition peak_node.hpp:127
NodeAccessStatus AccessStatus() const
Returns the access status.
Definition peak_node.hpp:809
void UnregisterChangedCallback(ChangedCallbackHandle callbackHandle)
Unregisters a changed callback.
Definition peak_node.hpp:1046
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:600
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:561
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:412
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:30