{"id":16487,"url":"https://patchwork.libcamera.org/api/1.1/patches/16487/?format=json","web_url":"https://patchwork.libcamera.org/patch/16487/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220630143543.39599-6-dse@thaumatec.com>","date":"2022-06-30T14:35:40","name":"[libcamera-devel,5/8] ipa: module: Add getAlgorithm() method","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"11f005acea425b931dcfaad96e048bdcc59235d4","submitter":{"id":126,"url":"https://patchwork.libcamera.org/api/1.1/people/126/?format=json","name":"Daniel Semkowicz","email":"dse@thaumatec.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16487/mbox/","series":[{"id":3239,"url":"https://patchwork.libcamera.org/api/1.1/series/3239/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3239","date":"2022-06-30T14:35:35","name":"ipa: rkisp1: Add autofocus algorithm","version":1,"mbox":"https://patchwork.libcamera.org/series/3239/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16487/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16487/checks/","tags":{},"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 3CDFCBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 14:36:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E25316565D;\n\tThu, 30 Jun 2022 16:36:01 +0200 (CEST)","from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BFE1F6565A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 16:35:59 +0200 (CEST)","by mail-wr1-x435.google.com with SMTP id i1so23120751wrb.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 07:35:59 -0700 (PDT)","from localhost.localdomain (ip092042140082.rev.nessus.at.\n\t[92.42.140.82]) by smtp.gmail.com with ESMTPSA id\n\tr5-20020a05600c320500b0039db500714fsm6405945wmp.6.2022.06.30.07.35.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 30 Jun 2022 07:35:59 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656599761;\n\tbh=tePFJbqNxQG4rqyc5U31SCyuAbtuxBb9RDJ4Ws7GtgI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Zde3PUg9gvAtZDfpSZOs/TjWF0my0gIXxghAqgmkNSNWnCY5+yZbGUvWOAD7oolcf\n\tGWhW+6bTyDMKn26q5jg9bPXNrvR7AlczYeAZpuGs0I5lh27GdaNUohELLtWlucO+wo\n\tOS0nlQuRRAPuH6EFlTiNtKCRpBbVR4Wk3pNga8EjjDztyE/jCk+La3lePrl3HAPzMd\n\tbQbeOOMrgJv/DfIbEVqVT/k9tGyhdjovjddeCpSiiAFZk5Z6As/YhTGRPapSjY9Uiy\n\taeXi1ncqjacXR2HezUCVoZoHGm2YnGVYKZbBL7rEx2Ik2aFMfAP7h2IlAkJCoJfCYq\n\tnK2pBFrAXYRig==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=X7GLsLrVPX5OXkhXrPOHqOO0DAVsribVHxl4TC4vZMA=;\n\tb=O1a/ofYvJwKSRGJT/783DvV0l7NdDQ89KfDHOl8gxmIn7siIqS6/XTmkQu7/OZ9fFF\n\tm9FkzP6awWnYNOmgvqwWvilNdOwOFhdWCz3sWlrrXu7qcQacr332G3s6+O+7AqXUFLlb\n\tcSIFUPnXLZVlNgE900EszMPRyV4+stFbW9+p4q8l1wuZXvicUM4W7PxaVWVIQvkLcAMI\n\taPayjQCfgyyUlWuAnMLEU22hEf6j9KvTHLKH+EvITAYwnOo23itylGoSSDAuOdskaBn2\n\tAy34+/NUz2vf85nTtWpKMyeZSr8o4PSXLRs8HpUmJxloT4Cx33TFl5goMrRQIM6vQsWZ\n\tIz6A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=thaumatec-com.20210112.gappssmtp.com\n\theader.i=@thaumatec-com.20210112.gappssmtp.com header.b=\"O1a/ofYv\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=X7GLsLrVPX5OXkhXrPOHqOO0DAVsribVHxl4TC4vZMA=;\n\tb=HYbEvXGquN4CAb08pH6tqh6R/Fwv+WnuST4sNbMU8U73rJl4FtlJEJaP3T0sjjv9hz\n\tvpcKmDWbDblrsoPc4DnoGroFFHiepYkK4Zl7MjIMvJ9AbziaGvuRyAUff9emfjmf1WhG\n\t3srVhwO9gXPU95XG8KlwIWdEZF992DnZsmim7reCbDnYKinc/kHh7JPWG6BQHVA0bcc6\n\tuFKewyZiO8rDpuZMeZ/nviQDmqNdCnc6KF9vjo/q0vKIxznyGmtA0gB1NeR+KYwwufg5\n\ttn4ysCwyw+f3HPJ20Ma21K+m1AMZjIKKfz4OTtl7rEAX/Oykmo//hTtKb3HZcMMjILXU\n\t6Vww==","X-Gm-Message-State":"AJIora8WcPfsCYqWO2HojIrS7467krLwnCqyaaW6z77dycis4E5RmqQi\n\tBYi6s+0OjVuArzJRc0PxKVyuuoAEpCHAHA==","X-Google-Smtp-Source":"AGRyM1t2Avvl71wftwk5/F6VKjqGAcb5Dfm7AHuDfcCbTEsSiczmjx+C0FbA3ytS7gDZd8Plq9ritA==","X-Received":"by 2002:a5d:534f:0:b0:21a:3695:f52 with SMTP id\n\tt15-20020a5d534f000000b0021a36950f52mr8504858wrv.620.1656599759490; \n\tThu, 30 Jun 2022 07:35:59 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 30 Jun 2022 16:35:40 +0200","Message-Id":"<20220630143543.39599-6-dse@thaumatec.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220630143543.39599-1-dse@thaumatec.com>","References":"<20220630143543.39599-1-dse@thaumatec.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 5/8] ipa: module: Add getAlgorithm() 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":"Daniel Semkowicz via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Daniel Semkowicz <dse@thaumatec.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This function allows to get pointer to the algorithm of specific type\nfrom the list of loaded algorithms.\n\nSigned-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(+)","diff":"diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\nindex 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\ndiff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\nindex 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+\t}\n+\n \tint createAlgorithms(Context &context, const YamlObject &algorithms)\n \t{\n \t\tconst auto &list = algorithms.asList();\n","prefixes":["libcamera-devel","5/8"]}