From patchwork Thu Sep 3 09:18:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 28183 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 E6AFFC3348 for ; Thu, 3 Sep 2026 09:18:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A8EC8685F0; Thu, 3 Sep 2026 11:18:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BFM7NYhn"; 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 4500D685DA for ; Thu, 3 Sep 2026 11:18:48 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2708823B9; Thu, 3 Sep 2026 11:17:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788427036; bh=ZLXAjLas2jfyeVmN5XjyZbjgQHju5RtIu3qfAN5iGJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFM7NYhnQO2X9YBXQnKRtQ3dRVLRysyZHHzxhKj+z0mZJimKdNY1788xIlrB1A2yM 8n3yxKIR7sOYpyV8ZVDVdEIPDgexnBX6LJoIBDo1Y9oBP4birD5oElhtHcyCCT3bx8 UZTKTtfnEyBaBwR2r/TMQEaTSy5Bd0MFx0dM8m5A= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Jacopo Mondi Subject: [PATCH v3 4/5] libcamera: controls: Implement `swap()` Date: Thu, 3 Sep 2026 11:18:42 +0200 Message-ID: <20260903091843.85548-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> References: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 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" Implement both free and member function `swap()` for `ControlValue`. The general `std::swap()` swaps two values by combining a move construction and two move assignments, but for `ControlValue` a simpler implementation can be provided by just swapping the members. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/controls.h | 13 +++++++++++++ src/libcamera/controls.cpp | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index aef17abe07..190a28970c 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -264,6 +264,19 @@ public: void reserve(ControlType type, bool isArray = false, std::size_t numElements = 1); + void swap(ControlValue &other) noexcept + { + std::swap(type_, other.type_); + std::swap(isArray_, other.isArray_); + std::swap(numElements_, other.numElements_); + std::swap(storage_, other.storage_); + } + + friend void swap(ControlValue &a, ControlValue &b) noexcept + { + a.swap(b); + } + private: ControlType type_; bool isArray_; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 588b609373..242072778b 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -413,6 +413,21 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen storage_.external = new uint8_t[newSize]; } +/** + * \fn ControlValue::swap(ControlValue &other) noexcept + * \brief Swap two control values + * + * This function swaps the contained value of \a this with that of \a other. + */ + +/** + * \fn ControlValue::swap(ControlValue &a, ControlValue &b) noexcept + * \brief Swap two control values + * + * This function swaps the contained value of \a a with that of \a b. + * \sa ControlValue::swap() + */ + /** * \class ControlId * \brief Control static metadata