From patchwork Thu Feb 11 13:34:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11243 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 15297BD16C for ; Thu, 11 Feb 2021 13:34:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7CB063753; Thu, 11 Feb 2021 14:34:52 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DbkFrdMt"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6862361661 for ; Thu, 11 Feb 2021 14:34:49 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 094611210; Thu, 11 Feb 2021 14:34:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613050489; bh=BDHCZ/d888fBgFBOFsqwRGAykJ9IxyQAZmcw03bD4v8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbkFrdMt9LdQjOgh/+u7omXGHppDHRZY4wKoRv8qYc6xtjccn0pYl3hJQV+tWQPpu tczSqEg7S4APqF0B4q0mvZmLJ2/vdtKb9CjX2biYZaHYKCvx0c3Pu93z6Tvot5UD+T DrW7fVgy4wgzc0M4Nri+0GJG+bgKIvGXS9VdRzAo= From: Kieran Bingham To: libcamera devel Date: Thu, 11 Feb 2021 13:34:43 +0000 Message-Id: <20210211133444.764808-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211133444.764808-1-kieran.bingham@ideasonboard.com> References: <20210211133444.764808-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/6] libcamera: Utilise LIBCAMERA_DISABLE_COPY X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace existing use cases where the copy constructor and copy assignment operator are deleted with the LIBCAMERA_DISABLE_COPY statement Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/camera.h | 6 +++--- include/libcamera/camera_manager.h | 4 ++-- include/libcamera/controls.h | 7 +++---- include/libcamera/framebuffer_allocator.h | 7 ++++--- include/libcamera/internal/byte_stream_buffer.h | 4 ++-- include/libcamera/internal/camera_sensor.h | 6 +++--- include/libcamera/internal/file.h | 6 +++--- include/libcamera/internal/log.h | 6 +++++- include/libcamera/internal/pipeline_handler.h | 4 ++-- include/libcamera/internal/v4l2_subdevice.h | 5 +++-- include/libcamera/internal/v4l2_videodevice.h | 6 +++--- include/libcamera/request.h | 5 +++-- 12 files changed, 36 insertions(+), 30 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index cff9f46e801b..568740a37778 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -81,9 +81,6 @@ public: const std::string &id, const std::set &streams); - Camera(const Camera &) = delete; - Camera &operator=(const Camera &) = delete; - const std::string &id() const; Signal bufferCompleted; @@ -109,6 +106,9 @@ public: private: Camera(PipelineHandler *pipe, const std::string &id, const std::set &streams); + + LIBCAMERA_DISABLE_COPY(Camera); + ~Camera(); friend class PipelineHandler; diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 7b8e533fadd6..467cfd0ac4ac 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -25,8 +25,6 @@ class CameraManager : public Object, public Extensible LIBCAMERA_DECLARE_PRIVATE(CameraManager) public: CameraManager(); - CameraManager(const CameraManager &) = delete; - CameraManager &operator=(const CameraManager &) = delete; ~CameraManager(); int start(); @@ -46,6 +44,8 @@ public: Signal> cameraRemoved; private: + LIBCAMERA_DISABLE_COPY(CameraManager); + static const std::string version_; static CameraManager *self_; }; diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3b7f3347761e..a5c9bda28661 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -220,8 +221,7 @@ public: ControlType type() const { return type_; } private: - ControlId &operator=(const ControlId &) = delete; - ControlId(const ControlId &) = delete; + LIBCAMERA_DISABLE_COPY(ControlId); unsigned int id_; std::string name_; @@ -260,8 +260,7 @@ public: } private: - Control(const Control &) = delete; - Control &operator=(const Control &) = delete; + LIBCAMERA_DISABLE_COPY(Control); }; class ControlInfo diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h index a96aaeae58ce..9e42de280c98 100644 --- a/include/libcamera/framebuffer_allocator.h +++ b/include/libcamera/framebuffer_allocator.h @@ -11,6 +11,8 @@ #include #include +#include + namespace libcamera { class Camera; @@ -21,9 +23,6 @@ class FrameBufferAllocator { public: FrameBufferAllocator(std::shared_ptr camera); - FrameBufferAllocator(const FrameBufferAllocator &) = delete; - FrameBufferAllocator &operator=(const FrameBufferAllocator &) = delete; - ~FrameBufferAllocator(); int allocate(Stream *stream); @@ -33,6 +32,8 @@ public: const std::vector> &buffers(Stream *stream) const; private: + LIBCAMERA_DISABLE_COPY(FrameBufferAllocator); + std::shared_ptr camera_; std::map>> buffers_; }; diff --git a/include/libcamera/internal/byte_stream_buffer.h b/include/libcamera/internal/byte_stream_buffer.h index db59577dc332..ec8b0b2ada86 100644 --- a/include/libcamera/internal/byte_stream_buffer.h +++ b/include/libcamera/internal/byte_stream_buffer.h @@ -11,6 +11,7 @@ #include #include +#include #include namespace libcamera { @@ -65,8 +66,7 @@ public: } private: - ByteStreamBuffer(const ByteStreamBuffer &other) = delete; - ByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete; + LIBCAMERA_DISABLE_COPY(ByteStreamBuffer); void setOverflow(); diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index c8f81882a958..9d26bd24a321 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -45,9 +46,6 @@ public: explicit CameraSensor(const MediaEntity *entity); ~CameraSensor(); - CameraSensor(const CameraSensor &) = delete; - CameraSensor &operator=(const CameraSensor &) = delete; - int init(); const std::string &model() const { return model_; } @@ -74,6 +72,8 @@ protected: std::string logPrefix() const override; private: + LIBCAMERA_DISABLE_COPY(CameraSensor); + int generateId(); int validateSensorDriver(); void initVimcDefaultProperties(); diff --git a/include/libcamera/internal/file.h b/include/libcamera/internal/file.h index 9b6d011f5e9d..2f75aaf00dab 100644 --- a/include/libcamera/internal/file.h +++ b/include/libcamera/internal/file.h @@ -11,6 +11,7 @@ #include #include +#include #include namespace libcamera { @@ -34,9 +35,6 @@ public: File(); ~File(); - File(const File &) = delete; - File &operator=(const File &) = delete; - const std::string &fileName() const { return name_; } void setFileName(const std::string &name); bool exists() const; @@ -62,6 +60,8 @@ public: static bool exists(const std::string &name); private: + LIBCAMERA_DISABLE_COPY(File); + void unmapAll(); std::string name_; diff --git a/include/libcamera/internal/log.h b/include/libcamera/internal/log.h index 4b10087a4718..5c44d623797a 100644 --- a/include/libcamera/internal/log.h +++ b/include/libcamera/internal/log.h @@ -10,6 +10,8 @@ #include #include +#include + #include "libcamera/internal/utils.h" namespace libcamera { @@ -57,7 +59,7 @@ public: LogSeverity severity); LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity); - LogMessage(const LogMessage &) = delete; + LogMessage(LogMessage &&); ~LogMessage(); @@ -70,6 +72,8 @@ public: const std::string msg() const { return msgStream_.str(); } private: + LIBCAMERA_DISABLE_COPY(LogMessage); + void init(const char *fileName, unsigned int line); std::ostringstream msgStream_; diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 0748f8634608..d5913eae88ca 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -49,8 +50,7 @@ public: std::unique_ptr ipa_; private: - CameraData(const CameraData &) = delete; - CameraData &operator=(const CameraData &) = delete; + LIBCAMERA_DISABLE_COPY(CameraData); }; class PipelineHandler : public std::enable_shared_from_this, diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index eb25fa2fd01b..f983ae6302bb 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -11,6 +11,7 @@ #include #include +#include #include #include "libcamera/internal/formats.h" @@ -41,8 +42,6 @@ public: }; explicit V4L2Subdevice(const MediaEntity *entity); - V4L2Subdevice(const V4L2Subdevice &) = delete; - V4L2Subdevice &operator=(const V4L2Subdevice &) = delete; ~V4L2Subdevice(); int open(); @@ -68,6 +67,8 @@ protected: std::string logPrefix() const override; private: + LIBCAMERA_DISABLE_COPY(V4L2Subdevice); + std::vector enumPadCodes(unsigned int pad); std::vector enumPadSizes(unsigned int pad, unsigned int code); diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 626dfbcd6113..f8da608603ef 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -175,11 +176,8 @@ public: explicit V4L2VideoDevice(const std::string &deviceNode); explicit V4L2VideoDevice(const MediaEntity *entity); - V4L2VideoDevice(const V4L2VideoDevice &) = delete; ~V4L2VideoDevice(); - V4L2VideoDevice &operator=(const V4L2VideoDevice &) = delete; - int open(); int open(int handle, enum v4l2_buf_type type); void close(); @@ -219,6 +217,8 @@ protected: std::string logPrefix() const override; private: + LIBCAMERA_DISABLE_COPY(V4L2VideoDevice); + int getFormatMeta(V4L2DeviceFormat *format); int trySetFormatMeta(V4L2DeviceFormat *format, bool set); diff --git a/include/libcamera/request.h b/include/libcamera/request.h index 655b1324bae8..3354ae9083f1 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -39,8 +40,6 @@ public: using BufferMap = std::map; Request(Camera *camera, uint64_t cookie = 0); - Request(const Request &) = delete; - Request &operator=(const Request &) = delete; ~Request(); void reuse(ReuseFlag flags = Default); @@ -57,6 +56,8 @@ public: bool hasPendingBuffers() const { return !pending_.empty(); } private: + LIBCAMERA_DISABLE_COPY(Request); + friend class PipelineHandler; void complete();