browse_filter.hpp
1 #pragma once
2 
3 #include "../global.hpp"
4 
5 #include "exception.hpp"
6 #include "node_id.hpp"
7 
8 namespace Cvb
9 {
10 CVB_BEGIN_INLINE_NS;
11 template <>
12 inline HandleGuard<OpcUa::BrowseFilter>::HandleGuard(void * handle) noexcept
13  : HandleGuard<OpcUa::BrowseFilter>(handle, [](void* handle)
14 {
15  CVB_CALL_CAPI(ReleaseObject(handle));
16 })
17 {
18 }
19 
20 namespace OpcUa
21 {
27  : public std::enable_shared_from_this<BrowseFilter>
28 {
29 public:
30 
41  OpcUa::ReferenceDirection direction, OpcUa::ReferenceType referenceType, std::size_t maxReferences,
42  BrowseSubType subTypes, std::uint32_t nodeClassMask)
43  {
44  auto tmp = new CExports::TCVOPCBrowseFilter;
45  tmp->ReferenceDirection = static_cast<CExports::TCVOPCReferenceDirection>(direction);
46  tmp->ReferenceTypeId = static_cast<CExports::TCVOPCReferenceType>(referenceType);
47  tmp->MaxReferences = static_cast<CExports::cvbval_t>(maxReferences);
48  tmp->IncludeSubTypes = static_cast<CExports::TCVOPCBrowseSubType>(subTypes);
49  tmp->NodeClassMask = static_cast<CExports::cvbval_t>(nodeClassMask);
50 
51  HandleGuard<BrowseFilter> guard(tmp);
52  if (!guard.Handle())
54 
55  BrowseFilterPtr bf(new BrowseFilter(std::move(guard)));
56 
57  return bf;
58  }
59 
67  {
68  return Create(ReferenceDirection::Forward, referenceTypeID, 10000U, BrowseSubType::SubTypesIncluded, 0U);
69  }
70 
77  {
78  return Create(ReferenceDirection::Forward, OpcUa::ReferenceType::Hierarchical, 10000U, BrowseSubType::SubTypesIncluded, 0U);
79  }
80 
85  void * Handle() const noexcept
86  {
87  return handle_.Handle();
88  }
89 
90  virtual ~BrowseFilter() = default;
91 
92 protected:
94  explicit BrowseFilter(HandleGuard<BrowseFilter> && guard) noexcept
95  : handle_(std::move(guard))
96  {
97  }
98 
99 private:
100  explicit BrowseFilter(std::function<HandleGuard<BrowseFilter>()> creator)
101  : BrowseFilter(creator())
102  {
103  }
104  HandleGuard<BrowseFilter> handle_;
106 };
107 }
108 CVB_END_INLINE_NS
109 }
STL class.
The BrowseFilter serves to specify the parameter of a browse operation on an OPCUA node object.
Definition: browse_filter.hpp:26
BrowseSubType
Define whether sub types of nodes should be included as part of a BaseNode::Browse operation.
Definition: opcua.hpp:306
const int CVB_ERROR
Generic unspecified error.
Definition: exception.hpp:24
Root namespace for the Image Manager interface.
Definition: version.hpp:11
void * Handle() const noexcept
Returns C-API style handle to BaseNode Object.
Definition: browse_filter.hpp:85
ReferenceDirection
Describes the direction for a OpcUa::Reference.
Definition: opcua.hpp:115
Special runtime exception to carry a native error code.
Definition: exception.hpp:24
ReferenceType
Used for defining References between Nodes. See OpcUa::Server::AddReference.
Definition: opcua.hpp:221
static BrowseFilterPtr Create()
Creates an even simpler BrowseFilter for browsing the OPCUA client.
Definition: browse_filter.hpp:76
static BrowseFilterPtr Create(OpcUa::ReferenceDirection direction, OpcUa::ReferenceType referenceType, std::size_t maxReferences, BrowseSubType subTypes, std::uint32_t nodeClassMask)
Creates a BrowseFilter for browsing the OPCUA client.
Definition: browse_filter.hpp:40
static BrowseFilterPtr Create(OpcUa::ReferenceType referenceTypeID)
Creates a simpler BrowseFilter for browsing the OPCUA client.
Definition: browse_filter.hpp:66