From patchwork Sun Apr 18 09:04:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11975 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 C6012BD812 for ; Sun, 18 Apr 2021 09:05:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5ED0968803; Sun, 18 Apr 2021 11:05:08 +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="bA2Iim9s"; dkim-atps=neutral Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B428602CD for ; Sun, 18 Apr 2021 11:05:06 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id j7so220519eds.8 for ; Sun, 18 Apr 2021 02:05:06 -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=fW/hur3tefpJwBCdBS9ucikdtiTjIrz8a6UkMMoW9n0=; b=bA2Iim9s4Yb7uN7Ca+qtkQm3I9YqirW0xuD49Vmz7IsgGBClVowaUCx6aDSIqW5VyX KaKQ6LE8kMkeiLjuEk6J1dS4wk4KdA/EYmFRdgn+t8a/oD2tY4VYFaqLBnb4d26qswLr h9uIYtRR7Uz6EtATbHSxwG2J0Mq3pu2ClHMLtPrwQWGkpFWgW+m9VEIbps2HV8e3HRaA mzWscyHXaqY4a0H67TKsM/+1y4mFJ9ICsE9qv+B24toVSHN3lJVP5AFHtplsA0yhoO6B o3q0z5LcpDyyX59iUSG0sJ9VXq4DR+swPUyvOggtkWqZXfHgVQ6UrME94IXF2yCa9t66 VIYw== 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=fW/hur3tefpJwBCdBS9ucikdtiTjIrz8a6UkMMoW9n0=; b=jGmJg1URKJNHWb30JLTQrYr9jfWk9UjPxDXAkmf9Bxs3K18VLvzD+WA3XveTjCzBi/ AzRoPN5rbgcGBpj9ykbtdi58dNtZlxuRFAVLOA3xDp0LthiETt2ztkwG/A/TQiwzy/8X BmFTxLqkV0bmFSTcgHmI97AdgvTzLFymOW5iFiSl9llNyTzGtTqZOTPWGGBU7ulbAgPY IrHiQHtnF6rJ/fyROwq+Mtt0+V1SLR9KohjJHt0q/mGL77U73UIWoTgGEQb4IRmkc1+K cIpzdSy3a/cd7fVZhI0soTU5NxuGIbr2cNCJuT56bDMhjnGPapfW44+db3vMPKOvs9uG Nl7A== X-Gm-Message-State: AOAM530XZggQiePrFrsN8cVnXGTBN0kgVcC+j6xE1cFnE2yanNDNH7Bw H+VL9m1hgfy+IwGs/enrG404YXH9OVm3lg== X-Google-Smtp-Source: ABdhPJyb92kDm7+ciU2aoPFJs2W8m7d96CRVk7Zy9pmcANTRGbc1sUpe10xfK/BnyM59jSqUXeAF4g== X-Received: by 2002:a05:6402:4244:: with SMTP id g4mr19384023edb.204.1618736705513; Sun, 18 Apr 2021 02:05:05 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id z4sm9080679edb.97.2021.04.18.02.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Apr 2021 02:05:05 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Sun, 18 Apr 2021 10:04:57 +0100 Message-Id: <20210418090459.38506-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210418090459.38506-1-naush@raspberrypi.com> References: <20210418090459.38506-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/4] 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 --- 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(); }