From patchwork Sat Feb 29 16:42:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2931 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B7A4A62796 for ; Sat, 29 Feb 2020 17:43:26 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5289C33E for ; Sat, 29 Feb 2020 17:43:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582994606; bh=Ju4ChpgLD5KCr++ioggZpJWGE95fy+RCeo4LCssiYbY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=U0J6T09iDx+JZihNPoDWE877XtnjrO1egnRSr94O+WWEbPbKtF+/g/VJG1ZX5RClX wTu4rSIUxb1w+7ybvbU8M2pgZcVtw/lBkBM0OMf6Wy56qV/DzEehVnucmpbEl6ebp8 A4s+2NpoC8d68p0KFft1SnjNGWxQAyrhIzQe2yeI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 29 Feb 2020 18:42:36 +0200 Message-Id: <20200229164254.23604-14-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200229164254.23604-1-laurent.pinchart@ideasonboard.com> References: <20200229164254.23604-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 13/31] libcamera: controls: Move ControlValue constructor to controls.h 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: , X-List-Received-Date: Sat, 29 Feb 2020 16:43:31 -0000 To avoid defining all specializations of the ControlValue constructor manually, move the definition of those functions to controls.h. The default constructor is still kept in controls.cpp. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 10 +++++++--- src/libcamera/controls.cpp | 27 +++------------------------ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 39e240438861..dfe69916cd64 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -55,9 +55,13 @@ class ControlValue { public: ControlValue(); - ControlValue(bool value); - ControlValue(int32_t value); - ControlValue(int64_t value); + + template + ControlValue(T value) + : type_(details::control_type>::value) + { + *reinterpret_cast(&bool_) = value; + } ControlType type() const { return type_; } bool isNone() const { return type_ == ControlTypeNone; } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index f3d79785e6a8..5cc8ce2199d0 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -74,31 +74,10 @@ ControlValue::ControlValue() } /** - * \brief Construct a Boolean ControlValue - * \param[in] value Boolean value to store + * \fn template T ControlValue::ControlValue(T value) + * \brief Construct a ControlValue of type T + * \param[in] value Initial value */ -ControlValue::ControlValue(bool value) - : type_(ControlTypeBool), bool_(value) -{ -} - -/** - * \brief Construct an integer ControlValue - * \param[in] value Integer value to store - */ -ControlValue::ControlValue(int32_t value) - : type_(ControlTypeInteger32), integer32_(value) -{ -} - -/** - * \brief Construct a 64 bit integer ControlValue - * \param[in] value Integer value to store - */ -ControlValue::ControlValue(int64_t value) - : type_(ControlTypeInteger64), integer64_(value) -{ -} /** * \fn ControlValue::type()