From patchwork Mon Apr 19 13:34:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12003 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 E07B1BD814 for ; Mon, 19 Apr 2021 13:35:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 30DC26883A; Mon, 19 Apr 2021 15:35:03 +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="HTpYjrXy"; dkim-atps=neutral Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AB3C768839 for ; Mon, 19 Apr 2021 15:34:59 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id x7so34048542wrw.10 for ; Mon, 19 Apr 2021 06:34:59 -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=HTpYjrXyhOkDbT+U6Ji+AedTG+1SM/axFXnKyJdP/r6CiTmV4Lq7hVct9ymv0fRm7f 6zBWk57jyTmPgUQIfLDLPAVUp8qvq86LQyW7FN9lHSwBUkPM2kaD2THo4vyUfADLxi7D XY7RSmJNyjzqjlpkgPj4kPVOfLHGqFacYrWKINg/7MeQGDSexlN2o630Axjn2QAnbUgk Xg33RxSHlGs+vV7GujtQ51eXyzmoDNY58jwF0WPou9F2KF/YM+liff4cD+Nofk3CYEJ0 m1HrBQrPdWzw+G5mEbbq5C4JSw+2nBICnBCtgENY6sneUG+uazBxqq07cV0++Ocimx2m ZxUw== 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=J/YiAC81wE5AdgbcSTVjkPjEl8Q9ZwwmOOIYoTlX+4kgzOdhhcwJ6T8yhlw92Zapzx 9eVl8sQE+ZtiPQO76mK3LtSXepxYh1BHQFGZX2mH6IOGDXjEUjxiiyBptzNK1OcghCRT BXfQ/qTYEve96iekWmjlYBtlezC8ceH0puQ1WtLTEDBSaF2R0ZNIbb5wnpE34zVQKHOn dpJxpvsbPrG6RVhsD5J6EHyjCWE6923CND05FdtpuYygIpMeM6SZrbtwlJwprYh+0/iw yBb2T4UqtOzGVAZUHfjtagbOT8r7Rt/KxHsIvPKm6JJrb12IGJoQ6PltvlceBYv2h+HX Yorw== X-Gm-Message-State: AOAM533eRVXnFOAUnTZcoqP6wpU8yG2yW2jndsqEgLtgpEpji6EDcemK awbsqrA18KJO7SRwdkft0b3Uzdwrg2QPnA== X-Google-Smtp-Source: ABdhPJwfiE/OqWMwEZwwOCxP722thno8kdHcAqn3gr8RrxsrlnOA/Kt8nV+7AvecJk9EmusgvwTBdQ== X-Received: by 2002:a05:6000:362:: with SMTP id f2mr14730584wrf.141.1618839299060; Mon, 19 Apr 2021 06:34:59 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:15:5363:8f56:4f84:754]) by smtp.gmail.com with ESMTPSA id k11sm19952238wrx.88.2021.04.19.06.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 06:34:58 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 19 Apr 2021 14:34:48 +0100 Message-Id: <20210419133451.263733-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210419133451.263733-1-naush@raspberrypi.com> References: <20210419133451.263733-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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(); }