From patchwork Fri Feb 12 13:30:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11261 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 6D035BD160 for ; Fri, 12 Feb 2021 13:31:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7250F6378F; Fri, 12 Feb 2021 14:31:02 +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="RETBkWLJ"; 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 BA1106377B for ; Fri, 12 Feb 2021 14:31:00 +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 44923A49; Fri, 12 Feb 2021 14:31:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136660; bh=hPmHVJWF/Ti6I5gMrKHxGBvzmC8QPwpxb4RipQJjTyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RETBkWLJwr2kqM86D9BhlB/LWT44MWYWLDcJzxzlfMDTy5CQjMIoEAlsp68JpaPYN GFMfIz6GKG3/CadzMK+fox9eRGMs1yt47Wv4h+GbDD988MbIBcivRYR/+xuTEjbkIj uslWBRrA1D+7RE4CyA8w1f81jSfnFM9K4+q847RM= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:50 +0000 Message-Id: <20210212133056.873230-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/7] libcamera: Move extensible to class 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" 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/{extensible.h => class.h} | 8 ++++---- include/libcamera/meson.build | 2 +- src/libcamera/{extensible.cpp => class.cpp} | 11 +++++++---- src/libcamera/meson.build | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) rename include/libcamera/{extensible.h => class.h} (86%) rename src/libcamera/{extensible.cpp => class.cpp} (94%) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index f94f859988fe..cff9f46e801b 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 8c8830e7ff1d..7b8e533fadd6 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/extensible.h b/include/libcamera/class.h similarity index 86% rename from include/libcamera/extensible.h rename to include/libcamera/class.h index 3f25a47c5064..cb278e58204a 100644 --- a/include/libcamera/extensible.h +++ b/include/libcamera/class.h @@ -2,10 +2,10 @@ /* * Copyright (C) 2020, Google Inc. * - * extensible.h - Utilities to create extensible public classes with stable ABIs + * class.h - Utilities and helpers for classes */ -#ifndef __LIBCAMERA_EXTENSIBLE_H__ -#define __LIBCAMERA_EXTENSIBLE_H__ +#ifndef __LIBCAMERA_CLASS_H__ +#define __LIBCAMERA_CLASS_H__ #include @@ -84,4 +84,4 @@ private: } /* namespace libcamera */ -#endif /* __LIBCAMERA_EXTENSIBLE_H__ */ +#endif /* __LIBCAMERA_CLASS_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index eb787d44746a..c7b8ee8e5c94 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', diff --git a/src/libcamera/extensible.cpp b/src/libcamera/class.cpp similarity index 94% rename from src/libcamera/extensible.cpp rename to src/libcamera/class.cpp index 1dcb0bf1b12f..ce230be91e61 100644 --- a/src/libcamera/extensible.cpp +++ b/src/libcamera/class.cpp @@ -2,14 +2,17 @@ /* * Copyright (C) 2020, Google Inc. * - * extensible.cpp - Utilities to create extensible public classes with stable ABIs + * class.cpp - Utilities and helpers for classes */ -#include +#include /** - * \file extensible.h - * \brief Utilities to create extensible public classes with stable ABIs + * \file class.h + * \brief Utilities to help constructing class interfaces + * + * The extensible class can be inherited to create public classes with stable + * ABIs. */ namespace libcamera { diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index ebce19d90c1e..939f1189b169 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -9,6 +9,7 @@ libcamera_sources = files([ 'camera_controls.cpp', 'camera_manager.cpp', 'camera_sensor.cpp', + 'class.cpp', 'controls.cpp', 'control_serializer.cpp', 'control_validator.cpp', @@ -18,7 +19,6 @@ libcamera_sources = files([ 'event_dispatcher.cpp', 'event_dispatcher_poll.cpp', 'event_notifier.cpp', - 'extensible.cpp', 'file.cpp', 'file_descriptor.cpp', 'formats.cpp', From patchwork Fri Feb 12 13:30:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11262 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 67E9EBD160 for ; Fri, 12 Feb 2021 13:31:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EC59463792; Fri, 12 Feb 2021 14:31:02 +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="OLZL2ECc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EB35E63772 for ; Fri, 12 Feb 2021 14:31:00 +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 856101253; Fri, 12 Feb 2021 14:31:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136660; bh=zOj4Fv/7FwvtQV1PpQ4W0SUBsm9q+9nWisXGaTGQCX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLZL2ECcwdfhdZxIYExWP7+Hhy/6KYaYIkm+UKWq0K3vrlJt2WWp6ELvJ/jZhaC8f Zv+nebJAlovtKLeay8ushoN35CcULhbDQtun3cA6A6iMIl4VU8DFqjenmYN6Qs+T8h fg41fedjGAKfGtFAX1oxqLYe2vo6YRMKELSECmp8= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:51 +0000 Message-Id: <20210212133056.873230-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/7] libcamera: class: Provide move and copy disablers 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" It can be difficult to correctly parse the syntax for copy/move and the associated assignment operators. Provide helpers as syntactic sugar to facilitate disabling either the copy constructor, and copy assignment operator, and the move constructor and move assignment operator in a way which is explicit and clear. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/class.h | 18 +++++++++++++ src/libcamera/class.cpp | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/include/libcamera/class.h b/include/libcamera/class.h index cb278e58204a..920624d8e726 100644 --- a/include/libcamera/class.h +++ b/include/libcamera/class.h @@ -11,6 +11,24 @@ 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(klass) \ public: \ diff --git a/src/libcamera/class.cpp b/src/libcamera/class.cpp index ce230be91e61..c1db14197b4e 100644 --- a/src/libcamera/class.cpp +++ b/src/libcamera/class.cpp @@ -17,6 +17,63 @@ namespace libcamera { +/** + * \def LIBCAMERA_DISABLE_COPY + * \brief Disable copy construction and assignment of the \a klass + * \param klass The name of the class + * + * Example usage: + * \code{.cpp} + * class NonCopyable + * { + * public: + * NonCopyable(); + * ... + * + * private: + * LIBCAMERA_DISABLE_COPY(NonCopyable) + * }; + * \endcode + */ + +/** + * \def LIBCAMERA_DISABLE_MOVE + * \brief Disable move construction and assignment of the \a klass + * \param klass The name of the class + * + * Example usage: + * \code{.cpp} + * class NonMoveable + * { + * public: + * NonMoveable(); + * ... + * + * private: + * LIBCAMERA_DISABLE_MOVE(NonMoveable) + * }; + * \endcode + */ + +/** + * \def LIBCAMERA_DISABLE_COPY_AND_MOVE + * \brief Disable copy and move construction and assignment of the \a klass +* \param klass The name of the class + * + * Example usage: + * \code{.cpp} + * class NonCopyableNonMoveable + * { + * public: + * NonCopyableNonMoveable(); + * ... + * + * private: + * LIBCAMERA_DISABLE_COPY_AND_MOVE(NonCopyableNonMoveable) + * }; + * \endcode + */ + /** * \def LIBCAMERA_DECLARE_PRIVATE * \brief Declare private data for a public class From patchwork Fri Feb 12 13:30:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11263 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 CAEC0BD160 for ; Fri, 12 Feb 2021 13:31:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D97A63786; Fri, 12 Feb 2021 14:31:04 +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="XjFa0xk4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 214B56377B for ; Fri, 12 Feb 2021 14:31:01 +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 C0B611508; Fri, 12 Feb 2021 14:31:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136660; bh=hi76FhRNIqGfKZ1cz9+XkJLUF/rsE6a5k1IinjL/iCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjFa0xk4xX6vPtTA3loX4bBazlkJauoj77uOtmvI4TiZs1osiD59wDqZuUFIZFsod uMAPMzzHfH26M9XLNcqQkBOintb4dBYwAPgZBnV7lX9oQxRwaV9RNf55OVLI/ps3N3 l2C86VaHjsxKZYED2YjzR4/QG1/hFBDJGe3KadGo= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:52 +0000 Message-Id: <20210212133056.873230-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/7] libcamera: buffer: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE 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" Convert the existing copy, move and assignment operators to use the new macros. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- include/libcamera/buffer.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index a26c8927d37a..302fe3d3e86b 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace libcamera { @@ -43,12 +44,6 @@ public: FrameBuffer(const std::vector &planes, unsigned int cookie = 0); - FrameBuffer(const FrameBuffer &) = delete; - FrameBuffer(FrameBuffer &&) = delete; - - FrameBuffer &operator=(const FrameBuffer &) = delete; - FrameBuffer &operator=(FrameBuffer &&) = delete; - const std::vector &planes() const { return planes_; } Request *request() const { return request_; } @@ -57,7 +52,10 @@ public: unsigned int cookie() const { return cookie_; } void setCookie(unsigned int cookie) { cookie_ = cookie; } + private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer) + friend class Request; /* Needed to update request_. */ friend class V4L2VideoDevice; /* Needed to update metadata_. */ From patchwork Fri Feb 12 13:30:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11264 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 04813BD16C for ; Fri, 12 Feb 2021 13:31:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D920D63785; Fri, 12 Feb 2021 14:31:04 +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="S+IRGq3s"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6526763772 for ; Fri, 12 Feb 2021 14:31:01 +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 0D2C31540; Fri, 12 Feb 2021 14:31:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136661; bh=zb+6P1jPo6STlRX9YTnt+JJYz8sHeSHJsB9lYrNZm8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+IRGq3so1lm8EQ/T7TyNgoCAI30f8k0qnqJrxZpmJWIUGteKhr3bEXEW3t/9aICj RfMPHEnZL2BdCY9grcDTGxpfxWCno/OkMoxLdWifRcge1s2nAIhwGyMVj2Lu4onSn3 BIEX3ZSg53wiV2ab8xS9v6J+8o3LCtXuwMn1TPAA= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:53 +0000 Message-Id: <20210212133056.873230-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/7] libcamera: media_object: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE 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" Convert MediaLink, MediaPad, and MediaEntity to declare LIBCAMERA_DISABLE_COPY_AND_MOVE. These classes already deleted their copy constructor but not the assignment operator. They should also not be movable, so expand to fully disable both copying and moving. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/media_object.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h index 2b336961f98d..1c82c27928a8 100644 --- a/include/libcamera/internal/media_object.h +++ b/include/libcamera/internal/media_object.h @@ -12,6 +12,8 @@ #include +#include + namespace libcamera { class MediaDevice; @@ -47,11 +49,12 @@ public: int setEnabled(bool enable); private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink) + friend class MediaDevice; MediaLink(const struct media_v2_link *link, MediaPad *source, MediaPad *sink); - MediaLink(const MediaLink &) = delete; MediaPad *source_; MediaPad *sink_; @@ -69,10 +72,11 @@ public: void addLink(MediaLink *link); private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaPad) + friend class MediaDevice; MediaPad(const struct media_v2_pad *pad, MediaEntity *entity); - MediaPad(const MediaPad &) = delete; unsigned int index_; MediaEntity *entity_; @@ -99,11 +103,12 @@ public: int setDeviceNode(const std::string &deviceNode); private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity) + friend class MediaDevice; MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity, unsigned int major = 0, unsigned int minor = 0); - MediaEntity(const MediaEntity &) = delete; void addPad(MediaPad *pad); From patchwork Fri Feb 12 13:30:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11265 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 A6DACBD160 for ; Fri, 12 Feb 2021 13:31:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 748146379C; Fri, 12 Feb 2021 14:31:06 +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="HK4pMxDT"; 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 A0B376377B for ; Fri, 12 Feb 2021 14:31:01 +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 478391810; Fri, 12 Feb 2021 14:31:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136661; bh=1hKv8iCmzZsacu0636JZJAtvUt4JbL1REGbPeULZg2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HK4pMxDTELhdST5RZkMOtEQH3k/UVryVyxepckDrJiq0nkdnyWDkybCGoFx7vBVLP HicODMt6LdZBFJmbccxMcQRhSQZ8PKUvHzZxEh3gcNlxhZvbCZ6cTj+BvjY7UJI3IT amaE9vKU97qbF8PPXKMcNSgzLPRFwJLrZ/8CZzGo= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:54 +0000 Message-Id: <20210212133056.873230-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/7] libcamera: controls: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE 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" The ControlId and Control classes disable the copy constructor and assignment operator, but they should also prevent move construction and assignment. Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE to fully disable these functions. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/controls.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3b7f3347761e..1a5690a5ccbe 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_AND_MOVE(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_AND_MOVE(Control) }; class ControlInfo From patchwork Fri Feb 12 13:30:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11266 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 6D081BD160 for ; Fri, 12 Feb 2021 13:31:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0165B6379B; Fri, 12 Feb 2021 14:31:07 +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="isxgSO7h"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E50CF6378A for ; Fri, 12 Feb 2021 14:31:01 +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 82AA4185F; Fri, 12 Feb 2021 14:31:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136661; bh=bHrDcdHwPn3DBI/v4BqoaPsO4GwL5tMYwXlu+26O0aQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=isxgSO7h9pt6Ye2h1RNGKZeGmIzS9HNOplPjyeDf6pULaAQyYsEvLqUfuxcE+YQgC Y3oj0aUh5QlnyM9rhG2ScXlQELl2YHkoCojTB183tTUvZVMSdKstYCiyKM/HelJx6F qbKHzQWOJS7g6JZfHUSY/bAgYO+dpfkoJbEcerFE= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:55 +0000 Message-Id: <20210212133056.873230-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/7] 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 Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- include/libcamera/camera.h | 5 ++--- include/libcamera/camera_manager.h | 4 ++-- 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 +++-- 11 files changed, 32 insertions(+), 26 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index cff9f46e801b..bd81fb54502e 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; @@ -107,6 +104,8 @@ public: int stop(); private: + LIBCAMERA_DISABLE_COPY(Camera) + Camera(PipelineHandler *pipe, const std::string &id, const std::set &streams); ~Camera(); diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 7b8e533fadd6..35a59f0df4ca 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/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h index a96aaeae58ce..0c85631a1da2 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..866cb9b0b2a6 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..f22ffbfe9f97 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..f0b313a5faae 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..e76ae913c857 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..d81c9b85f107 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..d2b9ca55439e 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..7938343bba8d 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..6e5aad5f6b75 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(); From patchwork Fri Feb 12 13:30:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11267 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 D8CA7BD160 for ; Fri, 12 Feb 2021 13:31:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A6BDA6378E; Fri, 12 Feb 2021 14:31:07 +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="qWo4TboI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 303BF6378C for ; Fri, 12 Feb 2021 14:31:02 +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 C8F8118B7; Fri, 12 Feb 2021 14:31:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613136661; bh=lYER7QGNxRrkOAKs3CDEPvulHJ1wAhygdZmALp9pvAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qWo4TboIc9vsaOT871njk2NWZsrLzYL+StAv1Tcqx4XWDK4oUh1+4GlGBPEr/sbEB 9VlvfeY5/USSw8kmTR0uk4VMce0ISCv2xoGzH/IeW5LkVEC+YWZ1fALAIGdejHA6Nm YpBg8w8ynVpwYUjdFcu16xL1PiHrFfqTW4CkuCyA= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Feb 2021 13:30:56 +0000 Message-Id: <20210212133056.873230-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> References: <20210212133056.873230-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/7] libcamera: MappedBuffer: Disable copy and assignment 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" MappedBuffers have a custom move constructor and assignment operator to ensure that memory is not unmapped during object manipulation. Because of the user-defined move constructor, the implicitly-declared copy-constructor will already be deleted, however delete it explicitly to help readability of the code, and make it clear that the object can not be copied. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- include/libcamera/internal/buffer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/libcamera/internal/buffer.h b/include/libcamera/internal/buffer.h index b7b0173f93f5..9da1fbd12c27 100644 --- a/include/libcamera/internal/buffer.h +++ b/include/libcamera/internal/buffer.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -34,6 +35,9 @@ protected: int error_; std::vector maps_; + +private: + LIBCAMERA_DISABLE_COPY(MappedBuffer) }; class MappedFrameBuffer : public MappedBuffer