Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqnxcamerahandle_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QQNXCAMERAHANDLE_P_H
4#define QQNXCAMERAHANDLE_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <camera/camera_api.h>
18
19#include <utility>
20
22{
23public:
24 QQnxCameraHandle() = default;
25
26 explicit QQnxCameraHandle(camera_handle_t h)
27 : m_handle (h) {}
28
30 : m_handle(other.m_handle)
31 , m_lastError(other.m_lastError)
32 {
34 }
35
37
39 {
40 m_handle = other.m_handle;
41 m_lastError = other.m_lastError;
42
44
45 return *this;
46 }
47
49 {
50 close();
51 }
52
53 bool open(camera_unit_t unit, uint32_t mode)
54 {
55 if (isOpen()) {
56 m_lastError = CAMERA_EALREADY;
57 return false;
58 }
59
60 return cacheError(camera_open, unit, mode, &m_handle);
61 }
62
63 bool close()
64 {
65 if (!isOpen())
66 return true;
67
68 const bool success = cacheError(camera_close, m_handle);
69 m_handle = CAMERA_HANDLE_INVALID;
70
71 return success;
72 }
73
74 camera_handle_t get() const
75 {
76 return m_handle;
77 }
78
79 bool isOpen() const
80 {
81 return m_handle != CAMERA_HANDLE_INVALID;
82 }
83
84 camera_error_t lastError() const
85 {
86 return m_lastError;
87 }
88
89private:
90 template <typename Func, typename ...Args>
91 bool cacheError(Func f, Args &&...args)
92 {
93 m_lastError = f(std::forward<Args>(args)...);
94
95 return m_lastError == CAMERA_EOK;
96 }
97
98 camera_handle_t m_handle = CAMERA_HANDLE_INVALID;
99 camera_error_t m_lastError = CAMERA_EOK;
100};
101
102#endif
bool open(camera_unit_t unit, uint32_t mode)
QQnxCameraHandle(const QQnxCameraHandle &)=delete
camera_handle_t get() const
QQnxCameraHandle()=default
camera_error_t lastError() const
QQnxCameraHandle(QQnxCameraHandle &&other)
QQnxCameraHandle & operator=(QQnxCameraHandle &&other)
QQnxCameraHandle(camera_handle_t h)
GLenum mode
GLfloat GLfloat f
GLfloat GLfloat GLfloat GLfloat h
QSharedPointer< T > other(t)
[5]
QJSValueList args