From patchwork Tue Apr 7 15:34:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 26461 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 40C8EC3305 for ; Tue, 7 Apr 2026 15:35:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4866262E09; Tue, 7 Apr 2026 17:35:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BY/0tMOm"; 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 A7D2462DF5 for ; Tue, 7 Apr 2026 17:34:57 +0200 (CEST) Received: from killaraus.ideasonboard.com (2001-14ba-703d-e500--2a1.rev.dnainternet.fi [IPv6:2001:14ba:703d:e500::2a1]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 2907278E for ; Tue, 7 Apr 2026 17:33:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775576010; bh=EfQ3ejPh+as/ini3dHIUSM0q8G1dLsiYvXruH2QZn3U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BY/0tMOmMdi0sBfQr8jMvmywFybUOscxJSIBJlJ2D75C7LZIpvggG3OLU2luBjKbf 2bp9SvDwfvjvG3L0+vYTQNKGkqijf3fawLoX2hIHvjD5VkM0c1RecwPD/OLqNEb+Ip 9HPSIcgGHLUP5JxzCWzhssJXraPi7vB6os/Yr0j8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 21/42] libcamera: value_node: Rework templates to prepare for mutable views Date: Tue, 7 Apr 2026 18:34:06 +0300 Message-ID: <20260407153427.1825999-22-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260407153427.1825999-1-laurent.pinchart@ideasonboard.com> References: <20260407153427.1825999-1-laurent.pinchart@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" ValueNode provides adapter classes to expose the object as an iteratable list or dictionary. The Iterator and Adapter classes hardcode the assumption that the ValueNode is const. To prepare for mutable views, move the const specifier to the top-level DictAdapter and ListAdapter class templates. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze --- include/libcamera/internal/value_node.h | 54 ++++++++++++++++--------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/include/libcamera/internal/value_node.h b/include/libcamera/internal/value_node.h index a7f916e22bc8..f8d0329f7670 100644 --- a/include/libcamera/internal/value_node.h +++ b/include/libcamera/internal/value_node.h @@ -38,14 +38,14 @@ private: public: #ifndef __DOXYGEN__ - template + template class Iterator { public: using difference_type = std::ptrdiff_t; using iterator_category = std::forward_iterator_tag; - Iterator(typename ValueContainer::const_iterator it) + Iterator(ContainerIterator it) : it_(it) { } @@ -74,14 +74,14 @@ public: } protected: - ValueContainer::const_iterator it_; + ContainerIterator it_; }; - template + template class Adapter { public: - Adapter(const ValueContainer &container) + Adapter(Container &container) : container_(container) { } @@ -97,47 +97,63 @@ public: } protected: - const ValueContainer &container_; + Container &container_; }; - class ListIterator : public Iterator + template + class ListIterator : public Iterator, + ContainerIterator> { - public: - using value_type = const ValueNode &; - using pointer = const ValueNode *; - using reference = value_type; + private: + using Base = Iterator, + ContainerIterator>; - value_type operator*() const + public: + using value_type = Value; + using pointer = value_type *; + using reference = value_type &; + + reference operator*() const { - return *it_->value.get(); + return *Base::it_->value.get(); } pointer operator->() const { - return it_->value.get(); + return Base::it_->value.get(); } }; - class DictIterator : public Iterator + template + class DictIterator : public Iterator, + ContainerIterator> { + private: + using Base = Iterator, + ContainerIterator>; + public: - using value_type = std::pair; + using value_type = std::pair; using pointer = value_type *; using reference = value_type &; value_type operator*() const { - return { it_->key, *it_->value.get() }; + return { Base::it_->key, *Base::it_->value.get() }; } }; - class DictAdapter : public Adapter + class DictAdapter : public Adapter, + const ValueContainer> { public: using key_type = std::string; }; - class ListAdapter : public Adapter + class ListAdapter : public Adapter, + const ValueContainer> { }; #endif /* __DOXYGEN__ */