[{"id":4589,"web_url":"https://patchwork.libcamera.org/comment/4589/","msgid":"<20200427225340.GB13402@pendragon.ideasonboard.com>","date":"2020-04-27T22:53:40","subject":"Re: [libcamera-devel] [PATCH v2 2/5] cam: options: Add public\n\tmethod to invalided options","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\ns/invalided/invalidate/ in the subject line.\n\nOn Tue, Apr 28, 2020 at 12:05:26AM +0200, Niklas Söderlund wrote:\n> Extend OptionsBase<T> with a public invalidate() method. This allows\n> sub-classes to continue the interpreting of parsed options and\n> invalidate them if they find problems with the result.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/cam/options.cpp | 6 ++++++\n>  src/cam/options.h   | 2 ++\n>  2 files changed, 8 insertions(+)\n> \n> diff --git a/src/cam/options.cpp b/src/cam/options.cpp\n> index 2c56eacf006e9857..77b3cc1f8c5a59e9 100644\n> --- a/src/cam/options.cpp\n> +++ b/src/cam/options.cpp\n> @@ -64,6 +64,12 @@ const OptionValue &OptionsBase<T>::operator[](const T &opt) const\n>  \treturn values_.find(opt)->second;\n>  }\n>  \n> +template<typename T>\n> +void OptionsBase<T>::invalidate()\n> +{\n> +\tvalid_ = false;\n> +}\n> +\n>  template<typename T>\n>  bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n>  \t\t\t\tconst char *optarg)\n> diff --git a/src/cam/options.h b/src/cam/options.h\n> index 5060fee0c26b896f..8ccbfee48f7ca0b5 100644\n> --- a/src/cam/options.h\n> +++ b/src/cam/options.h\n> @@ -54,6 +54,8 @@ public:\n>  \tbool isSet(const T &opt) const;\n>  \tconst OptionValue &operator[](const T &opt) const;\n>  \n> +\tvoid invalidate();\n\nIf this is only for subclasses, the method should be protected. I'm\ntempted to go simpler and move the valid_ field protected. What do you\nthink ? If you want to keep the method I'd make it inline, as it will be\nmore efficient.\n\n> +\n>  private:\n>  \tfriend class KeyValueParser;\n>  \tfriend class OptionsParser;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6174F60AF4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Apr 2020 00:53:56 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D237F72C;\n\tTue, 28 Apr 2020 00:53:55 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Ob8oK6be\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1588028036;\n\tbh=yIzOpia9dZawSbus3amgfh7oljRokwm/bk25TLWC2lU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ob8oK6be0ZYQc7GoYbjw8x+tdpDarixi+cQh2aI0zAJQ+IKZoJtOjwzlmYWNFsShW\n\t5XOZ7FOQfzoZ/BVO1lNWJ/0NfekY+5rFCLcsCwMu/7HPvCVFJ0gEBVBDVQGRuTXYbg\n\thTaLT0qrYk3ZjA+c4BsvHGCSse8MZD3rjDKwH9Gw=","Date":"Tue, 28 Apr 2020 01:53:40 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200427225340.GB13402@pendragon.ideasonboard.com>","References":"<20200427220529.1085074-1-niklas.soderlund@ragnatech.se>\n\t<20200427220529.1085074-3-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200427220529.1085074-3-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v2 2/5] cam: options: Add public\n\tmethod to invalided options","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>","X-List-Received-Date":"Mon, 27 Apr 2020 22:53:56 -0000"}},{"id":4591,"web_url":"https://patchwork.libcamera.org/comment/4591/","msgid":"<20200427231352.GD1165729@oden.dyn.berto.se>","date":"2020-04-27T23:13:52","subject":"Re: [libcamera-devel] [PATCH v2 2/5] cam: options: Add public\n\tmethod to invalided options","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your feedback.\n\nOn 2020-04-28 01:53:40 +0300, Laurent Pinchart wrote:\n> Hi Niklas,\n> \n> Thank you for the patch.\n> \n> s/invalided/invalidate/ in the subject line.\n> \n> On Tue, Apr 28, 2020 at 12:05:26AM +0200, Niklas Söderlund wrote:\n> > Extend OptionsBase<T> with a public invalidate() method. This allows\n> > sub-classes to continue the interpreting of parsed options and\n> > invalidate them if they find problems with the result.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  src/cam/options.cpp | 6 ++++++\n> >  src/cam/options.h   | 2 ++\n> >  2 files changed, 8 insertions(+)\n> > \n> > diff --git a/src/cam/options.cpp b/src/cam/options.cpp\n> > index 2c56eacf006e9857..77b3cc1f8c5a59e9 100644\n> > --- a/src/cam/options.cpp\n> > +++ b/src/cam/options.cpp\n> > @@ -64,6 +64,12 @@ const OptionValue &OptionsBase<T>::operator[](const T &opt) const\n> >  \treturn values_.find(opt)->second;\n> >  }\n> >  \n> > +template<typename T>\n> > +void OptionsBase<T>::invalidate()\n> > +{\n> > +\tvalid_ = false;\n> > +}\n> > +\n> >  template<typename T>\n> >  bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n> >  \t\t\t\tconst char *optarg)\n> > diff --git a/src/cam/options.h b/src/cam/options.h\n> > index 5060fee0c26b896f..8ccbfee48f7ca0b5 100644\n> > --- a/src/cam/options.h\n> > +++ b/src/cam/options.h\n> > @@ -54,6 +54,8 @@ public:\n> >  \tbool isSet(const T &opt) const;\n> >  \tconst OptionValue &operator[](const T &opt) const;\n> >  \n> > +\tvoid invalidate();\n> \n> If this is only for subclasses, the method should be protected. I'm\n> tempted to go simpler and move the valid_ field protected. What do you\n> think ? If you want to keep the method I'd make it inline, as it will be\n> more efficient.\n\nMy bad the commit message is wrong, it's not for subclassing. It's for \nprocessing the KeyValueParser::Options (which inherits from \nOptionsBase<T>) in subclasses of KeyValueParser.\n\nOne could move valid_ to protected and the implement \nKeyValueParser::Options::invalidate() to hide it a bit more. But I don't \nsee the harm in allowing even applications to examine the options parsed \nfrom the command line and if it does not like them marking the whole set \nas invalid. I would not however expose a setValid(bool valid) interface \nto applications.\n\nI have no strong feelings here so I'm open to any solution tho.\n\n> \n> > +\n> >  private:\n> >  \tfriend class KeyValueParser;\n> >  \tfriend class OptionsParser;\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2FC160AF4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Apr 2020 01:13:54 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id u15so19477533ljd.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 16:13:54 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tb73sm12544337lfg.86.2020.04.27.16.13.53\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 27 Apr 2020 16:13:53 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"Kd4/z1rL\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=o1vXi9tJST+zfXqpqilnjGWPpK+d88bAtrzWwyVRyLA=;\n\tb=Kd4/z1rLImaLz7sDn80tw8aHmBtIJkTF3FcBF1GF6qAosv/9k5QvAY+aVZ7YOTwDCp\n\tSBIX+R1U2ORPX9vIaSIqewVydaGaBcl0goTKYYn6a1DnJHDQd8ME2iVJCgnA0/1r8zK3\n\tCn6WYgvwX0hSphe9LYggAwftAlutMOSXZW06xKA4WdiR2GXiTvmhqMInzXHBtZz59pet\n\tTaWmv/aopIEXTSK01sglLYF6wAhMy7lNSnUb7Md0I0WbBysckURcu1pQLx6oh92mlA38\n\tVU75yswqUPSCPOLZC6q4Kr0xLkgh70zEoKT6PkUjILTv0qomxw5UXQuy8jSV1T8jeLBy\n\tYCIw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=o1vXi9tJST+zfXqpqilnjGWPpK+d88bAtrzWwyVRyLA=;\n\tb=OI9d727PV31K+ji5GALZo6cT6HYFCn1vtLwUV5+/h+hF21x9xF9br/YQbge3rZuByS\n\t3ByoDv/JqgaxEMqbE5cX5rW6pjWjL5dZojdrWW/MuP+S9574FLbrfxuJt/QAjzeRv3Wk\n\twZ+Qs2BwSnjUg+ohh/iyf3UokoYm9lGVR2rYjGQeOb6c/rcDNAsP41wzxZmfY1377bOd\n\teAK0FJfEIJx90DRb6wltHax8f7WatqRSGu4+fAUw4CnzC52TTBAjT8AFG4cOarI5oH9w\n\tc8ybpeczBExqIXFtnPvE+crxJROUM8gHunmMGxcVb8BIgFgm/NRumLX3O6wPKfq/h98q\n\t3g4Q==","X-Gm-Message-State":"AGi0PuZPao20+ZklVO181Jy0tnLX1+Q8SJjVUljIaQephytlSboBiNqq\n\tbD5j+SZMHb39W6O/EVxkjsJWTw==","X-Google-Smtp-Source":"APiQypJg4sF0t5HyQjGsHMMixip1D01iVoNjK5Dir7dkrW0Ay35VOyhn/TtMGzGrE6XWS1xk4+3eBg==","X-Received":"by 2002:a2e:8056:: with SMTP id\n\tp22mr16067899ljg.266.1588029234094; \n\tMon, 27 Apr 2020 16:13:54 -0700 (PDT)","Date":"Tue, 28 Apr 2020 01:13:52 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200427231352.GD1165729@oden.dyn.berto.se>","References":"<20200427220529.1085074-1-niklas.soderlund@ragnatech.se>\n\t<20200427220529.1085074-3-niklas.soderlund@ragnatech.se>\n\t<20200427225340.GB13402@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200427225340.GB13402@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/5] cam: options: Add public\n\tmethod to invalided options","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>","X-List-Received-Date":"Mon, 27 Apr 2020 23:13:55 -0000"}},{"id":4684,"web_url":"https://patchwork.libcamera.org/comment/4684/","msgid":"<20200430164121.GQ5856@pendragon.ideasonboard.com>","date":"2020-04-30T16:41:21","subject":"Re: [libcamera-devel] [PATCH v2 2/5] cam: options: Add public\n\tmethod to invalided options","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nOn Tue, Apr 28, 2020 at 01:13:52AM +0200, Niklas Söderlund wrote:\n> On 2020-04-28 01:53:40 +0300, Laurent Pinchart wrote:\n> > \n> > s/invalided/invalidate/ in the subject line.\n> > \n> > On Tue, Apr 28, 2020 at 12:05:26AM +0200, Niklas Söderlund wrote:\n> > > Extend OptionsBase<T> with a public invalidate() method. This allows\n> > > sub-classes to continue the interpreting of parsed options and\n> > > invalidate them if they find problems with the result.\n> > > \n> > > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > > ---\n> > >  src/cam/options.cpp | 6 ++++++\n> > >  src/cam/options.h   | 2 ++\n> > >  2 files changed, 8 insertions(+)\n> > > \n> > > diff --git a/src/cam/options.cpp b/src/cam/options.cpp\n> > > index 2c56eacf006e9857..77b3cc1f8c5a59e9 100644\n> > > --- a/src/cam/options.cpp\n> > > +++ b/src/cam/options.cpp\n> > > @@ -64,6 +64,12 @@ const OptionValue &OptionsBase<T>::operator[](const T &opt) const\n> > >  \treturn values_.find(opt)->second;\n> > >  }\n> > >  \n> > > +template<typename T>\n> > > +void OptionsBase<T>::invalidate()\n> > > +{\n> > > +\tvalid_ = false;\n> > > +}\n> > > +\n> > >  template<typename T>\n> > >  bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n> > >  \t\t\t\tconst char *optarg)\n> > > diff --git a/src/cam/options.h b/src/cam/options.h\n> > > index 5060fee0c26b896f..8ccbfee48f7ca0b5 100644\n> > > --- a/src/cam/options.h\n> > > +++ b/src/cam/options.h\n> > > @@ -54,6 +54,8 @@ public:\n> > >  \tbool isSet(const T &opt) const;\n> > >  \tconst OptionValue &operator[](const T &opt) const;\n> > >  \n> > > +\tvoid invalidate();\n> > \n> > If this is only for subclasses, the method should be protected. I'm\n> > tempted to go simpler and move the valid_ field protected. What do you\n> > think ? If you want to keep the method I'd make it inline, as it will be\n> > more efficient.\n> \n> My bad the commit message is wrong, it's not for subclassing. It's for \n> processing the KeyValueParser::Options (which inherits from \n> OptionsBase<T>) in subclasses of KeyValueParser.\n> \n> One could move valid_ to protected and the implement \n> KeyValueParser::Options::invalidate() to hide it a bit more. But I don't \n> see the harm in allowing even applications to examine the options parsed \n> from the command line and if it does not like them marking the whole set \n> as invalid. I would not however expose a setValid(bool valid) interface \n> to applications.\n> \n> I have no strong feelings here so I'm open to any solution tho.\n\nIt's an internal API, doesn't matter too much. With the commit message\nupdated,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > > +\n> > >  private:\n> > >  \tfriend class KeyValueParser;\n> > >  \tfriend class OptionsParser;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A511613A8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Apr 2020 18:41:23 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CE322321;\n\tThu, 30 Apr 2020 18:41:22 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"mYbUXNCp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1588264883;\n\tbh=uzePeGnbSu1OT34DAsUO4c5xxqPfOYJveMCmMN0tlyA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mYbUXNCplDEBSoI3TNG2CJ5/y4+dpiT0s5oR5w1DXbPxM8o2Ut8ADz87CmYxKOdw1\n\tDMXQp0O1vnNhqYmCIcQTSeuRlqvKb/WXQgVGxcU4dwyvZjQSdfo8wMYeVBV7U3eRGR\n\tr9gDsxwaZSML8EgnisYsXgQct0DXJOktknj7cxWg=","Date":"Thu, 30 Apr 2020 19:41:21 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200430164121.GQ5856@pendragon.ideasonboard.com>","References":"<20200427220529.1085074-1-niklas.soderlund@ragnatech.se>\n\t<20200427220529.1085074-3-niklas.soderlund@ragnatech.se>\n\t<20200427225340.GB13402@pendragon.ideasonboard.com>\n\t<20200427231352.GD1165729@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200427231352.GD1165729@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH v2 2/5] cam: options: Add public\n\tmethod to invalided options","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>","X-List-Received-Date":"Thu, 30 Apr 2020 16:41:23 -0000"}}]