From patchwork Fri May 7 08:40:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12223 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 4D738BF831 for ; Fri, 7 May 2021 08:40:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B58FB6891D; Fri, 7 May 2021 10:40:52 +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="rGHQUzUF"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 696A86890C for ; Fri, 7 May 2021 10:40:50 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id v12so8306986wrq.6 for ; Fri, 07 May 2021 01:40:50 -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=+GT3G4sPCrq9a5bQt/xmz9z6Jx7t87Z5yxPlBQqFaZM=; b=rGHQUzUFwAhLsZi6vGsK2WOzNq75nNwVNrr8cL8i+UJLIQRhurDAYKjxTG+Vx3nApE LnFzE5T5oykDfVZ6tteNhU1/K7xmWQKVuk9tvUQGbEONnOs1kR9xxuQIBnJrNyh9HgFL HpxfCG3L8yzl7KOZYXUngRicWOljBlm89Ux7QKGy+grgM/y7RvmcY5zbOyYhUDzmSBeh ees3jOhN7/x5Cqwp0zalBS2MsiACPmtOgsnb8ri0M+hCprYu4qS8tJB7q6wF6Dy0cdtq nM6hv3wu31qk8QQDZDSFNJ9+0tKd+7yXlMhabPzvfuZwMSuxikVzzhoClpEHYmB0+h2/ nWZw== 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=+GT3G4sPCrq9a5bQt/xmz9z6Jx7t87Z5yxPlBQqFaZM=; b=gr+SvF53kuRY1IrF+wY+McNPwp4qpksesL/aCmwyRiroW+P9NQyu1l50PGsPVS+qaf GtM4QmNNFww622f99Clnh22HkP9buKr8I+VW5OgbcoSd6ZLGUdfDUxpw0VMoe4e52kKh 0lEhdB0iloMgQsu3szX/GxUm5AdbTBsBY+q2DgiOxqjBnlXtHXsJzQdpn2yuOTrItjQL XYJJPGqzN7UcLhtVmPNd2wvRdacpZtvA8BtrLymwwKLyuYmDSGDfLvk4W7r3gDq/x+GD xdWX44eUK35nfPv9K1cflls3S8uD2ltLe1fPDXbojza508nbBt4jXqFVJebGXdPCt/IE uzXw== X-Gm-Message-State: AOAM533g9q/3bKBmKvkhjEhStoUUU+0kV05ImA6v98wslbFC9uFCUCTK Ak8L6Dq2cLxzOoBOtxtyRptDH4VAsLw75A== X-Google-Smtp-Source: ABdhPJysKxiy52NTht5ROg8unjvM6fFaKj24u4lGDNOavoP9GCRKPt+2FcXQLBeLw5/jFato3q8eiQ== X-Received: by 2002:adf:ab1d:: with SMTP id q29mr10504127wrc.208.1620376849938; Fri, 07 May 2021 01:40:49 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 01:40:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 7 May 2021 09:40:39 +0100 Message-Id: <20210507084042.31879-3-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 2/5] ipa: raspberrypi: Reformat RPiController::Metadata class header 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" Rearrange header includes to be in alphabetical order. Add whitespace to class definition to match libcamera coding guidelines. Fix a typo in the comment showing an example of scoped locks. There are no functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/metadata.hpp | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp index 4f44ffc6771c..07dd28ed9e0a 100644 --- a/src/ipa/raspberrypi/controller/metadata.hpp +++ b/src/ipa/raspberrypi/controller/metadata.hpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * * metadata.hpp - general metadata class */ @@ -9,22 +9,25 @@ // A simple class for carrying arbitrary metadata, for example about an image. #include -#include -#include #include #include +#include +#include namespace RPiController { class Metadata { public: - template void Set(std::string const &tag, T const &value) + template + void Set(std::string const &tag, T const &value) { std::lock_guard lock(mutex_); data_[tag] = value; } - template int Get(std::string const &tag, T &value) const + + template + int Get(std::string const &tag, T &value) const { std::lock_guard lock(mutex_); auto it = data_.find(tag); @@ -33,11 +36,13 @@ public: value = std::any_cast(it->second); return 0; } + void Clear() { std::lock_guard lock(mutex_); data_.clear(); } + Metadata &operator=(Metadata const &other) { std::lock_guard lock(mutex_); @@ -45,7 +50,9 @@ public: data_ = other.data_; return *this; } - template T *GetLocked(std::string const &tag) + + template + T *GetLocked(std::string const &tag) { // This allows in-place access to the Metadata contents, // for which you should be holding the lock. @@ -54,15 +61,17 @@ public: return nullptr; return std::any_cast(&it->second); } + template void SetLocked(std::string const &tag, T const &value) { // Use this only if you're holding the lock yourself. data_[tag] = value; } + // Note: use of (lowercase) lock and unlock means you can create scoped // locks with the standard lock classes. - // e.g. std::lock_guard lock(metadata) + // e.g. std::lock_guard lock(metadata) void lock() { mutex_.lock(); } void unlock() { mutex_.unlock(); }