IDS peak genericC++ v1.10.0
Loading...
Searching...
No Matches
peak_string_node.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
15#include <peak/dll_interface/peak_dll_interface_util.hpp>
18
19#include <cstdint>
20#include <string>
21
22namespace peak
23{
24namespace core
25{
26namespace nodes
27{
28
33class StringNode : public Node
34{
35public:
36 StringNode() = delete;
37 ~StringNode() override = default;
38 StringNode(const StringNode& other) = delete;
39 StringNode& operator=(const StringNode& other) = delete;
40 StringNode(StringNode&& other) = delete;
41 StringNode& operator=(StringNode&& other) = delete;
42
52 int64_t MaximumLength() const;
53
55 std::string Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
56
58 void SetValue(const std::string& value);
59
60private:
61 friend ClassCreator<StringNode>;
62 StringNode(PEAK_STRING_NODE_HANDLE stringNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
63 PEAK_STRING_NODE_HANDLE m_backendHandle;
64};
65
66} /* namespace nodes */
67} /* namespace core */
68} /* namespace peak */
69
70/* Implementation */
71namespace peak
72{
73namespace core
74{
75namespace nodes
76{
77
78inline StringNode::StringNode(PEAK_STRING_NODE_HANDLE stringNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
79 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
80 return PEAK_C_ABI_PREFIX PEAK_StringNode_ToNode(stringNodeHandle, nodeHandle);
81 }),
82 parentNodeMap)
83 , m_backendHandle(stringNodeHandle)
84{}
85
86inline int64_t StringNode::MaximumLength() const
87{
88 return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* maximumLength) {
89 return PEAK_C_ABI_PREFIX PEAK_StringNode_GetMaximumLength(m_backendHandle, maximumLength);
90 });
91}
92
93inline std::string StringNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
94{
95 auto lock = ParentNodeMap()->Lock();
96
97 return QueryStringFromCInterfaceFunction([&](char* value, size_t* valueSize) {
99 m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value, valueSize);
100 });
101}
102
103inline void StringNode::SetValue(const std::string& value)
104{
105 auto lock = ParentNodeMap()->Lock();
106
107 CallAndCheckCInterfaceFunction([&] {
108 return PEAK_C_ABI_PREFIX PEAK_StringNode_SetValue(m_backendHandle, value.c_str(), value.size() + 1);
109 });
110}
111
112} /* namespace nodes */
113} /* namespace core */
114} /* namespace peak */
std::shared_ptr< NodeMap > ParentNodeMap() const
Returns the parent node map.
Definition peak_node.hpp:933
StringNode & operator=(StringNode &&other)=delete
void SetValue(const std::string &value)
Sets the given value.
Definition peak_string_node.hpp:103
~StringNode() override=default
StringNode(const StringNode &other)=delete
StringNode & operator=(const StringNode &other)=delete
int64_t MaximumLength() const
Returns the maximum length.
Definition peak_string_node.hpp:86
std::string Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition peak_string_node.hpp:93
StringNode(StringNode &&other)=delete
The "nodes" namespace contains all GenAPI node types.
Definition peak_boolean_node.hpp:25
NodeCacheUsePolicy
Definition peak_common_node_enums.hpp:25
@ UseCache
Definition peak_common_node_enums.hpp:26
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:31
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
struct PEAK_STRING_NODE * PEAK_STRING_NODE_HANDLE
Definition peak_backend.h:449
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition peak_backend.h:429
PEAK_C_API PEAK_StringNode_GetValue(PEAK_STRING_NODE_HANDLE stringNodeHandle, PEAK_NODE_CACHE_USE_POLICY cacheUsePolicy, char *value, size_t *valueSize)
Asks the given string node for its value.
PEAK_C_API PEAK_StringNode_ToNode(PEAK_STRING_NODE_HANDLE stringNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given string node to a node.
int32_t PEAK_NODE_CACHE_USE_POLICY
Definition peak_backend.h:242
PEAK_C_API PEAK_StringNode_SetValue(PEAK_STRING_NODE_HANDLE stringNodeHandle, const char *value, size_t valueSize)
Tells the given string node to set the given value.
PEAK_C_API PEAK_StringNode_GetMaximumLength(PEAK_STRING_NODE_HANDLE stringNodeHandle, int64_t *maximumLength)
Asks the given string node for its maximum length.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16