From patchwork Mon May 10 09:58:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12235 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 34BC4BF829 for ; Mon, 10 May 2021 09:59:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EB68A6891D; Mon, 10 May 2021 11:59:11 +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="pU5bzADc"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7DAEC6891A for ; Mon, 10 May 2021 11:59:07 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso9362436wmc.1 for ; Mon, 10 May 2021 02:59:07 -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=pU5bzADcJMPLNrBVQ07r1tDtIXwyVlPYDEWKokZedo0ouvLGZ3bTmsb3YVO11QoDY3 X58wwRE/r9MgA9Wr3BAd5NK+qg/3sV//9PliyK1hYOPDT8q1ARgCpK1YI8wlrkJrAZ29 gLzicwCYmOHt/Hk2C1xmGIdykjtHI9brjWCXwnq52r9YK7JfpMotoyeS5Rrz35JOGVoZ v1fPpYc7gFT6kUqezUF3/AyDaBv8ZFKwbgQMS3G4Umzb0nOA5+qJnSYit+wo11dVdb0Q kQBvZ1rSdutY9sKZDqAGtftzBQiKxyFVcTaslBxpuZNJnBVX/IkWkuuUu01pET2NKagn 3JEA== 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=Ub6LGCJr17gq9kp2Pis7VfbQbnhcipaaBXTlB6spe96z992ODTjKvmb/j9jqp0xZYu ozCXt7VdZFL1bgEiE90gDkQmDr3vtp3jKr9HjvG1VZ4QSB80xjRXGkF2/fgJeZM5P+Ra 3V5EmLf+9iroqnimxYzkwtpZDJEoBSWwuXfAt07WewPd5V7FxE7wjIlJwaLbmmyAAMPN KntzgvUuS87870s/3zo7jNHdrdw8PO3ENYfdS3BOMKS4RszYBq/7snDtlz/ijMSodNmN FUibnbydjoZFEWM7+FLJovBBSttYLJrYtf1ejzbcyjUzbngC28ZyWQPsalYTXm+Jmnii YjIg== X-Gm-Message-State: AOAM533PFEoYcu/48axWqJONQY56qPej7dM1MAIl9sBftmoOd2CbrTK3 iy2C1ETJ22eNygYwHI3nFdy9etMPgLnKLw== X-Google-Smtp-Source: ABdhPJza/+EbCU2q1b2BJALltEDucDymYtxq9wpHsHgsJ8fA1zgIpYYyz3FQbS1tNWEgyomKlLlqjQ== X-Received: by 2002:a05:600c:4105:: with SMTP id j5mr36197475wmi.141.1620640746976; Mon, 10 May 2021 02:59:06 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:e710:3ec:6dad:dc2]) by smtp.gmail.com with ESMTPSA id y17sm24767917wrw.90.2021.05.10.02.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 02:59:06 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 10 May 2021 10:58:11 +0100 Message-Id: <20210510095814.3732400-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210510095814.3732400-1-naush@raspberrypi.com> References: <20210510095814.3732400-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 2/6] 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(); }