[{"id":16842,"web_url":"https://patchwork.libcamera.org/comment/16842/","msgid":"<YJXcEhaX2WULNSL/@pendragon.ideasonboard.com>","date":"2021-05-08T00:32:18","subject":"Re: [libcamera-devel] [PATCH v6 4/5] ipa: raspberrypi: Add\n\tOverwrite method to RPiController::Metadata","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Fri, May 07, 2021 at 09:40:41AM +0100, Naushir Patuck wrote:\n> Add a new Overwrite method to the Metadata class. This will overwrite\n> all key/value pairs in a destination object that have an identical key\n> in the source metadata object. Once complete, the source Metadata\n> object will be empty.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/controller/metadata.hpp | 20 ++++++++++++++++++++\n>  1 file changed, 20 insertions(+)\n> \n> diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp\n> index 319f2320fc70..ac64f17f617c 100644\n> --- a/src/ipa/raspberrypi/controller/metadata.hpp\n> +++ b/src/ipa/raspberrypi/controller/metadata.hpp\n> @@ -75,6 +75,26 @@ public:\n>  \t\treturn *this;\n>  \t}\n>  \n> +\tvoid Overwrite(Metadata &other)\n\nI may have used an rvalue reference to force the caller to acknowledge\nthat other will be cleared, but that doesn't matter much.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t{\n> +\t\tstd::lock_guard<std::mutex> lock(mutex_);\n> +\t\tstd::lock_guard<std::mutex> other_lock(other.mutex_);\n> +\n> +\t\t/*\n> +\t\t * Overwrite any contents of data_ with identical keys from\n> +\t\t * other.data_. Any keys from other.data_ that are not preset in\n> +\t\t * data_ will simply be copied across.\n> +\t\t *\n> +\t\t * The reason for the seemingly illogical steps below is because\n> +\t\t * std::map::merge() does not overwrite existing keys.\n> +\t\t */\n> +\t\tother.data_.merge(data_);\n> +\t\tstd::swap(data_, other.data_);\n> +\n> +\t\t/* Render the other object as empty now! */\n> +\t\tother.data_.clear();\n> +\t}\n> +\n>  \ttemplate<typename T>\n>  \tT *GetLocked(std::string const &tag)\n>  \t{","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 8671CBF831\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  8 May 2021 00:32:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 112766891B;\n\tSat,  8 May 2021 02:32:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DB88968901\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  8 May 2021 02:32:24 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D1703D7;\n\tSat,  8 May 2021 02:32:24 +0200 (CEST)"],"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=\"RWitVz7i\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1620433944;\n\tbh=vzs8MZijvX/YmrPiMO1+s6E2JzAC8ks7NpbLIyG47nQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RWitVz7iXJGJati9AYbQ7M4mfsuQHZ6f/TFXULT2C0fNEpqTDlGq8L+us4mKecRue\n\tAPOicy8/x2Hl1rBRnxvrNA9vsC+cE94q0yDmC2uLV4tnaQAKs88ayJqcF6gi0/Py94\n\t/Il06i0+GtHyst8ryr0OHz3WQxNAJrfFnloPuRCo=","Date":"Sat, 8 May 2021 03:32:18 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YJXcEhaX2WULNSL/@pendragon.ideasonboard.com>","References":"<20210507084042.31879-1-naush@raspberrypi.com>\n\t<20210507084042.31879-5-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210507084042.31879-5-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v6 4/5] ipa: raspberrypi: Add\n\tOverwrite method to RPiController::Metadata","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>","Cc":"libcamera-devel@lists.libcamera.org","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>"}}]