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
23
#include "drizzled/slot/listen.h"
29
#include <boost/scoped_ptr.hpp>
31
#include <drizzled/gettext.h>
32
#include <drizzled/unireg.h>
33
#include <drizzled/errmsg_print.h>
34
#include <drizzled/plugin/plugin.h>
30
class InfoSchemaTable;
31
class Function_builder;
32
class Logging_handler;
33
class Error_message_handler;
43
class SchedulerFactory;
51
typedef std::map<std::string, Library *> LibraryMap;
52
typedef std::map<std::string, Module *> ModuleMap;
53
typedef std::vector<Module *> ModuleList;
55
LibraryMap library_registry_;
56
ModuleMap module_registry_;
57
boost::scoped_ptr<Graph> depend_graph_;
59
plugin::Plugin::map plugin_registry;
50
std::map<std::string, Handle *>
64
54
Registry(const Registry&);
65
Registry& operator=(const Registry&);
71
static Registry& singleton()
73
static Registry *registry= new Registry();
77
void copy(plugin::Plugin::vector &arg);
79
static void shutdown();
81
Module *find(std::string name);
83
void add(Module *module);
85
void remove(Module *module);
87
std::vector<Module *> getList();
89
const plugin::Plugin::map &getPluginsMap() const
91
return plugin_registry;
94
const ModuleMap &getModulesMap() const
96
return module_registry_;
99
Library *addLibrary(const std::string &plugin_name, bool builtin= false);
100
void removeLibrary(const std::string &plugin_name);
101
Library *findLibrary(const std::string &plugin_name) const;
103
void shutdownModules();
109
std::string plugin_type(plugin->getTypeName());
110
std::transform(plugin_type.begin(), plugin_type.end(),
111
plugin_type.begin(), ::tolower);
112
std::string plugin_name(plugin->getName());
113
std::transform(plugin_name.begin(), plugin_name.end(),
114
plugin_name.begin(), ::tolower);
115
if (plugin_registry.find(std::make_pair(plugin_type, plugin_name)) != plugin_registry.end())
117
errmsg_printf(error::ERROR,
118
_("Loading plugin %s failed: a %s plugin by that name "
119
"already exists.\n"),
120
plugin->getTypeName().c_str(),
121
plugin->getName().c_str());
124
if (T::addPlugin(plugin))
131
errmsg_printf(error::ERROR,
132
_("Fatal error: Failed initializing %s::%s plugin.\n"),
133
plugin->getTypeName().c_str(),
134
plugin->getName().c_str());
137
plugin_registry.insert(std::make_pair(std::make_pair(plugin_type, plugin_name), plugin));
141
void remove(T *plugin)
143
std::string plugin_type(plugin->getTypeName());
144
std::transform(plugin_type.begin(), plugin_type.end(),
145
plugin_type.begin(), ::tolower);
146
std::string plugin_name(plugin->getName());
147
std::transform(plugin_name.begin(), plugin_name.end(),
148
plugin_name.begin(), ::tolower);
149
T::removePlugin(plugin);
150
plugin_registry.erase(std::make_pair(plugin_type, plugin_name));
57
static plugin::Registry& singleton()
59
static plugin::Registry registry;
63
Handle *find(const LEX_STRING *name);
65
void add(Handle *plugin);
67
std::vector<Handle *> get_list(bool active);
69
void add(StorageEngine *engine);
70
void add(InfoSchemaTable *schema_table);
71
void add(Function_builder *udf);
72
void add(Logging_handler *handler);
73
void add(Error_message_handler *handler);
74
void add(Authentication *auth);
75
void add(QueryCache *qcache);
76
void add(SchedulerFactory *scheduler);
77
void add(Replicator *replicator);
78
void add(Applier *applier);
80
void remove(StorageEngine *engine);
81
void remove(InfoSchemaTable *schema_table);
82
void remove(Function_builder *udf);
83
void remove(Logging_handler *handler);
84
void remove(Error_message_handler *handler);
85
void remove(Authentication *auth);
86
void remove(QueryCache *qcache);
87
void remove(SchedulerFactory *scheduler);
88
void remove(Replicator *replicator);
89
void remove(Applier *applier);
91
::drizzled::slot::Listen listen;
156
} /* namespace module */
157
} /* namespace drizzled */
158
#endif /* DRIZZLED_MODULE_REGISTRY_H */
94
} /* end namespace plugin */
95
} /* end namespace drizzled */
96
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */