From 6410d1d37c1ea9d1d168840a7ba063facb0bc9d6 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Fri, 25 Jun 2021 00:09:15 +0100 Subject: libcamera/base: Move class helpers to the base library Move the class support infrastructure to the base library. Reviewed-by: Paul Elder Reviewed-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- include/libcamera/base/class.h | 105 ++++++++++++++++++++++++ include/libcamera/base/meson.build | 1 + include/libcamera/buffer.h | 3 +- include/libcamera/camera.h | 3 +- include/libcamera/camera_manager.h | 3 +- include/libcamera/class.h | 105 ------------------------ include/libcamera/controls.h | 3 +- include/libcamera/framebuffer_allocator.h | 2 +- include/libcamera/internal/buffer.h | 3 +- include/libcamera/internal/byte_stream_buffer.h | 3 +- include/libcamera/internal/camera_sensor.h | 3 +- include/libcamera/internal/file.h | 3 +- include/libcamera/internal/log.h | 3 +- include/libcamera/internal/media_object.h | 2 +- include/libcamera/internal/pipeline_handler.h | 3 +- include/libcamera/internal/v4l2_subdevice.h | 3 +- include/libcamera/internal/v4l2_videodevice.h | 3 +- include/libcamera/meson.build | 1 - include/libcamera/request.h | 3 +- 19 files changed, 133 insertions(+), 122 deletions(-) create mode 100644 include/libcamera/base/class.h delete mode 100644 include/libcamera/class.h (limited to 'include') diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h new file mode 100644 index 00000000..a07dac05 --- /dev/null +++ b/include/libcamera/base/class.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * class.h - Utilities and helpers for classes + */ +#ifndef __LIBCAMERA_BASE_CLASS_H__ +#define __LIBCAMERA_BASE_CLASS_H__ + +#include + +namespace libcamera { + +#ifndef __DOXYGEN__ +#define LIBCAMERA_DISABLE_COPY(klass) \ + klass(const klass &) = delete; \ + klass &operator=(const klass &) = delete; + +#define LIBCAMERA_DISABLE_MOVE(klass) \ + klass(klass &&) = delete; \ + klass &operator=(klass &&) = delete; + +#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) \ + LIBCAMERA_DISABLE_COPY(klass) \ + LIBCAMERA_DISABLE_MOVE(klass) +#else +#define LIBCAMERA_DISABLE_COPY(klass) +#define LIBCAMERA_DISABLE_MOVE(klass) +#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) +#endif + +#ifndef __DOXYGEN__ +#define LIBCAMERA_DECLARE_PRIVATE() \ +public: \ + class Private; \ + friend class Private; + +#define LIBCAMERA_DECLARE_PUBLIC(klass) \ + friend class klass; \ + using Public = klass; + +#define LIBCAMERA_D_PTR() \ + _d(); + +#define LIBCAMERA_O_PTR() \ + _o(); + +#else +#define LIBCAMERA_DECLARE_PRIVATE() +#define LIBCAMERA_DECLARE_PUBLIC(klass) +#define LIBCAMERA_D_PTR() +#define LIBCAMERA_O_PTR() +#endif + +class Extensible +{ +public: + class Private + { + public: + Private(Extensible *o); + virtual ~Private(); + +#ifndef __DOXYGEN__ + template + const T *_o() const + { + return static_cast(o_); + } + + template + T *_o() + { + return static_cast(o_); + } +#endif + + private: + Extensible *const o_; + }; + + Extensible(Private *d); + +protected: +#ifndef __DOXYGEN__ + template + const T *_d() const + { + return static_cast(d_.get()); + } + + template + T *_d() + { + return static_cast(d_.get()); + } +#endif + +private: + const std::unique_ptr d_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_BASE_CLASS_H__ */ diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build index 9f0ba6b0..2db756c5 100644 --- a/include/libcamera/base/meson.build +++ b/include/libcamera/base/meson.build @@ -3,6 +3,7 @@ libcamera_base_include_dir = libcamera_include_dir / 'base' libcamera_base_headers = files([ + 'class.h', 'utils.h', ]) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index e0af0090..323d1cba 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -10,7 +10,8 @@ #include #include -#include +#include + #include namespace libcamera { diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index d7164180..ea091400 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -12,7 +12,8 @@ #include #include -#include +#include + #include #include #include diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index c2f0b786..5deede03 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -12,7 +12,8 @@ #include #include -#include +#include + #include #include diff --git a/include/libcamera/class.h b/include/libcamera/class.h deleted file mode 100644 index f384a488..00000000 --- a/include/libcamera/class.h +++ /dev/null @@ -1,105 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2020, Google Inc. - * - * class.h - Utilities and helpers for classes - */ -#ifndef __LIBCAMERA_CLASS_H__ -#define __LIBCAMERA_CLASS_H__ - -#include - -namespace libcamera { - -#ifndef __DOXYGEN__ -#define LIBCAMERA_DISABLE_COPY(klass) \ - klass(const klass &) = delete; \ - klass &operator=(const klass &) = delete; - -#define LIBCAMERA_DISABLE_MOVE(klass) \ - klass(klass &&) = delete; \ - klass &operator=(klass &&) = delete; - -#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) \ - LIBCAMERA_DISABLE_COPY(klass) \ - LIBCAMERA_DISABLE_MOVE(klass) -#else -#define LIBCAMERA_DISABLE_COPY(klass) -#define LIBCAMERA_DISABLE_MOVE(klass) -#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) -#endif - -#ifndef __DOXYGEN__ -#define LIBCAMERA_DECLARE_PRIVATE() \ -public: \ - class Private; \ - friend class Private; - -#define LIBCAMERA_DECLARE_PUBLIC(klass) \ - friend class klass; \ - using Public = klass; - -#define LIBCAMERA_D_PTR() \ - _d(); - -#define LIBCAMERA_O_PTR() \ - _o(); - -#else -#define LIBCAMERA_DECLARE_PRIVATE() -#define LIBCAMERA_DECLARE_PUBLIC(klass) -#define LIBCAMERA_D_PTR() -#define LIBCAMERA_O_PTR() -#endif - -class Extensible -{ -public: - class Private - { - public: - Private(Extensible *o); - virtual ~Private(); - -#ifndef __DOXYGEN__ - template - const T *_o() const - { - return static_cast(o_); - } - - template - T *_o() - { - return static_cast(o_); - } -#endif - - private: - Extensible *const o_; - }; - - Extensible(Private *d); - -protected: -#ifndef __DOXYGEN__ - template - const T *_d() const - { - return static_cast(d_.get()); - } - - template - T *_d() - { - return static_cast(d_.get()); - } -#endif - -private: - const std::unique_ptr d_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_CLASS_H__ */ diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1c9b37e6..f62b6cf0 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -14,7 +14,8 @@ #include #include -#include +#include + #include #include diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h index 0c85631a..cbc9ce10 100644 --- a/include/libcamera/framebuffer_allocator.h +++ b/include/libcamera/framebuffer_allocator.h @@ -11,7 +11,7 @@ #include #include -#include +#include namespace libcamera { diff --git a/include/libcamera/internal/buffer.h b/include/libcamera/internal/buffer.h index 9da1fbd1..91dd2496 100644 --- a/include/libcamera/internal/buffer.h +++ b/include/libcamera/internal/buffer.h @@ -10,7 +10,8 @@ #include #include -#include +#include + #include #include diff --git a/include/libcamera/internal/byte_stream_buffer.h b/include/libcamera/internal/byte_stream_buffer.h index 866cb9b0..7eefb1a7 100644 --- a/include/libcamera/internal/byte_stream_buffer.h +++ b/include/libcamera/internal/byte_stream_buffer.h @@ -11,7 +11,8 @@ #include #include -#include +#include + #include namespace libcamera { diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index e133ebf4..7bc54061 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -11,7 +11,8 @@ #include #include -#include +#include + #include #include #include diff --git a/include/libcamera/internal/file.h b/include/libcamera/internal/file.h index f0b313a5..44621ceb 100644 --- a/include/libcamera/internal/file.h +++ b/include/libcamera/internal/file.h @@ -11,7 +11,8 @@ #include #include -#include +#include + #include namespace libcamera { diff --git a/include/libcamera/internal/log.h b/include/libcamera/internal/log.h index 9c2beab6..82e55a62 100644 --- a/include/libcamera/internal/log.h +++ b/include/libcamera/internal/log.h @@ -10,8 +10,7 @@ #include #include -#include - +#include #include namespace libcamera { diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h index 1c82c279..2f5d33e1 100644 --- a/include/libcamera/internal/media_object.h +++ b/include/libcamera/internal/media_object.h @@ -12,7 +12,7 @@ #include -#include +#include namespace libcamera { diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 31dadf28..8beb6b76 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -15,7 +15,8 @@ #include #include -#include +#include + #include #include #include diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index d2b9ca55..d07dd6b4 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -11,7 +11,8 @@ #include #include -#include +#include + #include #include "libcamera/internal/formats.h" diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 7938343b..227d015e 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -16,8 +16,9 @@ #include +#include + #include -#include #include #include #include diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 4ac864b7..21a43388 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -5,7 +5,6 @@ libcamera_public_headers = files([ 'buffer.h', 'camera.h', 'camera_manager.h', - 'class.h', 'compiler.h', 'controls.h', 'file_descriptor.h', diff --git a/include/libcamera/request.h b/include/libcamera/request.h index 5596901d..00c646fe 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -13,7 +13,8 @@ #include #include -#include +#include + #include #include -- cgit v1.2.1