Added vector with instances for convenience
This commit is contained in:
parent
deb8f59b12
commit
85b5507882
@ -31,6 +31,9 @@ namespace sc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const auto& elem : plugins) {
|
||||||
|
objects.emplace_back(elem.second());
|
||||||
|
}
|
||||||
throw_if_min1(closedir(plugins_dir));
|
throw_if_min1(closedir(plugins_dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ namespace sc {
|
|||||||
static size_t count() { return plugins.size(); }
|
static size_t count() { return plugins.size(); }
|
||||||
|
|
||||||
static const std::map<std::string, plugin<T>>& all() { return plugins; }
|
static const std::map<std::string, plugin<T>>& all() { return plugins; }
|
||||||
|
static const std::vector<T>& instances() { return objects; }
|
||||||
|
|
||||||
plugin(const std::string& path) : _path {path} {
|
plugin(const std::string& path) : _path {path} {
|
||||||
_plugin = dlopen(path.c_str(), RTLD_LAZY);
|
_plugin = dlopen(path.c_str(), RTLD_LAZY);
|
||||||
@ -112,6 +116,7 @@ namespace sc {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<std::string, plugin<T>> plugins;
|
static std::map<std::string, plugin<T>> plugins;
|
||||||
|
static std::vector<T> objects;
|
||||||
|
|
||||||
std::string _path;
|
std::string _path;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
@ -123,6 +128,8 @@ namespace sc {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
std::map<std::string, plugin<T>> plugin<T>::plugins;
|
std::map<std::string, plugin<T>> plugin<T>::plugins;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::vector<T> objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _plugin_H_
|
#endif // _plugin_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user