[{"id":23964,"web_url":"https://patchwork.libcamera.org/comment/23964/","msgid":"<165823432387.2021905.13718575546798918011@Monstersaurus>","date":"2022-07-19T12:38:43","subject":"Re: [libcamera-devel] [PATCH] simple-cam: Update to the new\n\tControList::get() API","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2022-07-19 13:26:04)\n> The ControlList::get() function has changed and now returns a\n> std::optional<T>. Adapt simple-cam accordingly.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  simple-cam.cpp | 28 ++++++++++++++++------------\n>  1 file changed, 16 insertions(+), 12 deletions(-)\n> \n> diff --git a/simple-cam.cpp b/simple-cam.cpp\n> index 4de1b7de9ced..3e17839d17e6 100644\n> --- a/simple-cam.cpp\n> +++ b/simple-cam.cpp\n> @@ -133,18 +133,22 @@ std::string cameraName(Camera *camera)\n>         const ControlList &props = camera->properties();\n>         std::string name;\n>  \n> -       switch (props.get(properties::Location)) {\n> -       case properties::CameraLocationFront:\n> -               name = \"Internal front camera\";\n> -               break;\n> -       case properties::CameraLocationBack:\n> -               name = \"Internal back camera\";\n> -               break;\n> -       case properties::CameraLocationExternal:\n> -               name = \"External camera\";\n> -               if (props.contains(properties::Model))\n> -                       name += \" '\" + props.get(properties::Model) + \"'\";\n> -               break;\n> +       const auto &location = props.get(properties::Location);\n> +       if (location) {\n> +               switch (*location) {\n> +               case properties::CameraLocationFront:\n> +                       name = \"Internal front camera\";\n> +                       break;\n> +               case properties::CameraLocationBack:\n> +                       name = \"Internal back camera\";\n> +                       break;\n> +               case properties::CameraLocationExternal:\n> +                       name = \"External camera\";\n> +                       const auto &model = props.get(properties::Model);\n> +                       if (model)\n> +                               name = \" '\" + *model + \"'\";\n\nI like that this saves double-lookups!\nIt's a shame we end up an extra level indented though.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +                       break;\n> +               }\n>         }\n>  \n>         name += \" (\" + camera->id() + \")\";\n> \n> base-commit: bb97f3bbd96a9d347e1b7f6cb68d94efaf8db574\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 9FF65BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Jul 2022 12:38:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E9AF663312;\n\tTue, 19 Jul 2022 14:38:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6D10603F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Jul 2022 14:38:47 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 596136EE;\n\tTue, 19 Jul 2022 14:38:47 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658234329;\n\tbh=PJyNKELn3+8zi3DkgTneB/DNHeU/nEDYKTE0IfO+Dj4=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=A7hXIcvr5EcwqWtVCNUUMu0JAdw5we+pF/lxrICTV2GCMF+TYZ1NMZmzgDAoDM3T/\n\tAUncgxoluAgzUzcsFsfJepCN1DmMJ9JJpvYso+DuDxJtZgIHgDL06EeXZzz1DSO87T\n\tL+Tr8xBpFnfZ9X49JwkZHP4z7L2j1ypK1LDBmIteJRuPhfjXw4uj0u2olN38xyx9CL\n\tmu0ON5r9DvhfOud+cxVZWcmP1wn7hmbj5lCFTJyDGVR0fRXAfevGmQ+fGrshGzCjPx\n\tMt/2EBo6X0Hln3tU9zPQgn8EpF6w9NwpchTZ8pEd3/L4Qp+EUUlNBn1YE45AuEhyrD\n\tjE5mQwSNeR+HA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658234327;\n\tbh=PJyNKELn3+8zi3DkgTneB/DNHeU/nEDYKTE0IfO+Dj4=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ee9/xYGL3+d4hDdh6Kk/jX6oXGET/t5ERZSjXZe23f/3WrKJoWLapMQXg/X0CNPhv\n\tS/UFNcTztOMz0LMAkIu8S/HJktJvWrpe7KYQf0ffjOd53xNKtYSt4JnJtLyMD9Anl6\n\tanJA1JE+g9XhDJKIPCBOcdxq5gT+3teUXbl7KIzQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ee9/xYGL\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220719122604.20709-1-laurent.pinchart@ideasonboard.com>","References":"<20220719122604.20709-1-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 19 Jul 2022 13:38:43 +0100","Message-ID":"<165823432387.2021905.13718575546798918011@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] simple-cam: Update to the new\n\tControList::get() API","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]