CVB++ 15.0
decl_result_handle.hpp
1#pragma once
2
3#include "../../_cexports/c_code_reader.h"
4#include "../../shims/stdoptional.hpp"
5
6namespace Cvb
7{
8 CVB_BEGIN_INLINE_NS
9
10 namespace CodeReader
11 {
12 class ResultHandle;
13 }
14
15 template <>
16 inline HandleGuard<CodeReader::ResultHandle>::HandleGuard(void *handle) noexcept
17 : HandleGuard<CodeReader::ResultHandle>(handle, [](void *handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
18 {
19 }
20
21 namespace CodeReader
22 {
23 class ResultHandle final
24 {
25 friend class Result;
26 friend class Result2D;
27 friend class Decoder;
28
29 struct PrivateTag
30 {
31 };
32
33 private:
34 ResultHandle(ResultHandle &&other) noexcept = default;
35
36 public:
37 ResultHandle(const ResultHandle &other) = delete;
38 ResultHandle &operator=(const ResultHandle &other) = delete;
39 explicit ResultHandle(HandleGuard<ResultHandle> &&guard, PrivateTag) noexcept
40 : handle_(std::move(guard))
41 {
42 }
43 virtual ~ResultHandle() = default;
44
45 static std::unique_ptr<ResultHandle> FromHandle(HandleGuard<ResultHandle> &&guard)
46 {
47 if (!guard.Handle())
48 throw std::runtime_error("ResultHandle must not be null");
49
50 return std::make_unique<ResultHandle>(std::move(guard), PrivateTag{});
51 }
52
53 void *Handle() const noexcept
54 {
55 return handle_.Handle();
56 }
57
58 private:
59 HandleGuard<ResultHandle> handle_;
60 Cvb::optional<Result2D> TryCreateResult2D(size_t i) const;
61 std::vector<Result> CreateResultVector() const;
62 };
63
64 } // namespace CodeReader
65
66 CVB_END_INLINE_NS
67} // namespace Cvb
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for all decoding functionalities.
Definition decl_config_2d_codes.hpp:10
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17