IDS peak genericC++  v1.4.1
peak_string_node.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
13 
15 #include <peak/dll_interface/peak_dll_interface_util.hpp>
18 
19 #include <cstdint>
20 #include <string>
21 
22 
23 namespace peak
24 {
25 namespace core
26 {
27 namespace nodes
28 {
29 
34 class StringNode : public Node
35 {
36 public:
37  StringNode() = delete;
38  ~StringNode() override = default;
39  StringNode(const StringNode& other) = delete;
40  StringNode& operator=(const StringNode& other) = delete;
41  StringNode(StringNode&& other) = delete;
42  StringNode& operator=(StringNode&& other) = delete;
43 
53  int64_t MaximumLength() const;
54 
56  std::string Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
58  void SetValue(const std::string& value);
59 
60 private:
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 */
71 namespace peak
72 {
73 namespace core
74 {
75 namespace nodes
76 {
77 
78 inline 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 
86 inline 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 
93 inline std::string StringNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
94 {
95  return QueryStringFromCInterfaceFunction([&](char* value, size_t* valueSize) {
97  m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value, valueSize);
98  });
99 }
100 
101 inline void StringNode::SetValue(const std::string& value)
102 {
103  CallAndCheckCInterfaceFunction([&] {
104  return PEAK_C_ABI_PREFIX PEAK_StringNode_SetValue(m_backendHandle, value.c_str(), value.size() + 1);
105  });
106 }
107 
108 } /* namespace nodes */
109 } /* namespace core */
110 } /* namespace peak */
StringNode & operator=(const StringNode &other)=delete
void SetValue(const std::string &value)
Sets the given value.
Definition: peak_string_node.hpp:101
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.
int64_t MaximumLength() const
Returns the maximum length.
Definition: peak_string_node.hpp:86
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
NodeCacheUsePolicy
Definition: peak_common_node_enums.hpp:24
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition: peak_backend.h:409
std::string Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition: peak_string_node.hpp:93
PEAK_C_API PEAK_StringNode_ToNode(PEAK_STRING_NODE_HANDLE stringNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given string node to a node.
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.
struct PEAK_STRING_NODE * PEAK_STRING_NODE_HANDLE
Definition: peak_backend.h:429
Represents a GenAPI string node.
Definition: peak_string_node.hpp:34
#define PEAK_C_ABI_PREFIX
Definition: peak_dll_defines.h:16
Represents a GenAPI node.
Definition: peak_node.hpp:121
PEAK_C_API PEAK_StringNode_GetMaximumLength(PEAK_STRING_NODE_HANDLE stringNodeHandle, int64_t *maximumLength)
Asks the given string node for its maximum length.
~StringNode() override=default