{"id":11266,"url":"https://patchwork.libcamera.org/api/patches/11266/?format=json","web_url":"https://patchwork.libcamera.org/patch/11266/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210212133056.873230-7-kieran.bingham@ideasonboard.com>","date":"2021-02-12T13:30:55","name":"[libcamera-devel,v3,6/7] libcamera: Utilise LIBCAMERA_DISABLE_COPY","commit_ref":"640f48d60399fe63f549f6cb5fa8623a6b6b2810","pull_url":null,"state":"accepted","archived":false,"hash":"6867b7759e97c568999b63732ec8e85dab450680","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11266/mbox/","series":[{"id":1685,"url":"https://patchwork.libcamera.org/api/series/1685/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1685","date":"2021-02-12T13:30:49","name":"Delete Copy-Move-Assign","version":3,"mbox":"https://patchwork.libcamera.org/series/1685/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11266/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11266/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6D081BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Feb 2021 13:31:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0165B6379B;\n\tFri, 12 Feb 2021 14:31:07 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E50CF6378A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Feb 2021 14:31:01 +0100 (CET)","from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82AA4185F;\n\tFri, 12 Feb 2021 14:31:01 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"isxgSO7h\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1613136661;\n\tbh=bHrDcdHwPn3DBI/v4BqoaPsO4GwL5tMYwXlu+26O0aQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=isxgSO7h9pt6Ye2h1RNGKZeGmIzS9HNOplPjyeDf6pULaAQyYsEvLqUfuxcE+YQgC\n\tY3oj0aUh5QlnyM9rhG2ScXlQELl2YHkoCojTB183tTUvZVMSdKstYCiyKM/HelJx6F\n\tqbKHzQWOJS7g6JZfHUSY/bAgYO+dpfkoJbEcerFE=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","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\n\tLIBCAMERA_DISABLE_COPY","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Replace existing use cases where the copy constructor and copy\nassignment operator are deleted with the LIBCAMERA_DISABLE_COPY\nstatement\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/camera.h                      | 5 ++---\n include/libcamera/camera_manager.h              | 4 ++--\n include/libcamera/framebuffer_allocator.h       | 7 ++++---\n include/libcamera/internal/byte_stream_buffer.h | 4 ++--\n include/libcamera/internal/camera_sensor.h      | 6 +++---\n include/libcamera/internal/file.h               | 6 +++---\n include/libcamera/internal/log.h                | 6 +++++-\n include/libcamera/internal/pipeline_handler.h   | 4 ++--\n include/libcamera/internal/v4l2_subdevice.h     | 5 +++--\n include/libcamera/internal/v4l2_videodevice.h   | 6 +++---\n include/libcamera/request.h                     | 5 +++--\n 11 files changed, 32 insertions(+), 26 deletions(-)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex cff9f46e801b..bd81fb54502e 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -81,9 +81,6 @@ public:\n \t\t\t\t\t      const std::string &id,\n \t\t\t\t\t      const std::set<Stream *> &streams);\n \n-\tCamera(const Camera &) = delete;\n-\tCamera &operator=(const Camera &) = delete;\n-\n \tconst std::string &id() const;\n \n \tSignal<Request *, FrameBuffer *> bufferCompleted;\n@@ -107,6 +104,8 @@ public:\n \tint stop();\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(Camera)\n+\n \tCamera(PipelineHandler *pipe, const std::string &id,\n \t       const std::set<Stream *> &streams);\n \t~Camera();\ndiff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\nindex 7b8e533fadd6..35a59f0df4ca 100644\n--- a/include/libcamera/camera_manager.h\n+++ b/include/libcamera/camera_manager.h\n@@ -25,8 +25,6 @@ class CameraManager : public Object, public Extensible\n \tLIBCAMERA_DECLARE_PRIVATE(CameraManager)\n public:\n \tCameraManager();\n-\tCameraManager(const CameraManager &) = delete;\n-\tCameraManager &operator=(const CameraManager &) = delete;\n \t~CameraManager();\n \n \tint start();\n@@ -46,6 +44,8 @@ public:\n \tSignal<std::shared_ptr<Camera>> cameraRemoved;\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(CameraManager)\n+\n \tstatic const std::string version_;\n \tstatic CameraManager *self_;\n };\ndiff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h\nindex a96aaeae58ce..0c85631a1da2 100644\n--- a/include/libcamera/framebuffer_allocator.h\n+++ b/include/libcamera/framebuffer_allocator.h\n@@ -11,6 +11,8 @@\n #include <memory>\n #include <vector>\n \n+#include <libcamera/class.h>\n+\n namespace libcamera {\n \n class Camera;\n@@ -21,9 +23,6 @@ class FrameBufferAllocator\n {\n public:\n \tFrameBufferAllocator(std::shared_ptr<Camera> camera);\n-\tFrameBufferAllocator(const FrameBufferAllocator &) = delete;\n-\tFrameBufferAllocator &operator=(const FrameBufferAllocator &) = delete;\n-\n \t~FrameBufferAllocator();\n \n \tint allocate(Stream *stream);\n@@ -33,6 +32,8 @@ public:\n \tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers(Stream *stream) const;\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(FrameBufferAllocator)\n+\n \tstd::shared_ptr<Camera> camera_;\n \tstd::map<Stream *, std::vector<std::unique_ptr<FrameBuffer>>> buffers_;\n };\ndiff --git a/include/libcamera/internal/byte_stream_buffer.h b/include/libcamera/internal/byte_stream_buffer.h\nindex db59577dc332..866cb9b0b2a6 100644\n--- a/include/libcamera/internal/byte_stream_buffer.h\n+++ b/include/libcamera/internal/byte_stream_buffer.h\n@@ -11,6 +11,7 @@\n #include <stdint.h>\n #include <type_traits>\n \n+#include <libcamera/class.h>\n #include <libcamera/span.h>\n \n namespace libcamera {\n@@ -65,8 +66,7 @@ public:\n \t}\n \n private:\n-\tByteStreamBuffer(const ByteStreamBuffer &other) = delete;\n-\tByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete;\n+\tLIBCAMERA_DISABLE_COPY(ByteStreamBuffer)\n \n \tvoid setOverflow();\n \ndiff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex c8f81882a958..f22ffbfe9f97 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -11,6 +11,7 @@\n #include <string>\n #include <vector>\n \n+#include <libcamera/class.h>\n #include <libcamera/controls.h>\n #include <libcamera/geometry.h>\n \n@@ -45,9 +46,6 @@ public:\n \texplicit CameraSensor(const MediaEntity *entity);\n \t~CameraSensor();\n \n-\tCameraSensor(const CameraSensor &) = delete;\n-\tCameraSensor &operator=(const CameraSensor &) = delete;\n-\n \tint init();\n \n \tconst std::string &model() const { return model_; }\n@@ -74,6 +72,8 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(CameraSensor)\n+\n \tint generateId();\n \tint validateSensorDriver();\n \tvoid initVimcDefaultProperties();\ndiff --git a/include/libcamera/internal/file.h b/include/libcamera/internal/file.h\nindex 9b6d011f5e9d..f0b313a5faae 100644\n--- a/include/libcamera/internal/file.h\n+++ b/include/libcamera/internal/file.h\n@@ -11,6 +11,7 @@\n #include <string>\n #include <sys/types.h>\n \n+#include <libcamera/class.h>\n #include <libcamera/span.h>\n \n namespace libcamera {\n@@ -34,9 +35,6 @@ public:\n \tFile();\n \t~File();\n \n-\tFile(const File &) = delete;\n-\tFile &operator=(const File &) = delete;\n-\n \tconst std::string &fileName() const { return name_; }\n \tvoid setFileName(const std::string &name);\n \tbool exists() const;\n@@ -62,6 +60,8 @@ public:\n \tstatic bool exists(const std::string &name);\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(File)\n+\n \tvoid unmapAll();\n \n \tstd::string name_;\ndiff --git a/include/libcamera/internal/log.h b/include/libcamera/internal/log.h\nindex 4b10087a4718..e76ae913c857 100644\n--- a/include/libcamera/internal/log.h\n+++ b/include/libcamera/internal/log.h\n@@ -10,6 +10,8 @@\n #include <chrono>\n #include <sstream>\n \n+#include <libcamera/class.h>\n+\n #include \"libcamera/internal/utils.h\"\n \n namespace libcamera {\n@@ -57,7 +59,7 @@ public:\n \t\t   LogSeverity severity);\n \tLogMessage(const char *fileName, unsigned int line,\n \t\t   const LogCategory &category, LogSeverity severity);\n-\tLogMessage(const LogMessage &) = delete;\n+\n \tLogMessage(LogMessage &&);\n \t~LogMessage();\n \n@@ -70,6 +72,8 @@ public:\n \tconst std::string msg() const { return msgStream_.str(); }\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(LogMessage)\n+\n \tvoid init(const char *fileName, unsigned int line);\n \n \tstd::ostringstream msgStream_;\ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex 0748f8634608..d81c9b85f107 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -15,6 +15,7 @@\n #include <sys/types.h>\n #include <vector>\n \n+#include <libcamera/class.h>\n #include <libcamera/controls.h>\n #include <libcamera/object.h>\n #include <libcamera/stream.h>\n@@ -49,8 +50,7 @@ public:\n \tstd::unique_ptr<IPAProxy> ipa_;\n \n private:\n-\tCameraData(const CameraData &) = delete;\n-\tCameraData &operator=(const CameraData &) = delete;\n+\tLIBCAMERA_DISABLE_COPY(CameraData)\n };\n \n class PipelineHandler : public std::enable_shared_from_this<PipelineHandler>,\ndiff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex eb25fa2fd01b..d2b9ca55439e 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -11,6 +11,7 @@\n #include <string>\n #include <vector>\n \n+#include <libcamera/class.h>\n #include <libcamera/geometry.h>\n \n #include \"libcamera/internal/formats.h\"\n@@ -41,8 +42,6 @@ public:\n \t};\n \n \texplicit V4L2Subdevice(const MediaEntity *entity);\n-\tV4L2Subdevice(const V4L2Subdevice &) = delete;\n-\tV4L2Subdevice &operator=(const V4L2Subdevice &) = delete;\n \t~V4L2Subdevice();\n \n \tint open();\n@@ -68,6 +67,8 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(V4L2Subdevice)\n+\n \tstd::vector<unsigned int> enumPadCodes(unsigned int pad);\n \tstd::vector<SizeRange> enumPadSizes(unsigned int pad,\n \t\t\t\t\t    unsigned int code);\ndiff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 626dfbcd6113..7938343bba8d 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -17,6 +17,7 @@\n #include <linux/videodev2.h>\n \n #include <libcamera/buffer.h>\n+#include <libcamera/class.h>\n #include <libcamera/geometry.h>\n #include <libcamera/pixel_format.h>\n #include <libcamera/signal.h>\n@@ -175,11 +176,8 @@ public:\n \n \texplicit V4L2VideoDevice(const std::string &deviceNode);\n \texplicit V4L2VideoDevice(const MediaEntity *entity);\n-\tV4L2VideoDevice(const V4L2VideoDevice &) = delete;\n \t~V4L2VideoDevice();\n \n-\tV4L2VideoDevice &operator=(const V4L2VideoDevice &) = delete;\n-\n \tint open();\n \tint open(int handle, enum v4l2_buf_type type);\n \tvoid close();\n@@ -219,6 +217,8 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(V4L2VideoDevice)\n+\n \tint getFormatMeta(V4L2DeviceFormat *format);\n \tint trySetFormatMeta(V4L2DeviceFormat *format, bool set);\n \ndiff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex 655b1324bae8..6e5aad5f6b75 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -12,6 +12,7 @@\n #include <stdint.h>\n #include <unordered_set>\n \n+#include <libcamera/class.h>\n #include <libcamera/controls.h>\n #include <libcamera/signal.h>\n \n@@ -39,8 +40,6 @@ public:\n \tusing BufferMap = std::map<const Stream *, FrameBuffer *>;\n \n \tRequest(Camera *camera, uint64_t cookie = 0);\n-\tRequest(const Request &) = delete;\n-\tRequest &operator=(const Request &) = delete;\n \t~Request();\n \n \tvoid reuse(ReuseFlag flags = Default);\n@@ -57,6 +56,8 @@ public:\n \tbool hasPendingBuffers() const { return !pending_.empty(); }\n \n private:\n+\tLIBCAMERA_DISABLE_COPY(Request)\n+\n \tfriend class PipelineHandler;\n \n \tvoid complete();\n","prefixes":["libcamera-devel","v3","6/7"]}