20
20
#ifndef DRIZZLED_PLUGIN_REGISTRY_H
21
21
#define DRIZZLED_PLUGIN_REGISTRY_H
28
#include "drizzled/gettext.h"
29
#include "drizzled/unireg.h"
30
#include "drizzled/errmsg_print.h"
30
struct InfoSchemaTable;
31
class Function_builder;
32
class Logging_handler;
33
class Error_message_handler;
36
class SchedulerFactory;
37
class ProtocolFactory;
42
std::map<std::string, Module *> module_map;
43
std::map<std::string, const Plugin *> plugin_registry;
45
Module *current_module;
53
Registry(const Registry&);
54
Registry& operator=(const Registry&);
49
std::map<std::string, st_plugin_int *>
52
PluginRegistry(const PluginRegistry&);
57
static plugin::Registry& singleton()
59
static plugin::Registry *registry= new plugin::Registry();
63
static void shutdown()
65
plugin::Registry& registry= singleton();
69
Module *find(const LEX_STRING *name);
71
void add(Module *module);
73
void setCurrentModule(Module *module)
75
current_module= module;
78
void clearCurrentModule()
83
std::vector<Module *> getList(bool active);
85
const std::map<std::string, const Plugin *> &getPluginsMap() const
87
return plugin_registry;
93
plugin->setModule(current_module);
95
std::string plugin_name(plugin->getName());
96
std::transform(plugin_name.begin(), plugin_name.end(),
97
plugin_name.begin(), ::tolower);
98
if (plugin_registry.find(plugin_name) != plugin_registry.end())
100
errmsg_printf(ERRMSG_LVL_ERROR,
101
_("Loading plugin %s failed: a plugin by that name already "
102
"exists."), plugin->getName().c_str());
105
if (T::addPlugin(plugin))
109
errmsg_printf(ERRMSG_LVL_ERROR,
110
_("Fatal error: Failed initializing %s plugin."),
111
plugin->getName().c_str());
114
plugin_registry.insert(std::pair<std::string, const Plugin *>(plugin_name, plugin));
118
void remove(T *plugin)
120
std::string plugin_name(plugin->getName());
121
std::transform(plugin_name.begin(), plugin_name.end(),
122
plugin_name.begin(), ::tolower);
123
T::removePlugin(plugin);
124
plugin_registry.erase(plugin_name);
57
st_plugin_int *find(const LEX_STRING *name);
59
void add(st_plugin_int *plugin);
61
std::vector<st_plugin_int *> get_list(bool active);
62
static PluginRegistry& getPluginRegistry();
64
void add(StorageEngine *engine);
65
void add(InfoSchemaTable *schema_table);
66
void add(Function_builder *udf);
67
void add(Logging_handler *handler);
68
void add(Error_message_handler *handler);
69
void add(Authentication *auth);
70
void add(QueryCache *qcache);
71
void add(SchedulerFactory *scheduler);
72
void add(ProtocolFactory *protocol);
73
void add(drizzled::plugin::Replicator *repl);
75
void remove(StorageEngine *engine);
76
void remove(InfoSchemaTable *schema_table);
77
void remove(Function_builder *udf);
78
void remove(Logging_handler *handler);
79
void remove(Error_message_handler *handler);
80
void remove(Authentication *auth);
81
void remove(QueryCache *qcache);
82
void remove(SchedulerFactory *scheduler);
83
void remove(ProtocolFactory *protocol);
84
void remove(drizzled::plugin::Replicator *repl);
129
} /* end namespace plugin */
130
} /* end namespace drizzled */
131
88
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */