[{"id":16344,"web_url":"https://patchwork.libcamera.org/comment/16344/","msgid":"<CAHW6GYJjT=UTBzDJ15oZ-_TfucU0xJGd0wD6K6ftfYMOb9KX_w@mail.gmail.com>","date":"2021-04-19T10:29:06","subject":"Re: [libcamera-devel] [PATCH v3 3/4] ipa: raspberrypi: Add\n\tmove/copy ctors and operators to Metadata class","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nAs per our discussion, it may be worthwhile including a merge (or\nMerge) method. Something like \"void Metadata::Merge(Metadata &other)\".\n\nThis method would add any key/value pairs in the passed metadata\nobject \"other\" to \"this\" one. It could do so either by \"moving\" the\ndata values or by copying them. Presumably there are circumstances\nwhere \"moving\" may be more efficient.\n\nSuch a method would help us to update the metadata correctly when we\nelect not to run the control algorithms (one of the other patches in\nthis set). It would update all the sensor's metadata items, not just\nthe \"device.status\", preparing us for the day when we have sensors\nthat will generate such information.\n\nThanks!\nDavid\n\nOn Sun, 18 Apr 2021 at 10:05, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\n> Add a default, move and copy constructor as well as a move operator\n> implementation RPiController::Metadata class.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/controller/metadata.hpp | 24 +++++++++++++++++++++\n>  1 file changed, 24 insertions(+)\n>\n> diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp\n> index 07dd28ed9e0a..319f2320fc70 100644\n> --- a/src/ipa/raspberrypi/controller/metadata.hpp\n> +++ b/src/ipa/raspberrypi/controller/metadata.hpp\n> @@ -19,6 +19,21 @@ namespace RPiController {\n>  class Metadata\n>  {\n>  public:\n> +       Metadata() = default;\n> +\n> +       Metadata(Metadata const &other)\n> +       {\n> +               std::lock_guard<std::mutex> other_lock(other.mutex_);\n> +               data_ = other.data_;\n> +       }\n> +\n> +       Metadata(Metadata &&other)\n> +       {\n> +               std::lock_guard<std::mutex> other_lock(other.mutex_);\n> +               data_ = std::move(other.data_);\n> +               other.data_.clear();\n> +       }\n> +\n>         template<typename T>\n>         void Set(std::string const &tag, T const &value)\n>         {\n> @@ -51,6 +66,15 @@ public:\n>                 return *this;\n>         }\n>\n> +       Metadata &operator=(Metadata &&other)\n> +       {\n> +               std::lock_guard<std::mutex> lock(mutex_);\n> +               std::lock_guard<std::mutex> other_lock(other.mutex_);\n> +               data_ = std::move(other.data_);\n> +               other.data_.clear();\n> +               return *this;\n> +       }\n> +\n>         template<typename T>\n>         T *GetLocked(std::string const &tag)\n>         {\n> --\n> 2.25.1\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 7F343BD814\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 10:29:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 032116880C;\n\tMon, 19 Apr 2021 12:29:21 +0200 (CEST)","from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com\n\t[IPv6:2607:f8b0:4864:20::c29])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB24D602C8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 12:29:19 +0200 (CEST)","by mail-oo1-xc29.google.com with SMTP id\n\ti25-20020a4aa1190000b02901bbd9429832so7644875ool.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 03:29:19 -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=\"ED9xAr7z\"; 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=NounWg7qbtIS7P/qWa7In1VajDRuEe9ZsIXbDq/xNpU=;\n\tb=ED9xAr7zJQ4s7RwDwH78P7YbbfDXCGo7NwiKITTOKtvuXb4LZ9MpR9mBuxW3OQw20U\n\twPA5Z4b1tJAsNtW8QU3Pu/iV+7gwfzcmRJ7hWpIQZ0OR4ShKnww7HD8Rgmlq2ZBL3sq7\n\tUhvA8ChT8HfxhNYRb9L5t6+Zbsft7AOwKieknWY92DktT0dhgBxLLZP8kCSxqex3E2dD\n\t6/jBqOt3onnOd2yzHQAxRMjcIgi9OE3A0YN5d6O3iFDkeDmxaMsdjyzmjLo2wMuSYLHk\n\tcnA9NGckQhrVM/ic7u4EIv56gxyT1kNyGSz3qmB6ZGAkBpTXK1BYdspHYQuDijc66jWu\n\tXkKg==","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=NounWg7qbtIS7P/qWa7In1VajDRuEe9ZsIXbDq/xNpU=;\n\tb=RPUMMO204JmkW6YWfX7UhGvI2AG8bBTHAVO6O13OiWLSscQClu7WAUrmzqG+0FXP7y\n\tyxu/39Mu1bZoreRBzBwShCZLy40goQ9PXZtvUt2NkgxeXxsonKWneXmem8acuLvi4+/a\n\tfFVnYnIsMkD6et1b0m/B45SMkh7L8oDhRaBT97JaShTCanzo+ub9PdX/szCfSjlYf8mx\n\tEvH7MkCQpgmKIYKRWTQPsD20jwAWrPB6ZUyA+i8v3EFGu9fVfLn8ODmSgFw863xX5X/3\n\tsu4u7wGVEXQEcNJaFw8M8V0CbVT6DzbEj85kiPSo3vaEcXZB++IV/hpZCRNTV6S21rXV\n\tC9IQ==","X-Gm-Message-State":"AOAM533uu6hgHEg3azSmSHoK3fstRg1ozWT/qjgu6GkqpeM8h6JW6rBZ\n\tHnSRMevhENvb7L9gX5Wh7+MDO33lu51WBBF/V3b9Ow==","X-Google-Smtp-Source":"ABdhPJww0yAI5IHXPHlIit+0qK6OSngTpqF8/Z4NGXSdK8QPXWIynqeWFChNZGOzOqS1hutp9n3dfbWAB1CuQQsmWLk=","X-Received":"by 2002:a05:6820:56:: with SMTP id\n\tv22mr2472842oob.5.1618828158351; \n\tMon, 19 Apr 2021 03:29:18 -0700 (PDT)","MIME-Version":"1.0","References":"<20210418090459.38506-1-naush@raspberrypi.com>\n\t<20210418090459.38506-4-naush@raspberrypi.com>","In-Reply-To":"<20210418090459.38506-4-naush@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 19 Apr 2021 11:29:06 +0100","Message-ID":"<CAHW6GYJjT=UTBzDJ15oZ-_TfucU0xJGd0wD6K6ftfYMOb9KX_w@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 3/4] ipa: raspberrypi: Add\n\tmove/copy ctors and operators to Metadata class","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>"}}]