Sundry tweaks to aos/vision libs
Change-Id: Ia5578dcf2d42ac53b81af239bf329eb084fcf1d9
diff --git a/aos/common/util/global_factory.h b/aos/common/util/global_factory.h
index 148fc1e..aac49bb 100644
--- a/aos/common/util/global_factory.h
+++ b/aos/common/util/global_factory.h
@@ -44,7 +44,7 @@
class GlobalFactory {
public:
using FactoryFunction =
- std::function<std::unique_ptr<BaseClass>(FactoryArgs&&...)>;
+ std::function<std::unique_ptr<BaseClass>(FactoryArgs &&...)>;
// Gets the factory function by named. This will return a null factory
// std::function if the factory is not available, so one would be wise
@@ -67,13 +67,18 @@
class SubClassRegisterer {
public:
explicit SubClassRegisterer(const char *name) {
- (*GetMap())[name] = [](FactoryArgs&&... args) {
+ (*GetMap())[name] = [](FactoryArgs &&... args) {
return std::unique_ptr<BaseClass>(
new SubClass(std::forward<FactoryArgs>(args)...));
};
}
};
+ // Fetch all factory functions.
+ static const std::unordered_map<std::string, FactoryFunction> &GetAll() {
+ return *GetMap();
+ }
+
private:
// Actual map. (Protected by static from concurrent construction
// if there is nothing registered at static linkage time).