CVB++ 15.1
Loading...
Searching...
No Matches
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 ResultHandle &operator=(ResultHandle &&other) = delete;
40 explicit ResultHandle(HandleGuard<ResultHandle> &&guard, PrivateTag) noexcept
41 : handle_(std::move(guard))
42 {
43 }
44 ~ResultHandle() = default;
45
46 static std::unique_ptr<ResultHandle> FromHandle(HandleGuard<ResultHandle> &&guard)
47 {
48 if (!guard.Handle())
49 throw std::runtime_error("ResultHandle must not be null");
50
51 return std::make_unique<ResultHandle>(std::move(guard), PrivateTag{});
52 }
53
54 void *Handle() const noexcept
55 {
56 return handle_.Handle();
57 }
58
59 private:
60 HandleGuard<ResultHandle> handle_;
61 Cvb::optional<Result2D> TryCreateResult2D(size_t i) const;
62 std::vector<Result> CreateResultVector() const;
63 TimeLimitStatus IsTimeLimitReached() const;
64 };
65
66 } // namespace CodeReader
67
68 CVB_END_INLINE_NS
69} // namespace Cvb
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for all decoding functionalities.
Definition decl_config_2d_codes.hpp:10
TimeLimitStatus
Enum class specifying decoder status returned by function Cvb::CodeReader::Decoder::ExecuteFor.
Definition decl_decoder.hpp:31
Root namespace for the Image Manager interface.
Definition version.hpp:11