[{"id":16355,"web_url":"https://patchwork.libcamera.org/comment/16355/","msgid":"<CAHW6GY+H4QLEBO5wvvLYdCGE8UM-ZF=QLmUP_AyuB2M04PZmGQ@mail.gmail.com>","date":"2021-04-19T13:47:59","subject":"Re: [libcamera-devel] [PATCH v5 2/5] ipa: raspberrypi: Reformat\n\tRPiController::Metadata class header","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for the patch. All looks good to me!\n\nOn Mon, 19 Apr 2021 at 14:35, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\n> Rearrange header includes to be in alphabetical order.\n> Add whitespace to class definition to match libcamera coding guidelines.\n> Fix a typo in the comment showing an example of scoped locks.\n>\n> There are no functional changes in this commit.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nBest regards\nDavid\n\n> ---\n>  src/ipa/raspberrypi/controller/metadata.hpp | 23 ++++++++++++++-------\n>  1 file changed, 16 insertions(+), 7 deletions(-)\n>\n> diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp\n> index 4f44ffc6771c..07dd28ed9e0a 100644\n> --- a/src/ipa/raspberrypi/controller/metadata.hpp\n> +++ b/src/ipa/raspberrypi/controller/metadata.hpp\n> @@ -1,6 +1,6 @@\n>  /* SPDX-License-Identifier: BSD-2-Clause */\n>  /*\n> - * Copyright (C) 2019, Raspberry Pi (Trading) Limited\n> + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited\n>   *\n>   * metadata.hpp - general metadata class\n>   */\n> @@ -9,22 +9,25 @@\n>  // A simple class for carrying arbitrary metadata, for example about an image.\n>\n>  #include <any>\n> -#include <string>\n> -#include <mutex>\n>  #include <map>\n>  #include <memory>\n> +#include <mutex>\n> +#include <string>\n>\n>  namespace RPiController {\n>\n>  class Metadata\n>  {\n>  public:\n> -       template<typename T> void Set(std::string const &tag, T const &value)\n> +       template<typename T>\n> +       void Set(std::string const &tag, T const &value)\n>         {\n>                 std::lock_guard<std::mutex> lock(mutex_);\n>                 data_[tag] = value;\n>         }\n> -       template<typename T> int Get(std::string const &tag, T &value) const\n> +\n> +       template<typename T>\n> +       int Get(std::string const &tag, T &value) const\n>         {\n>                 std::lock_guard<std::mutex> lock(mutex_);\n>                 auto it = data_.find(tag);\n> @@ -33,11 +36,13 @@ public:\n>                 value = std::any_cast<T>(it->second);\n>                 return 0;\n>         }\n> +\n>         void Clear()\n>         {\n>                 std::lock_guard<std::mutex> lock(mutex_);\n>                 data_.clear();\n>         }\n> +\n>         Metadata &operator=(Metadata const &other)\n>         {\n>                 std::lock_guard<std::mutex> lock(mutex_);\n> @@ -45,7 +50,9 @@ public:\n>                 data_ = other.data_;\n>                 return *this;\n>         }\n> -       template<typename T> T *GetLocked(std::string const &tag)\n> +\n> +       template<typename T>\n> +       T *GetLocked(std::string const &tag)\n>         {\n>                 // This allows in-place access to the Metadata contents,\n>                 // for which you should be holding the lock.\n> @@ -54,15 +61,17 @@ public:\n>                         return nullptr;\n>                 return std::any_cast<T>(&it->second);\n>         }\n> +\n>         template<typename T>\n>         void SetLocked(std::string const &tag, T const &value)\n>         {\n>                 // Use this only if you're holding the lock yourself.\n>                 data_[tag] = value;\n>         }\n> +\n>         // Note: use of (lowercase) lock and unlock means you can create scoped\n>         // locks with the standard lock classes.\n> -       // e.g. std::lock_guard<PisP::Metadata> lock(metadata)\n> +       // e.g. std::lock_guard<RPiController::Metadata> lock(metadata)\n>         void lock() { mutex_.lock(); }\n>         void unlock() { mutex_.unlock(); }\n>\n> --\n> 2.25.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C046FBD814\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 13:48:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 598FF68839;\n\tMon, 19 Apr 2021 15:48:13 +0200 (CEST)","from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com\n\t[IPv6:2607:f8b0:4864:20::c32])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61A6768824\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 15:48:12 +0200 (CEST)","by mail-oo1-xc32.google.com with SMTP id\n\tc12-20020a4ae24c0000b02901bad05f40e4so7744720oot.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 06:48:12 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"jlxYh4bF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=8a9fONtkcvYH97Z4r415xh8zxeXdAOw5CIvqkVYA8dw=;\n\tb=jlxYh4bFJreWrAV9IS9IoLuuMq5NZA2P07qXEGvZlk7KxWnySSkJVJNpaAO/jqrfGS\n\tFQLfMouTVf6QUBmEIapv1ji6uUbC/UP0yIpuVlI4/xmm6ZvzgepeydzVQ7/mxu91XOw8\n\tfRPIot92QAy3qXb/JniRbZDZ/7SyhBFAELP3knSjXSEWMTxL/zULNyGM2yGkcGK7qCXw\n\tfn5fVy8xq1MMU+ypyXycCQKBpJZ4BhqCumyL+A2fDb3gMUjXuQus8o4wJ8JkuowVwaq0\n\teVYOv4YLgogdWy+/H9kUPPq54simy3BogYpxaqvlLii27mSJgfqtOxakzjHs2VlmaEqt\n\tQt1Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=8a9fONtkcvYH97Z4r415xh8zxeXdAOw5CIvqkVYA8dw=;\n\tb=V21COtfTWs3K9/TnUvn7W1nqmfgAZmVRh2SQ7s/zKXL0Ww4tXVxyczzMEIr8v/XGiR\n\t67hkneP8TKclov0VFVqtxZugLSkVtkM7yXr9DuYpVS2qKlXvhEtpoHdjFhSeFIMOJr5d\n\toX/7zHi2BlBenAOu6N+d3hLc1SQqvwhKJYOy9OPM4LyctMQ4DhhXxLik3oPUjuR3dKFa\n\t3pTZ351lFmmkEux9P4hFa21iT2CT7T1YMVJHpSggtgHEl0wajbKIfZgmvMQxD3zi/HRU\n\tClxv9Gbq6aQGt9b4Dhfk6fGx7tWa274mZG2GixW4tdiYe6shtsFULMQznEpY873KcG8v\n\tA7zg==","X-Gm-Message-State":"AOAM530YgWC2PdWiImO3MVbbIQBrPmUmZIxgSjiHr9Qmoij1tQYygB1O\n\t53+++uDjLOlXl9FBllUgIVr8wNs2vO8G95vGtaFzrQ==","X-Google-Smtp-Source":"ABdhPJxMyKxKFavNNAtv8MP6iKf9ermaQmplY2J5yXAHv9VWpMrRIA+rOVVvNRrQWGj7beEJAuFO4Onio2zaXn+krgc=","X-Received":"by 2002:a4a:d553:: with SMTP id\n\tq19mr13539342oos.28.1618840091212; \n\tMon, 19 Apr 2021 06:48:11 -0700 (PDT)","MIME-Version":"1.0","References":"<20210419133451.263733-1-naush@raspberrypi.com>\n\t<20210419133451.263733-3-naush@raspberrypi.com>","In-Reply-To":"<20210419133451.263733-3-naush@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 19 Apr 2021 14:47:59 +0100","Message-ID":"<CAHW6GY+H4QLEBO5wvvLYdCGE8UM-ZF=QLmUP_AyuB2M04PZmGQ@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v5 2/5] ipa: raspberrypi: Reformat\n\tRPiController::Metadata class header","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16633,"web_url":"https://patchwork.libcamera.org/comment/16633/","msgid":"<YIe505UayAYw7E5h@pendragon.ideasonboard.com>","date":"2021-04-27T07:14:27","subject":"Re: [libcamera-devel] [PATCH v5 2/5] ipa: raspberrypi: Reformat\n\tRPiController::Metadata class header","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, Apr 19, 2021 at 02:34:48PM +0100, Naushir Patuck wrote:\n> Rearrange header includes to be in alphabetical order.\n> Add whitespace to class definition to match libcamera coding guidelines.\n> Fix a typo in the comment showing an example of scoped locks.\n\nSweet, it looks nicer. To me at least :-)\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> There are no functional changes in this commit.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/controller/metadata.hpp | 23 ++++++++++++++-------\n>  1 file changed, 16 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp\n> index 4f44ffc6771c..07dd28ed9e0a 100644\n> --- a/src/ipa/raspberrypi/controller/metadata.hpp\n> +++ b/src/ipa/raspberrypi/controller/metadata.hpp\n> @@ -1,6 +1,6 @@\n>  /* SPDX-License-Identifier: BSD-2-Clause */\n>  /*\n> - * Copyright (C) 2019, Raspberry Pi (Trading) Limited\n> + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited\n>   *\n>   * metadata.hpp - general metadata class\n>   */\n> @@ -9,22 +9,25 @@\n>  // A simple class for carrying arbitrary metadata, for example about an image.\n>  \n>  #include <any>\n> -#include <string>\n> -#include <mutex>\n>  #include <map>\n>  #include <memory>\n> +#include <mutex>\n> +#include <string>\n>  \n>  namespace RPiController {\n>  \n>  class Metadata\n>  {\n>  public:\n> -\ttemplate<typename T> void Set(std::string const &tag, T const &value)\n> +\ttemplate<typename T>\n> +\tvoid Set(std::string const &tag, T const &value)\n>  \t{\n>  \t\tstd::lock_guard<std::mutex> lock(mutex_);\n>  \t\tdata_[tag] = value;\n>  \t}\n> -\ttemplate<typename T> int Get(std::string const &tag, T &value) const\n> +\n> +\ttemplate<typename T>\n> +\tint Get(std::string const &tag, T &value) const\n>  \t{\n>  \t\tstd::lock_guard<std::mutex> lock(mutex_);\n>  \t\tauto it = data_.find(tag);\n> @@ -33,11 +36,13 @@ public:\n>  \t\tvalue = std::any_cast<T>(it->second);\n>  \t\treturn 0;\n>  \t}\n> +\n>  \tvoid Clear()\n>  \t{\n>  \t\tstd::lock_guard<std::mutex> lock(mutex_);\n>  \t\tdata_.clear();\n>  \t}\n> +\n>  \tMetadata &operator=(Metadata const &other)\n>  \t{\n>  \t\tstd::lock_guard<std::mutex> lock(mutex_);\n> @@ -45,7 +50,9 @@ public:\n>  \t\tdata_ = other.data_;\n>  \t\treturn *this;\n>  \t}\n> -\ttemplate<typename T> T *GetLocked(std::string const &tag)\n> +\n> +\ttemplate<typename T>\n> +\tT *GetLocked(std::string const &tag)\n>  \t{\n>  \t\t// This allows in-place access to the Metadata contents,\n>  \t\t// for which you should be holding the lock.\n> @@ -54,15 +61,17 @@ public:\n>  \t\t\treturn nullptr;\n>  \t\treturn std::any_cast<T>(&it->second);\n>  \t}\n> +\n>  \ttemplate<typename T>\n>  \tvoid SetLocked(std::string const &tag, T const &value)\n>  \t{\n>  \t\t// Use this only if you're holding the lock yourself.\n>  \t\tdata_[tag] = value;\n>  \t}\n> +\n>  \t// Note: use of (lowercase) lock and unlock means you can create scoped\n>  \t// locks with the standard lock classes.\n> -\t// e.g. std::lock_guard<PisP::Metadata> lock(metadata)\n> +\t// e.g. std::lock_guard<RPiController::Metadata> lock(metadata)\n>  \tvoid lock() { mutex_.lock(); }\n>  \tvoid unlock() { mutex_.unlock(); }\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 84134BDE19\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Apr 2021 07:14:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 43CB1688B1;\n\tTue, 27 Apr 2021 09:14:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 94F946885A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Apr 2021 09:14:33 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 33E6BE9;\n\tTue, 27 Apr 2021 09:14:33 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uAl8X1f9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619507673;\n\tbh=90hmv3AGMFOCUq0oHdj7DwfW1gWHZyNlmxBC6org8I8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uAl8X1f9G1sAJ+bDm40xm07K/rThzFkNTtaxi+Urgo9MR8IUWAq52uhzMrw6khRLn\n\t7Cpa5QZYtIz4WsR2P79Tqu1aYGZ8I0FPLPa6aoaG7vR4XkJg+lXZNsL+upJXGtlroS\n\tiVgUhNitcM/q+vZSugKPBEEFBAdbFaVsH3FviAOQ=","Date":"Tue, 27 Apr 2021 10:14:27 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YIe505UayAYw7E5h@pendragon.ideasonboard.com>","References":"<20210419133451.263733-1-naush@raspberrypi.com>\n\t<20210419133451.263733-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210419133451.263733-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v5 2/5] ipa: raspberrypi: Reformat\n\tRPiController::Metadata class header","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]