17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_PLUGIN_REGISTRY_H
21
#define DRIZZLED_PLUGIN_REGISTRY_H
28
#include "drizzled/gettext.h"
29
#include "drizzled/unireg.h"
30
#include "drizzled/errmsg_print.h"
24
class Plugin_registry_impl
43
std::map<std::string, Library *> library_map;
44
std::map<std::string, Module *> module_map;
45
std::map<std::string, Plugin *> plugin_registry;
52
Registry(const Registry&);
53
Registry& operator=(const Registry&);
27
std::map<std::string, st_plugin_int *>
28
plugin_map[DRIZZLE_MAX_PLUGIN_TYPE_NUM];
30
Plugin_registry_impl(const Plugin_registry_impl&);
57
static plugin::Registry& singleton()
59
static plugin::Registry *registry= new plugin::Registry();
63
static void shutdown();
65
Module *find(std::string name);
67
void add(Module *module);
70
std::vector<Module *> getList(bool active);
72
const std::map<std::string, Plugin *> &getPluginsMap() const
74
return plugin_registry;
77
const std::map<std::string, Module *> &getModulesMap() const
82
Library *addLibrary(const std::string &plugin_name);
83
void removeLibrary(const std::string &plugin_name);
84
Library *findLibrary(const std::string &plugin_name) const;
90
std::string plugin_name(plugin->getName());
91
std::transform(plugin_name.begin(), plugin_name.end(),
92
plugin_name.begin(), ::tolower);
93
if (plugin_registry.find(plugin_name) != plugin_registry.end())
95
errmsg_printf(ERRMSG_LVL_ERROR,
96
_("Loading plugin %s failed: a plugin by that name already "
97
"exists.\n"), plugin->getName().c_str());
100
if (T::addPlugin(plugin))
104
errmsg_printf(ERRMSG_LVL_ERROR,
105
_("Fatal error: Failed initializing %s plugin.\n"),
106
plugin->getName().c_str());
109
plugin_registry.insert(std::pair<std::string, Plugin *>(plugin_name, plugin));
113
void remove(T *plugin)
115
std::string plugin_name(plugin->getName());
116
std::transform(plugin_name.begin(), plugin_name.end(),
117
plugin_name.begin(), ::tolower);
118
T::removePlugin(plugin);
119
plugin_registry.erase(plugin_name);
32
Plugin_registry_impl() {}
34
st_plugin_int *find(const LEX_STRING *name, int type);
36
void add(st_mysql_plugin *handle, st_plugin_int *plugin);
38
void get_list(uint32_t type, std::vector<st_plugin_int *> &plugins, bool active);
125
} /* end namespace plugin */
126
} /* end namespace drizzled */
127
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */