diff options
author | Daniel Semkowicz via libcamera-devel <libcamera-devel@lists.libcamera.org> | 2022-07-13 10:43:11 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2022-07-14 20:12:17 +0200 |
commit | c04ead82ce822ef6b1d9fb4ac1e7b8a7968a5169 (patch) | |
tree | 803152939cde4fb2b127e77acd82e98be8181c01 /src/ipa/libipa/module.h | |
parent | 971dc5858d0823c6a0b08027727088eebb4350b3 (diff) |
ipa: module: Add getAlgorithm() method
This function allows to get pointer to the algorithm of specific type
from the list of loaded algorithms.
Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
Diffstat (limited to 'src/ipa/libipa/module.h')
-rw-r--r-- | src/ipa/libipa/module.h | 17 |
1 files changed, 17 insertions, 0 deletions
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 <list> #include <memory> #include <string> +#include <typeinfo> #include <vector> #include <libcamera/base/log.h> @@ -43,6 +44,22 @@ public: return algorithms_; } + template<typename AlgoType> + AlgoType *getAlgorithm() const + { + auto isSameType = [](const std::unique_ptr<Algorithm<Module>> &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<AlgoType *>(result->get()); + } else { + return nullptr; + } + } + int createAlgorithms(Context &context, const YamlObject &algorithms) { const auto &list = algorithms.asList(); |