From patchwork Fri Dec 18 16:47:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10687 X-Patchwork-Delegate: jacopo@jmondi.org 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 91B39C0F1A for ; Fri, 18 Dec 2020 16:47:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40083615D2; Fri, 18 Dec 2020 17:47:57 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B08E661597 for ; Fri, 18 Dec 2020 17:47:51 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 7EA0720008 for ; Fri, 18 Dec 2020 16:47:51 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:51 +0100 Message-Id: <20201218164754.81422-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/9] libcamera: controls: List-initialize ControlList 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" Provide an additional constructor to the ControlList class to allow the construction of instances of the class with the usage of an std::intializer_list<> of ControlId and an associated ControlValue. The new constructor allows to intialize a ControlList instance at construction time, allowing the declaration of populated ControlList instances. Signed-off-by: Jacopo Mondi --- include/libcamera/controls.h | 2 ++ src/libcamera/controls.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3634dc431618..4df6615a3c7b 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -348,9 +348,11 @@ class ControlList { private: using ControlListMap = std::unordered_map; + using ControlsMap = std::unordered_map; public: ControlList(); + ControlList(std::initializer_list controls); ControlList(const ControlIdMap &idmap, ControlValidator *validator = nullptr); ControlList(const ControlInfoMap &infoMap, ControlValidator *validator = nullptr); diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index c58ed3946f3b..7650057dde7d 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -797,6 +797,17 @@ ControlList::ControlList() { } +/** + * \brief Construct a ControlList with a list of values + * \param[in] controls The controls and associated values to initialize the list with + */ +ControlList::ControlList(std::initializer_list controls) + : ControlList() +{ + for (const auto &ctrl : controls) + set(ctrl.first->id(), ctrl.second); +} + /** * \brief Construct a ControlList with an optional control validator * \param[in] idmap The ControlId map for the control list target object