/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2022, Ideas On Board * * module.h - IPA module */ #pragma once #include #include #include #include "algorithm.h" namespace libcamera { namespace ipa { template class Module { public: using Context = _Context; using FrameContext = _FrameContext; using Config = _Config; using Params = _Params; using Stats = _Stats; virtual ~Module() {} static std::unique_ptr> createAlgorithm(const std::string &name) { for (const AlgorithmFactoryBase *factory : factories()) { if (factory->name() == name) return factory->create(); } return nullptr; } static void registerAlgorithm(AlgorithmFactoryBase *factory) { factories().push_back(factory); } private: static std::vector *> &factories() { /* * The static factories map is defined inside the function to ensure * it gets initialized on first use, without any dependency on * link order. */ static std::vector *> factories; return factories; } }; } /* namespace ipa */ } /* namespace libcamera */