From patchwork Fri May 7 08:40:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12225 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 9FF30BF831 for ; Fri, 7 May 2021 08:40:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 60DD968919; Fri, 7 May 2021 10:40:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="F0/KH1h0"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B84EB6890E for ; Fri, 7 May 2021 10:40:51 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id x5so8297152wrv.13 for ; Fri, 07 May 2021 01:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ToAhjL9XFdxjjye6nKRusCeRANLcN15gZaOodjy4LOI=; b=F0/KH1h0po9NP/XRRJplLAtS8OXJmpfbGBtjJkaB8hq85vvGMwKwAnrVtiZIcuOFNh XcktEcDnQZzfI1Rcm8uQAXLeF7Uzpxi4ohaIE3JAKHUFott0QrDu6O7cbALBcVJ2QuKc 7zDMrfrEMoX28EeKwueHRlfXQokID1tydBWdaflbKLlL/azBKk1Ydp9kyRM0dvV43WHG s3P/lWg5kHqTJk6zkIZoqb/e/vI2lp4jXqDu70KtwZMyQuiwn3BGw1b5S1dcth2nlH/Z sPem+DZMGuTO2uXYugFw/0sXQHJTfndRRJmSGqxkaY0PT/9KuYhd4ZYwsJY92xnzvY5G 2kiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ToAhjL9XFdxjjye6nKRusCeRANLcN15gZaOodjy4LOI=; b=BaXSneB/a7D1zqibPLKmkrEhgdAOspAxFMxILhvrjObOPpe7BKLHJs8G4CuWcBYzo5 KMhDr7JiIhosuUDafPKzykWRpQbNkf9R84LCdIYANLpR9f2LEqgJFxJRC6Ny1wc68BA/ /IzBB6pSjsstpXl/YORE5gT7kbqOsWHp99OQVQf883vykyL2zq/Jg48k9J25atd3HHZJ M/luGlr+k5eoxDFyMtC2pbOhLw1MxPt60Cd6l0YnjuWewuGd3VoNLboMONox6uophLwm TPG/WQOXHfNLNcPl74BSxke2ya4FW4ALhZr2IE5pGYyR4JAaQ1Ra3PyvKwZdbJ5R136c baBQ== X-Gm-Message-State: AOAM532LTDCtaPXm5/KdQ7EwjgRkjMYFcFCzV2jz/XmZUh21Q9ct2TMf CwjQdl2eRUnU4IbLSzUhGufTZZC2pciv1Q== X-Google-Smtp-Source: ABdhPJw8hynxj6NuYoXAa7/TyWDXLDjE+nEg8ztapsVGSjwXP7pZ/WDmX6dILWYpYgAMXk974oCyhw== X-Received: by 2002:adf:fa06:: with SMTP id m6mr10847400wrr.387.1620376851299; Fri, 07 May 2021 01:40:51 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:81ab:95ee:9715:e9fb]) by smtp.gmail.com with ESMTPSA id l12sm7604098wrm.76.2021.05.07.01.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 01:40:50 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 7 May 2021 09:40:41 +0100 Message-Id: <20210507084042.31879-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507084042.31879-1-naush@raspberrypi.com> References: <20210507084042.31879-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 4/5] ipa: raspberrypi: Add Overwrite method to RPiController::Metadata 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" Add a new Overwrite method to the Metadata class. This will overwrite all key/value pairs in a destination object that have an identical key in the source metadata object. Once complete, the source Metadata object will be empty. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/metadata.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp index 319f2320fc70..ac64f17f617c 100644 --- a/src/ipa/raspberrypi/controller/metadata.hpp +++ b/src/ipa/raspberrypi/controller/metadata.hpp @@ -75,6 +75,26 @@ public: return *this; } + void Overwrite(Metadata &other) + { + std::lock_guard lock(mutex_); + std::lock_guard other_lock(other.mutex_); + + /* + * Overwrite any contents of data_ with identical keys from + * other.data_. Any keys from other.data_ that are not preset in + * data_ will simply be copied across. + * + * The reason for the seemingly illogical steps below is because + * std::map::merge() does not overwrite existing keys. + */ + other.data_.merge(data_); + std::swap(data_, other.data_); + + /* Render the other object as empty now! */ + other.data_.clear(); + } + template T *GetLocked(std::string const &tag) {