[{"id":23886,"web_url":"https://patchwork.libcamera.org/comment/23886/","msgid":"<20220714183528.jlvipc3td2hk4nwl@uno.localdomain>","date":"2022-07-14T18:35:28","subject":"Re: [libcamera-devel] [PATCH v2 05/11] ipa: module: Add\n\tgetAlgorithm() method","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"I'm not really expert of this part, this looks right, I'm only\nsurprised we didn't have one already.. let me cc Laurent which I\npresume implemented the algorith registration mechinery.\n\n\nOn Wed, Jul 13, 2022 at 10:43:11AM +0200, Daniel Semkowicz via libcamera-devel wrote:\n> This function allows to get pointer to the algorithm of specific type\n> from the list of loaded algorithms.\n>\n> Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>\n> ---\n>  src/ipa/libipa/module.cpp |  7 +++++++\n>  src/ipa/libipa/module.h   | 17 +++++++++++++++++\n>  2 files changed, 24 insertions(+)\n>\n> diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\n> index 77352104..7c0680fd 100644\n> --- a/src/ipa/libipa/module.cpp\n> +++ b/src/ipa/libipa/module.cpp\n> @@ -83,6 +83,13 @@ namespace ipa {\n>   * \\return The list of instantiated algorithms\n>   */\n>\n> +/**\n> + * \\fn Module::getAlgorithm()\n> + * \\brief Find and return the algorithm of requested type\n> + * \\tparam AlgoType Algorithm type you want to retrieve\n> + * \\return Pointer to the algorithm if found, else nullptr\n> + */\n> +\n>  /**\n>   * \\fn Module::createAlgorithms()\n>   * \\brief Create algorithms from YAML configuration data\n> diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\n> index 4149a353..c4974635 100644\n> --- a/src/ipa/libipa/module.h\n> +++ b/src/ipa/libipa/module.h\n> @@ -10,6 +10,7 @@\n>  #include <list>\n>  #include <memory>\n>  #include <string>\n> +#include <typeinfo>\n>  #include <vector>\n>\n>  #include <libcamera/base/log.h>\n> @@ -43,6 +44,22 @@ public:\n>  \t\treturn algorithms_;\n>  \t}\n>\n> +\ttemplate<typename AlgoType>\n> +\tAlgoType *getAlgorithm() const\n> +\t{\n> +\t\tauto isSameType = [](const std::unique_ptr<Algorithm<Module>> &algoPtr) {\n> +\t\t\treturn typeid(*algoPtr.get()) == typeid(AlgoType);\n> +\t\t};\n> +\n> +\t\tauto result = std::find_if(begin(algorithms_), end(algorithms_), isSameType);\n> +\n> +\t\tif (result != std::end(algorithms_)) {\n> +\t\t\treturn static_cast<AlgoType *>(result->get());\n> +\t\t} else {\n> +\t\t\treturn nullptr;\n> +\t\t}\n\n                if (result != std::end(algorithms_))\n                        return static_cast<AlgoType *>(result->get());\n\n                return nullptr;\n\n\n> +\t}\n> +\n>  \tint createAlgorithms(Context &context, const YamlObject &algorithms)\n>  \t{\n>  \t\tconst auto &list = algorithms.asList();\n> --\n> 2.34.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 C5971BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Jul 2022 18:35:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F8FA6330E;\n\tThu, 14 Jul 2022 20:35:32 +0200 (CEST)","from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::222])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 95EC16330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Jul 2022 20:35:30 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id CFC3E40003;\n\tThu, 14 Jul 2022 18:35:29 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657823732;\n\tbh=sEp/WiRjE4xZDGy8dfjto7O3MqfxedXHke5a1yG8S1U=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=aLuQrHRHcey63R8uAF8WmeTJg2LUAZTmyrf41/ALKRhmR+LeTSfr4mTsOkgZ/S5Tr\n\tQQ8SbmAmIrob+2xK8GziOoQsyD3RHW3hpeY0Ty2RZIrLx7Vxv2tPIZfsVjUH41qfub\n\tJPYhh4H8c0u7io3n77PbLQdIfs810sWSbLcBBPuUnU78a266s3WZ0hxqh6kiVXtP+k\n\tGqowombsiG24yAK3hLW7RLjx2kA0Efoq9ZERp6FzsN62Zv5odfZaaVpUQ/Heiagp2J\n\t5t1SXR2gpl3UM8ZK2AFLH8yy44rb7r3PUlGvI17CmU0KqHU/lltBoVGf3S4M2/hfPp\n\tJy8lOg/MFNQ3A==","Date":"Thu, 14 Jul 2022 20:35:28 +0200","To":"Daniel Semkowicz <dse@thaumatec.com>","Message-ID":"<20220714183528.jlvipc3td2hk4nwl@uno.localdomain>","References":"<20220713084317.24268-1-dse@thaumatec.com>\n\t<20220713084317.24268-6-dse@thaumatec.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220713084317.24268-6-dse@thaumatec.com>","Subject":"Re: [libcamera-devel] [PATCH v2 05/11] ipa: module: Add\n\tgetAlgorithm() method","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23904,"web_url":"https://patchwork.libcamera.org/comment/23904/","msgid":"<YtC4fXEf2rKO+PjN@pendragon.ideasonboard.com>","date":"2022-07-15T00:44:45","subject":"Re: [libcamera-devel] [PATCH v2 05/11] ipa: module: Add\n\tgetAlgorithm() method","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jul 14, 2022 at 08:35:28PM +0200, Jacopo Mondi wrote:\n> I'm not really expert of this part, this looks right, I'm only\n> surprised we didn't have one already.. let me cc Laurent which I\n> presume implemented the algorith registration mechinery.\n\nDepending on the outcome of the discussion in 06/11, this patch may not\nbe needed.\n\n> On Wed, Jul 13, 2022 at 10:43:11AM +0200, Daniel Semkowicz via libcamera-devel wrote:\n> > This function allows to get pointer to the algorithm of specific type\n> > from the list of loaded algorithms.\n> >\n> > Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>\n> > ---\n> >  src/ipa/libipa/module.cpp |  7 +++++++\n> >  src/ipa/libipa/module.h   | 17 +++++++++++++++++\n> >  2 files changed, 24 insertions(+)\n> >\n> > diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\n> > index 77352104..7c0680fd 100644\n> > --- a/src/ipa/libipa/module.cpp\n> > +++ b/src/ipa/libipa/module.cpp\n> > @@ -83,6 +83,13 @@ namespace ipa {\n> >   * \\return The list of instantiated algorithms\n> >   */\n> >\n> > +/**\n> > + * \\fn Module::getAlgorithm()\n> > + * \\brief Find and return the algorithm of requested type\n> > + * \\tparam AlgoType Algorithm type you want to retrieve\n> > + * \\return Pointer to the algorithm if found, else nullptr\n> > + */\n> > +\n> >  /**\n> >   * \\fn Module::createAlgorithms()\n> >   * \\brief Create algorithms from YAML configuration data\n> > diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\n> > index 4149a353..c4974635 100644\n> > --- a/src/ipa/libipa/module.h\n> > +++ b/src/ipa/libipa/module.h\n> > @@ -10,6 +10,7 @@\n> >  #include <list>\n> >  #include <memory>\n> >  #include <string>\n> > +#include <typeinfo>\n> >  #include <vector>\n> >\n> >  #include <libcamera/base/log.h>\n> > @@ -43,6 +44,22 @@ public:\n> >  \t\treturn algorithms_;\n> >  \t}\n> >\n> > +\ttemplate<typename AlgoType>\n> > +\tAlgoType *getAlgorithm() const\n> > +\t{\n> > +\t\tauto isSameType = [](const std::unique_ptr<Algorithm<Module>> &algoPtr) {\n> > +\t\t\treturn typeid(*algoPtr.get()) == typeid(AlgoType);\n> > +\t\t};\n> > +\n> > +\t\tauto result = std::find_if(begin(algorithms_), end(algorithms_), isSameType);\n> > +\n> > +\t\tif (result != std::end(algorithms_)) {\n> > +\t\t\treturn static_cast<AlgoType *>(result->get());\n> > +\t\t} else {\n> > +\t\t\treturn nullptr;\n> > +\t\t}\n> \n>                 if (result != std::end(algorithms_))\n>                         return static_cast<AlgoType *>(result->get());\n> \n>                 return nullptr;\n> \n> > +\t}\n> > +\n> >  \tint createAlgorithms(Context &context, const YamlObject &algorithms)\n> >  \t{\n> >  \t\tconst auto &list = algorithms.asList();","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 00955BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 00:45:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AAD5B63312;\n\tFri, 15 Jul 2022 02:45:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1954E60489\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 02:45:17 +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 AB6DD9DA;\n\tFri, 15 Jul 2022 02:45:16 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657845918;\n\tbh=dFu+lo+zycQgkTU1npmkGPWepCdT5OboCKuUCUyG+aw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=OviQIP+wBufgPByCMT/HPAa5GZBVaIG2DmYl4F6i8iWixB1CZdLCSayX+IssmoMuX\n\tyslXP4HPIPOjGstcULE1RFhAg1Tv+wImysKvh4W1ioevMZu0aMIEf+6yKLeDvUtKN2\n\t7zffkFzYhpyHkcAtxFtFBXy+ohqUTwGSJ1XaSUWm+7tLh39cdQ7RJ1BrCIr45qDPFB\n\tJDsgIdWe0lQw8ZPgqcHoaUKeH6orgDz0EmkZ6Ivom0tNk9va64ikjEDLUZLRRw0Igo\n\tIj3XDuQ/+NJ5D6xjNMGIMfkHNJfyZ3JfpkRGsDbgYXWftbi5TymtolzliOivd1DQ4w\n\tZ8fyqA6iUu6BQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657845916;\n\tbh=dFu+lo+zycQgkTU1npmkGPWepCdT5OboCKuUCUyG+aw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VhMbtEJZWYU+qI2VEVCWJWIHEC7gudyhw33EWd1wbgxkKROqst5j3n+sUCgAWP0en\n\t1whIC1CMSjc88IrGil8cFK8+W2jdLAksN11E6MpcCHIQSgfEwOl1ifvR+Il7h1TUmi\n\tQ3cZvQPWUwO+cAIa73QJVVZCVN4GZH4D2W+ItHeM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VhMbtEJZ\"; dkim-atps=neutral","Date":"Fri, 15 Jul 2022 03:44:45 +0300","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YtC4fXEf2rKO+PjN@pendragon.ideasonboard.com>","References":"<20220713084317.24268-1-dse@thaumatec.com>\n\t<20220713084317.24268-6-dse@thaumatec.com>\n\t<20220714183528.jlvipc3td2hk4nwl@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220714183528.jlvipc3td2hk4nwl@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH v2 05/11] ipa: module: Add\n\tgetAlgorithm() method","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]