17 #ifndef __MODULE_MANAGER_HPP__ 18 #define __MODULE_MANAGER_HPP__ 25 #include <glog/logging.h> 69 return loadManifest(modules);
79 const std::string& moduleName,
82 synchronized (mutex) {
83 if (!moduleBases.contains(moduleName)) {
85 "Module '" + moduleName +
"' unknown");
89 if (module->create ==
nullptr) {
91 "Error creating module instance for '" + moduleName +
"': " 92 "create() method not found");
95 std::string expectedKind = kind<T>();
96 if (expectedKind != module->kind) {
98 "Error creating module instance for '" + moduleName +
"': " 99 "module is of kind '" + module->kind +
"', but the requested " 100 "kind is '" + expectedKind +
"'");
105 params.isSome() ? params.get() : moduleParameters[moduleName]);
106 if (instance ==
nullptr) {
107 return Error(
"Error creating Module instance for '" + moduleName +
"'");
113 template <
typename T>
114 static bool contains(
const std::string& moduleName)
116 synchronized (mutex) {
117 return (moduleBases.contains(moduleName) &&
118 moduleBases[moduleName]->kind ==
stringify(kind<T>()));
129 template <
typename T>
130 static std::vector<std::string>
find()
132 std::vector<std::string> names;
134 synchronized (mutex) {
137 names.push_back(name);
150 static void initialize();
152 static Try<Nothing> loadManifest(
const Modules& modules);
155 const std::string& moduleName,
162 const std::string& libraryName,
163 const Modules::Library::Module& module,
166 static std::mutex mutex;
196 #endif // __MODULE_MANAGER_HPP__
Definition: errorbase.hpp:36
Definition: option.hpp:29
static bool contains(const std::string &moduleName)
Definition: manager.hpp:114
static Try< T * > create(const std::string &moduleName, const Option< Parameters > ¶ms=None())
Definition: manager.hpp:78
Definition: module.hpp:56
Definition: manager.hpp:59
static Try< Nothing > load(const Modules &modules)
Definition: manager.hpp:67
static Try< Nothing > unload(const std::string &moduleName)
const char * kind
Definition: module.hpp:78
#define foreachpair(KEY, VALUE, ELEMS)
Definition: foreach.hpp:51
std::string stringify(int flags)
static std::vector< std::string > find()
Definition: manager.hpp:130
constexpr const char * name
Definition: shell.hpp:41
Definition: module.hpp:97