From patchwork Mon Apr 19 13:17:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11997 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 C458EBD812 for ; Mon, 19 Apr 2021 13:17:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 708C668835; Mon, 19 Apr 2021 15:17:28 +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="nnqfLFO4"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 756EB602CD for ; Mon, 19 Apr 2021 15:17:27 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id a4so34021901wrr.2 for ; Mon, 19 Apr 2021 06:17:27 -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=nnqfLFO4CanlAnfby2OO53IS4oy8LHMuHV0KuoyM+qsw8kt2/7PCogJexNoZG1UJ/S e131S2qvyM242rJfoqDHf3Li7UusHy5yhXN+5JKMlMI5zOmzOB6e86t4Ov71gzYq/IV9 4AVuvOq5/s8HoEE9JufuvyH1WIRTdOuVawS/tprbSfzuJeYqUKyqpB0RrjhK3eaaxuL7 H9omSE4avIlvzFvdejf0QEz0xDQe7+yFPrVPegSh7vvBmQ439V2kme2eGkt95hmcNnxX 3XPzqlKI6VNLYQ3hd8cWTz/+M7n7eW9QxLPUklaxkcuRCoWXYa6SVz5vx+qo4kW2YHMo SBhA== 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=ElILAxcDXubHXi+cbklVlV2bPdYfZtSknPmwPIUmtdmcsKefqYeAZD4rmNQ/RUzuei b4JKFca3aQhq6gs99TJqMADQBMcPQpxzcIvEOb0p1g/NcugigfszqI0sQnu3aW/fyZQi aJ+nv6WnrXXnE8yVi+r4UjpygJex79jT0UMfq4JM0MuUR20gIyLRZR9ndCOouYGK9VKR /Ywgw+Bl7c8tapP7L1yTrq8RSrUZN+fuVHHMtmdVvg2LzdhOw7K9UaDpSOprNsjFJhB9 dx47yNf2eHY4OihyNkB6uBRnVLq4B/yCu3WS9HErxKIsnYhELSBP2YUhgOzgIWwSabAM L02A== X-Gm-Message-State: AOAM533cTs/HatNEKRbxENdcb5CHIzBLyrGcYz1AoU70mhuyG+BqwaG0 m+3AL9MktLffgAKjUsIw9RCFiZqdfdI1CQ== X-Google-Smtp-Source: ABdhPJxzUWyUfxq2BtVkx+BMOFZ8UN8rP1fxWrCb5hLDDf8o6B6aCpMaAbzSBuuGIDkQEPAmJhUQYg== X-Received: by 2002:adf:e58f:: with SMTP id l15mr14215503wrm.175.1618838246972; Mon, 19 Apr 2021 06:17:26 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:15:5363:8f56:4f84:754]) by smtp.gmail.com with ESMTPSA id t6sm22335428wrx.38.2021.04.19.06.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 06:17:26 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 19 Apr 2021 14:17:12 +0100 Message-Id: <20210419131715.256802-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210419131715.256802-1-naush@raspberrypi.com> References: <20210419131715.256802-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/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(); }