26
26
#include "drizzled/module/registry.h"
27
27
#include "drizzled/module/library.h"
28
#include "drizzled/module/graph.h"
29
#include "drizzled/module/vertex_handle.h"
29
31
#include "drizzled/plugin.h"
30
32
#include "drizzled/show.h"
31
33
#include "drizzled/cursor.h"
34
#include "drizzled/abort_exception.h"
33
36
#include <boost/bind.hpp>
106
116
add_str.begin(), ::tolower);
108
118
module_registry_[add_str]= handle;
120
Vertex vertex_info(add_str, handle);
121
VertexDesc handle_vertex= boost::add_vertex(depend_graph_->getGraph());
122
depend_graph_->properties(handle_vertex)= vertex_info;
124
handle->setVertexHandle(new VertexHandle(handle_vertex));
111
128
void module::Registry::remove(module::Module *handle)
128
145
assert(arg.size() == plugin_registry.size());
131
vector<module::Module *> module::Registry::getList(bool active)
133
module::Module *plugin= NULL;
148
void module::Registry::buildDeps()
150
ModuleMap::iterator map_iter= module_registry_.begin();
151
while (map_iter != module_registry_.end())
153
Module *handle= (*map_iter).second;
154
Module::Depends::const_iterator handle_deps= handle->getDepends().begin();
155
while (handle_deps != handle->getDepends().end())
157
std::string dep_str((*handle_deps));
158
transform(dep_str.begin(), dep_str.end(),
159
dep_str.begin(), ::tolower);
161
bool found_dep= false;
162
vertex_iter it= boost::vertices(depend_graph_->getGraph()).first;
163
while (it != vertices(depend_graph_->getGraph()).second)
165
if (depend_graph_->properties(*it).getName() == dep_str)
168
add_edge(handle->getVertexHandle()->getVertexDesc(), *it, depend_graph_->getGraph());
175
errmsg_printf(ERRMSG_LVL_ERROR,
176
_("Couldn't process plugin module dependencies. "
177
"%s depends on %s but %s is not to be loaded.\n"),
178
handle->getName().c_str(),
179
dep_str.c_str(), dep_str.c_str());
190
module::Registry::ModuleList module::Registry::getList()
135
197
std::vector<module::Module *> plugins;
136
plugins.reserve(module_registry_.size());
138
ModuleMap::iterator map_iter;
139
for (map_iter= module_registry_.begin();
140
map_iter != module_registry_.end();
199
VertexList vertex_list;
201
boost::topological_sort(depend_graph_->getGraph(), std::back_inserter(vertex_list));
203
for (VertexList::iterator i = vertex_list.begin();
204
i != vertex_list.end(); ++i)
143
plugin= (*map_iter).second;
145
plugins.push_back(plugin);
146
else if (plugin->isInited)
147
plugins.push_back(plugin);
206
Module *mod_ptr= depend_graph_->properties(*i).getModule();
209
plugins.push_back(mod_ptr);