From 1473add188f7a11fb8f5e17d21659a3b30a7063f Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Mon, 8 Feb 2021 14:30:31 +0000 Subject: libcamera: Move extensible to class The Extensible concept is a generic Class helper. To prepare for further class helper additions, move the specific extensible implementation and header to a more generic class header and source. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- include/libcamera/camera.h | 2 +- include/libcamera/camera_manager.h | 2 +- include/libcamera/class.h | 87 ++++++++++++++++++++++++++++++++++++++ include/libcamera/extensible.h | 87 -------------------------------------- include/libcamera/meson.build | 2 +- 5 files changed, 90 insertions(+), 90 deletions(-) create mode 100644 include/libcamera/class.h delete mode 100644 include/libcamera/extensible.h (limited to 'include') diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index f94f8599..cff9f46e 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -12,8 +12,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 8c8830e7..7b8e533f 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/include/libcamera/class.h b/include/libcamera/class.h new file mode 100644 index 00000000..cb278e58 --- /dev/null +++ b/include/libcamera/class.h @@ -0,0 +1,87 @@ +/* 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_DECLARE_PRIVATE(klass) \ +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(klass) +#define LIBCAMERA_DECLARE_PUBLIC(klass) +#define LIBCAMERA_D_PTR(klass) +#define LIBCAMERA_O_PTR(klass) +#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/extensible.h b/include/libcamera/extensible.h deleted file mode 100644 index 3f25a47c..00000000 --- a/include/libcamera/extensible.h +++ /dev/null @@ -1,87 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2020, Google Inc. - * - * extensible.h - Utilities to create extensible public classes with stable ABIs - */ -#ifndef __LIBCAMERA_EXTENSIBLE_H__ -#define __LIBCAMERA_EXTENSIBLE_H__ - -#include - -namespace libcamera { - -#ifndef __DOXYGEN__ -#define LIBCAMERA_DECLARE_PRIVATE(klass) \ -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(klass) -#define LIBCAMERA_DECLARE_PUBLIC(klass) -#define LIBCAMERA_D_PTR(klass) -#define LIBCAMERA_O_PTR(klass) -#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_EXTENSIBLE_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index eb787d44..c7b8ee8e 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -5,9 +5,9 @@ libcamera_public_headers = files([ 'buffer.h', 'camera.h', 'camera_manager.h', + 'class.h', 'compiler.h', 'controls.h', - 'extensible.h', 'file_descriptor.h', 'framebuffer_allocator.h', 'geometry.h', -- cgit v1.2.1