[{"id":33435,"web_url":"https://patchwork.libcamera.org/comment/33435/","msgid":"<rwaktrc4isyyv77mdcf5t2srvqh4mtkdnmajsmzq5mzdicwfdm@tmigukopefcq>","date":"2025-02-24T09:32:44","subject":"Re: [PATCH 10/15] libipa: awb: Provide read-only accessor to modes_","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the patch. \n\nOn Mon, Feb 24, 2025 at 01:03:58AM +0200, Laurent Pinchart wrote:\n> Derived classes don't need to modify the modes_ member variable. Make\n> it private and provide a read-only accessor.\n\nAs parseModeConfigs() and modes_ are only helper functions (I was\nundecided if they should be added to the Awb class at all - but they\nseem to be quite useful for most implementations) and parseModeConfigs()\nis only called by the derived classes, the derived classes should have\nfull control over the results. I would keep that protected.\n\nRegards,\nStefan\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/ipa/libipa/awb.cpp       | 6 +++---\n>  src/ipa/libipa/awb.h         | 6 +++++-\n>  src/ipa/libipa/awb_bayes.cpp | 6 +++---\n>  src/ipa/libipa/awb_bayes.h   | 2 +-\n>  4 files changed, 12 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\n> index 04cf2d55ed00..0f54655d3234 100644\n> --- a/src/ipa/libipa/awb.cpp\n> +++ b/src/ipa/libipa/awb.cpp\n> @@ -250,9 +250,9 @@ int AwbAlgorithm::parseModeConfigs(const YamlObject &tuningData,\n>   */\n>  \n>  /**\n> - * \\var AwbAlgorithm::modes_\n> - * \\brief Map of all configured modes\n> - * \\sa AwbAlgorithm::parseModeConfigs\n> + * \\fn AwbAlgorithm::modes()\n> + * \\brief Get the available AWB modes\n> + * \\return The map of available AWB modes\n>   */\n>  \n>  } /* namespace ipa */\n> diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\n> index 36c05c37f5e9..017b7a0c3dc1 100644\n> --- a/src/ipa/libipa/awb.h\n> +++ b/src/ipa/libipa/awb.h\n> @@ -54,9 +54,13 @@ protected:\n>  \t\tdouble ctLo;\n>  \t};\n>  \n> -\tstd::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;\n> +\tconst std::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> &modes() const\n> +\t{\n> +\t\treturn modes_;\n> +\t}\n>  \n>  private:\n> +\tstd::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;\n>  \tControlInfoMap::Map controls_;\n>  };\n>  \n> diff --git a/src/ipa/libipa/awb_bayes.cpp b/src/ipa/libipa/awb_bayes.cpp\n> index 9287b884cb95..97bd256526a4 100644\n> --- a/src/ipa/libipa/awb_bayes.cpp\n> +++ b/src/ipa/libipa/awb_bayes.cpp\n> @@ -170,7 +170,7 @@ int AwbBayes::init(const YamlObject &tuningData)\n>  \t\t\t<< \"Failed to parse mode parameter from tuning file\";\n>  \t\treturn ret;\n>  \t}\n> -\tcurrentMode_ = &modes_[controls::AwbAuto];\n> +\tcurrentMode_ = &modes().at(controls::AwbAuto);\n>  \n>  \ttransversePos_ = tuningData[\"transversePos\"].get<double>(0.01);\n>  \ttransverseNeg_ = tuningData[\"transverseNeg\"].get<double>(0.01);\n> @@ -256,8 +256,8 @@ void AwbBayes::handleControls(const ControlList &controls)\n>  {\n>  \tauto mode = controls.get(controls::AwbMode);\n>  \tif (mode) {\n> -\t\tauto it = modes_.find(static_cast<controls::AwbModeEnum>(*mode));\n> -\t\tif (it != modes_.end())\n> +\t\tauto it = modes().find(static_cast<controls::AwbModeEnum>(*mode));\n> +\t\tif (it != modes().end())\n>  \t\t\tcurrentMode_ = &it->second;\n>  \t\telse\n>  \t\t\tLOG(Awb, Error) << \"Unsupported AWB mode \" << *mode;\n> diff --git a/src/ipa/libipa/awb_bayes.h b/src/ipa/libipa/awb_bayes.h\n> index 23bf88061118..b74201b542fb 100644\n> --- a/src/ipa/libipa/awb_bayes.h\n> +++ b/src/ipa/libipa/awb_bayes.h\n> @@ -59,7 +59,7 @@ private:\n>  \tdouble transversePos_;\n>  \tdouble transverseNeg_;\n>  \n> -\tModeConfig *currentMode_ = nullptr;\n> +\tconst ModeConfig *currentMode_ = nullptr;\n>  };\n>  \n>  } /* namespace ipa */\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 80C45C324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Feb 2025 09:32:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 91460686CF;\n\tMon, 24 Feb 2025 10:32:48 +0100 (CET)","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 7710B686A6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Feb 2025 10:32:47 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:c02b:2ffa:8001:90d4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 16B47220;\n\tMon, 24 Feb 2025 10:31:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QE1o6NZo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740389481;\n\tbh=FELEHkRTch0cc91haLIac/xOSkJKk/hnTyrivIiDq0M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QE1o6NZo8qmgrSeDLdTR1yfZ06DvEr0KFYyLSt7Eo16vgWrKiiINsnOinjuVJYzvQ\n\t1pHM2Zixx2TUsfTwpJqKa9hPOJQuoItgjx2xN56Q4LXrg4xxoQkS5z4/6N7o36tghr\n\t7e5evN06K5VFbKm/jZZEsSbh8bkhjX4DTEqNffms=","Date":"Mon, 24 Feb 2025 10:32:44 +0100","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 10/15] libipa: awb: Provide read-only accessor to modes_","Message-ID":"<rwaktrc4isyyv77mdcf5t2srvqh4mtkdnmajsmzq5mzdicwfdm@tmigukopefcq>","References":"<20250223230403.1226-1-laurent.pinchart@ideasonboard.com>\n\t<20250223230403.1226-11-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250223230403.1226-11-laurent.pinchart@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33437,"web_url":"https://patchwork.libcamera.org/comment/33437/","msgid":"<20250224093534.GD29646@pendragon.ideasonboard.com>","date":"2025-02-24T09:35:34","subject":"Re: [PATCH 10/15] libipa: awb: Provide read-only accessor to modes_","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Feb 24, 2025 at 10:32:44AM +0100, Stefan Klug wrote:\n> Hi Laurent,\n> \n> Thank you for the patch. \n> \n> On Mon, Feb 24, 2025 at 01:03:58AM +0200, Laurent Pinchart wrote:\n> > Derived classes don't need to modify the modes_ member variable. Make\n> > it private and provide a read-only accessor.\n> \n> As parseModeConfigs() and modes_ are only helper functions (I was\n> undecided if they should be added to the Awb class at all - but they\n> seem to be quite useful for most implementations) and parseModeConfigs()\n> is only called by the derived classes, the derived classes should have\n> full control over the results. I would keep that protected.\n\nOK, I'll drop this.\n\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/ipa/libipa/awb.cpp       | 6 +++---\n> >  src/ipa/libipa/awb.h         | 6 +++++-\n> >  src/ipa/libipa/awb_bayes.cpp | 6 +++---\n> >  src/ipa/libipa/awb_bayes.h   | 2 +-\n> >  4 files changed, 12 insertions(+), 8 deletions(-)\n> > \n> > diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\n> > index 04cf2d55ed00..0f54655d3234 100644\n> > --- a/src/ipa/libipa/awb.cpp\n> > +++ b/src/ipa/libipa/awb.cpp\n> > @@ -250,9 +250,9 @@ int AwbAlgorithm::parseModeConfigs(const YamlObject &tuningData,\n> >   */\n> >  \n> >  /**\n> > - * \\var AwbAlgorithm::modes_\n> > - * \\brief Map of all configured modes\n> > - * \\sa AwbAlgorithm::parseModeConfigs\n> > + * \\fn AwbAlgorithm::modes()\n> > + * \\brief Get the available AWB modes\n> > + * \\return The map of available AWB modes\n> >   */\n> >  \n> >  } /* namespace ipa */\n> > diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\n> > index 36c05c37f5e9..017b7a0c3dc1 100644\n> > --- a/src/ipa/libipa/awb.h\n> > +++ b/src/ipa/libipa/awb.h\n> > @@ -54,9 +54,13 @@ protected:\n> >  \t\tdouble ctLo;\n> >  \t};\n> >  \n> > -\tstd::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;\n> > +\tconst std::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> &modes() const\n> > +\t{\n> > +\t\treturn modes_;\n> > +\t}\n> >  \n> >  private:\n> > +\tstd::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;\n> >  \tControlInfoMap::Map controls_;\n> >  };\n> >  \n> > diff --git a/src/ipa/libipa/awb_bayes.cpp b/src/ipa/libipa/awb_bayes.cpp\n> > index 9287b884cb95..97bd256526a4 100644\n> > --- a/src/ipa/libipa/awb_bayes.cpp\n> > +++ b/src/ipa/libipa/awb_bayes.cpp\n> > @@ -170,7 +170,7 @@ int AwbBayes::init(const YamlObject &tuningData)\n> >  \t\t\t<< \"Failed to parse mode parameter from tuning file\";\n> >  \t\treturn ret;\n> >  \t}\n> > -\tcurrentMode_ = &modes_[controls::AwbAuto];\n> > +\tcurrentMode_ = &modes().at(controls::AwbAuto);\n> >  \n> >  \ttransversePos_ = tuningData[\"transversePos\"].get<double>(0.01);\n> >  \ttransverseNeg_ = tuningData[\"transverseNeg\"].get<double>(0.01);\n> > @@ -256,8 +256,8 @@ void AwbBayes::handleControls(const ControlList &controls)\n> >  {\n> >  \tauto mode = controls.get(controls::AwbMode);\n> >  \tif (mode) {\n> > -\t\tauto it = modes_.find(static_cast<controls::AwbModeEnum>(*mode));\n> > -\t\tif (it != modes_.end())\n> > +\t\tauto it = modes().find(static_cast<controls::AwbModeEnum>(*mode));\n> > +\t\tif (it != modes().end())\n> >  \t\t\tcurrentMode_ = &it->second;\n> >  \t\telse\n> >  \t\t\tLOG(Awb, Error) << \"Unsupported AWB mode \" << *mode;\n> > diff --git a/src/ipa/libipa/awb_bayes.h b/src/ipa/libipa/awb_bayes.h\n> > index 23bf88061118..b74201b542fb 100644\n> > --- a/src/ipa/libipa/awb_bayes.h\n> > +++ b/src/ipa/libipa/awb_bayes.h\n> > @@ -59,7 +59,7 @@ private:\n> >  \tdouble transversePos_;\n> >  \tdouble transverseNeg_;\n> >  \n> > -\tModeConfig *currentMode_ = nullptr;\n> > +\tconst ModeConfig *currentMode_ = nullptr;\n> >  };\n> >  \n> >  } /* namespace ipa */","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 CBF85C32A9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Feb 2025 09:35:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 800C0686D1;\n\tMon, 24 Feb 2025 10:35:53 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C455E686A6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Feb 2025 10:35:51 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 718BD220;\n\tMon, 24 Feb 2025 10:34:25 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"qFPPnqfm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740389665;\n\tbh=DuY3EOJ1Xx2hCx8MsTsz/3Rff/JB94iIjeIc3nWOqxM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qFPPnqfmF0SSMs79uCu9foW0J2zfW9R/B7FQzbmcrqBiN/yAgBtE797vDMBeR0KRL\n\tgHNycAQh+jOcLCV4kqoX4wnyD/UOp236CLZdiiFTw3PY/ISkdeUQfvQxF8pXkK2KzI\n\tTudE0p3YOlhxVbyPd8SnfdKHPLCokajO7i5/ofSA=","Date":"Mon, 24 Feb 2025 11:35:34 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 10/15] libipa: awb: Provide read-only accessor to modes_","Message-ID":"<20250224093534.GD29646@pendragon.ideasonboard.com>","References":"<20250223230403.1226-1-laurent.pinchart@ideasonboard.com>\n\t<20250223230403.1226-11-laurent.pinchart@ideasonboard.com>\n\t<rwaktrc4isyyv77mdcf5t2srvqh4mtkdnmajsmzq5mzdicwfdm@tmigukopefcq>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<rwaktrc4isyyv77mdcf5t2srvqh4mtkdnmajsmzq5mzdicwfdm@tmigukopefcq>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]