17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_MODULE_REGISTRY_H
21
#define DRIZZLED_MODULE_REGISTRY_H
20
#ifndef DRIZZLED_PLUGIN_REGISTRY_H
21
#define DRIZZLED_PLUGIN_REGISTRY_H
28
28
#include "drizzled/gettext.h"
29
29
#include "drizzled/unireg.h"
30
30
#include "drizzled/errmsg_print.h"
31
#include "drizzled/plugin/plugin.h"
44
std::map<std::string, Library *> library_map;
45
42
std::map<std::string, Module *> module_map;
46
std::map<std::string, plugin::Plugin *> plugin_registry;
43
std::map<std::string, const Plugin *> plugin_registry;
45
Module *current_module;
53
53
Registry(const Registry&);
54
54
Registry& operator=(const Registry&);
58
static Registry& singleton()
57
static plugin::Registry& singleton()
60
static Registry *registry= new Registry();
59
static plugin::Registry *registry= new plugin::Registry();
64
void copy(plugin::Plugin::vector &arg);
66
static void shutdown();
68
Module *find(std::string name);
63
static void shutdown()
65
plugin::Registry& registry= singleton();
69
Module *find(const LEX_STRING *name);
70
71
void add(Module *module);
72
void remove(Module *module);
73
void setCurrentModule(Module *module)
75
current_module= module;
78
void clearCurrentModule()
74
83
std::vector<Module *> getList(bool active);
76
const std::map<std::string, plugin::Plugin *> &getPluginsMap() const
85
const std::map<std::string, const Plugin *> &getPluginsMap() const
78
87
return plugin_registry;
81
const std::map<std::string, Module *> &getModulesMap() const
86
Library *addLibrary(const std::string &plugin_name, bool builtin= false);
87
void removeLibrary(const std::string &plugin_name);
88
Library *findLibrary(const std::string &plugin_name) const;
90
void shutdownModules();
93
91
void add(T *plugin)
93
plugin->setModule(current_module);
95
94
bool failed= false;
96
95
std::string plugin_name(plugin->getName());
97
96
std::transform(plugin_name.begin(), plugin_name.end(),
101
100
errmsg_printf(ERRMSG_LVL_ERROR,
102
101
_("Loading plugin %s failed: a plugin by that name already "
103
"exists.\n"), plugin->getName().c_str());
102
"exists."), plugin->getName().c_str());
106
105
if (T::addPlugin(plugin))
110
109
errmsg_printf(ERRMSG_LVL_ERROR,
111
_("Fatal error: Failed initializing %s plugin.\n"),
110
_("Fatal error: Failed initializing %s plugin."),
112
111
plugin->getName().c_str());
115
plugin_registry.insert(std::pair<std::string, plugin::Plugin *>(plugin_name, plugin));
118
116
template<class T>
125
123
plugin_registry.erase(plugin_name);
131
} /* namespace module */
132
} /* namespace drizzled */
133
#endif /* DRIZZLED_MODULE_REGISTRY_H */
128
} /* end namespace plugin */
129
} /* end namespace drizzled */
130
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */