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
#include "drizzled/gettext.h"
29
#include "drizzled/unireg.h"
30
#include "drizzled/errmsg_print.h"
31
#include "drizzled/plugin/plugin.h"
30
struct InfoSchemaTable;
31
class Function_builder;
32
class Logging_handler;
33
class Error_message_handler;
36
class SchedulerFactory;
37
class ProtocolFactory;
44
std::map<std::string, Library *> library_map;
45
std::map<std::string, Module *> module_map;
46
std::map<std::string, plugin::Plugin *> plugin_registry;
53
Registry(const Registry&);
54
Registry& operator=(const Registry&);
49
std::map<std::string, st_plugin_int *>
52
PluginRegistry(const PluginRegistry&);
58
static Registry& singleton()
60
static Registry *registry= new Registry();
64
void copy(plugin::Plugin::vector &arg);
66
static void shutdown();
68
Module *find(std::string name);
70
void add(Module *module);
72
void remove(Module *module);
74
std::vector<Module *> getList(bool active);
76
const std::map<std::string, plugin::Plugin *> &getPluginsMap() const
78
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();
96
std::string plugin_name(plugin->getName());
97
std::transform(plugin_name.begin(), plugin_name.end(),
98
plugin_name.begin(), ::tolower);
99
if (plugin_registry.find(plugin_name) != plugin_registry.end())
101
errmsg_printf(ERRMSG_LVL_ERROR,
102
_("Loading plugin %s failed: a plugin by that name already "
103
"exists.\n"), plugin->getName().c_str());
106
if (T::addPlugin(plugin))
110
errmsg_printf(ERRMSG_LVL_ERROR,
111
_("Fatal error: Failed initializing %s plugin.\n"),
112
plugin->getName().c_str());
115
plugin_registry.insert(std::pair<std::string, plugin::Plugin *>(plugin_name, plugin));
119
void remove(T *plugin)
121
std::string plugin_name(plugin->getName());
122
std::transform(plugin_name.begin(), plugin_name.end(),
123
plugin_name.begin(), ::tolower);
124
T::removePlugin(plugin);
125
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);
131
} /* namespace module */
132
} /* namespace drizzled */
133
#endif /* DRIZZLED_MODULE_REGISTRY_H */
88
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */