summaryrefslogtreecommitdiff
path: root/src/ipa/libipa/module.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/libipa/module.h')
-rw-r--r--src/ipa/libipa/module.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h
index c4d77812..05f39801 100644
--- a/src/ipa/libipa/module.h
+++ b/src/ipa/libipa/module.h
@@ -7,6 +7,12 @@
#pragma once
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "algorithm.h"
+
namespace libcamera {
namespace ipa {
@@ -23,6 +29,33 @@ public:
using Stats = _Stats;
virtual ~Module() {}
+
+ static std::unique_ptr<Algorithm<Module>> createAlgorithm(const std::string &name)
+ {
+ for (const AlgorithmFactoryBase<Module> *factory : factories()) {
+ if (factory->name() == name)
+ return factory->create();
+ }
+
+ return nullptr;
+ }
+
+ static void registerAlgorithm(AlgorithmFactoryBase<Module> *factory)
+ {
+ factories().push_back(factory);
+ }
+
+private:
+ static std::vector<AlgorithmFactoryBase<Module> *> &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<AlgorithmFactoryBase<Module> *> factories;
+ return factories;
+ }
};
} /* namespace ipa */