From patchwork Wed Jul 13 08:43:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16603 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 9322FBE173 for ; Wed, 13 Jul 2022 08:43:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43B1363322; Wed, 13 Jul 2022 10:43:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657701824; 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=ATU5LOLO29+AZLbpDoBkOIyJrRRaMH+n5UnsDqCxLgLZiU3/TDYGh8ouJbU9JO+r1 mdDLhGzgDRw+F1rSnCYxL9SWYELB5kONwoWidpcHSFXaEQamryRGUcpDSrV6Ae6e3r gQgN0UY7lw2sPEiVUqckD/ymSEPdVsTjL/5Lk0AuWOpVq3jtKkMZaqBXpfQy+/qgT5 /qrqIv7S9GOp4hbo+l5ZsnTec7VSiZUfMxT66NaLp/xYqLP2WuE8n7mkzQwc4tVwU+ Pn+WniGgrxNxgd8JJbtRRE53QQ+5VOnatVMdw7xMGLIH6gc9lmuaZYf59lhZO2d/g6 yfK4AIw+90NCg== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E4A063317 for ; Wed, 13 Jul 2022 10:43:42 +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="ZZ5CBhwQ"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id v14so14473691wra.5 for ; Wed, 13 Jul 2022 01:43:42 -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=ZZ5CBhwQawFHtX16y12lchrWFO8RUPBOZx4pRywl3ZIoS53/UHs5m9Qmn0GEdnCDm6 +EYncmZ57x0wvjeJQlVo5sXukJCgDiu/QtwSl0EV2pynS+Eb5c2EEExTxwtOfOUa9wLB WhuRxhp4hZLibRa3KgTgH8hL5iWc6dHZHwaEjGyIEY+wSLDw+ckp22GBrg1Dbu0yqiuK 8FSvoQbYF+Bx49p2J0XFbcDdaqxkWzFepsvISgohv+1wMiKWWLnh/DMZeA8g2LOgX7ZF d+eru6Zd5eVb4y9D7nM5mOoJtXVFPKUUHSn3c/DI7sTXw1v1dg+Fh9HPVIFT9909uh9U zuxA== 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=t1fb6KzRSUBjA0Lk2K7MKEGSOLoKBzoQvdPeEuZt8Bmk6G/uxKkaxa2PLSC2/n5ZnA UFMzXygi8ktbLWZkmcQ0PQ88sUi0TroVhdOYWxS5vwKvx+qesg1KxXhA1YpK1cy9GqMG xL5T6KAMMRDysVF1nXiSxWhaJ6XLyp4KEIQ2ALVtpuxMWsd2wX9PuyLaP9qcKd38cbHu 1u7OpabEJJpYpNWO74aTq5hE+mSoC62/TUOBjmp8SShP6md+soFHbwFXY94FFYtXET4F hh5BTNYtAOWDRfCj57AuWrrTHjX39rpStkx2uAhvHR3blISlVzx8INdnDcYTG5++AV0I dWbw== X-Gm-Message-State: AJIora+fF+4yeUhxFfrEd87e+4x/RvHSodzcCkQPcRlEsUrjl/gYfDgM 9H4bfeHrC2xbMZ/KVHRDCxA3J3IT+7FEVQ== X-Google-Smtp-Source: AGRyM1tVskmINzu3guNp1TFGe2rfjdThLbzDSzQRbGej+MsWh2cln3roVNIzjwfQXfpEWpxHZ8gXKA== X-Received: by 2002:adf:ed10:0:b0:21d:a9a1:3526 with SMTP id a16-20020adfed10000000b0021da9a13526mr2064015wro.403.1657701822265; Wed, 13 Jul 2022 01:43:42 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id bg32-20020a05600c3ca000b003a04d19dab3sm5667468wmb.3.2022.07.13.01.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 01:43:41 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Jul 2022 10:43:11 +0200 Message-Id: <20220713084317.24268-6-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713084317.24268-1-dse@thaumatec.com> References: <20220713084317.24268-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 05/11] 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();