From patchwork Thu Jun 30 14:35:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16487 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3CDFCBE173 for ; Thu, 30 Jun 2022 14:36:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E25316565D; Thu, 30 Jun 2022 16:36:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656599761; bh=tePFJbqNxQG4rqyc5U31SCyuAbtuxBb9RDJ4Ws7GtgI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Zde3PUg9gvAtZDfpSZOs/TjWF0my0gIXxghAqgmkNSNWnCY5+yZbGUvWOAD7oolcf GWhW+6bTyDMKn26q5jg9bPXNrvR7AlczYeAZpuGs0I5lh27GdaNUohELLtWlucO+wo OS0nlQuRRAPuH6EFlTiNtKCRpBbVR4Wk3pNga8EjjDztyE/jCk+La3lePrl3HAPzMd bQbeOOMrgJv/DfIbEVqVT/k9tGyhdjovjddeCpSiiAFZk5Z6As/YhTGRPapSjY9Uiy aeXi1ncqjacXR2HezUCVoZoHGm2YnGVYKZbBL7rEx2Ik2aFMfAP7h2IlAkJCoJfCYq nK2pBFrAXYRig== Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BFE1F6565A for ; Thu, 30 Jun 2022 16:35:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="O1a/ofYv"; dkim-atps=neutral Received: by mail-wr1-x435.google.com with SMTP id i1so23120751wrb.11 for ; Thu, 30 Jun 2022 07:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X7GLsLrVPX5OXkhXrPOHqOO0DAVsribVHxl4TC4vZMA=; b=O1a/ofYvJwKSRGJT/783DvV0l7NdDQ89KfDHOl8gxmIn7siIqS6/XTmkQu7/OZ9fFF m9FkzP6awWnYNOmgvqwWvilNdOwOFhdWCz3sWlrrXu7qcQacr332G3s6+O+7AqXUFLlb cSIFUPnXLZVlNgE900EszMPRyV4+stFbW9+p4q8l1wuZXvicUM4W7PxaVWVIQvkLcAMI aPayjQCfgyyUlWuAnMLEU22hEf6j9KvTHLKH+EvITAYwnOo23itylGoSSDAuOdskaBn2 Ay34+/NUz2vf85nTtWpKMyeZSr8o4PSXLRs8HpUmJxloT4Cx33TFl5goMrRQIM6vQsWZ Iz6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X7GLsLrVPX5OXkhXrPOHqOO0DAVsribVHxl4TC4vZMA=; b=HYbEvXGquN4CAb08pH6tqh6R/Fwv+WnuST4sNbMU8U73rJl4FtlJEJaP3T0sjjv9hz vpcKmDWbDblrsoPc4DnoGroFFHiepYkK4Zl7MjIMvJ9AbziaGvuRyAUff9emfjmf1WhG 3srVhwO9gXPU95XG8KlwIWdEZF992DnZsmim7reCbDnYKinc/kHh7JPWG6BQHVA0bcc6 uFKewyZiO8rDpuZMeZ/nviQDmqNdCnc6KF9vjo/q0vKIxznyGmtA0gB1NeR+KYwwufg5 tn4ysCwyw+f3HPJ20Ma21K+m1AMZjIKKfz4OTtl7rEAX/Oykmo//hTtKb3HZcMMjILXU 6Vww== X-Gm-Message-State: AJIora8WcPfsCYqWO2HojIrS7467krLwnCqyaaW6z77dycis4E5RmqQi BYi6s+0OjVuArzJRc0PxKVyuuoAEpCHAHA== X-Google-Smtp-Source: AGRyM1t2Avvl71wftwk5/F6VKjqGAcb5Dfm7AHuDfcCbTEsSiczmjx+C0FbA3ytS7gDZd8Plq9ritA== X-Received: by 2002:a5d:534f:0:b0:21a:3695:f52 with SMTP id t15-20020a5d534f000000b0021a36950f52mr8504858wrv.620.1656599759490; Thu, 30 Jun 2022 07:35:59 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r5-20020a05600c320500b0039db500714fsm6405945wmp.6.2022.06.30.07.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This function allows to get pointer to the algorithm of specific type from the list of loaded algorithms. Signed-off-by: Daniel Semkowicz --- src/ipa/libipa/module.cpp | 7 +++++++ src/ipa/libipa/module.h | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp index 77352104..7c0680fd 100644 --- a/src/ipa/libipa/module.cpp +++ b/src/ipa/libipa/module.cpp @@ -83,6 +83,13 @@ namespace ipa { * \return The list of instantiated algorithms */ +/** + * \fn Module::getAlgorithm() + * \brief Find and return the algorithm of requested type + * \tparam AlgoType Algorithm type you want to retrieve + * \return Pointer to the algorithm if found, else nullptr + */ + /** * \fn Module::createAlgorithms() * \brief Create algorithms from YAML configuration data diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h index 4149a353..c4974635 100644 --- a/src/ipa/libipa/module.h +++ b/src/ipa/libipa/module.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,22 @@ public: return algorithms_; } + template + AlgoType *getAlgorithm() const + { + auto isSameType = [](const std::unique_ptr> &algoPtr) { + return typeid(*algoPtr.get()) == typeid(AlgoType); + }; + + auto result = std::find_if(begin(algorithms_), end(algorithms_), isSameType); + + if (result != std::end(algorithms_)) { + return static_cast(result->get()); + } else { + return nullptr; + } + } + int createAlgorithms(Context &context, const YamlObject &algorithms) { const auto &list = algorithms.asList();