1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
#include "drizzled/plugin/registry.h"
28
#include "drizzled/plugin.h"
29
#include "drizzled/plugin/library.h"
30
#include "drizzled/show.h"
31
#include "drizzled/cursor.h"
38
plugin::Registry::~Registry()
40
map<string, plugin::Library *>::iterator iter= library_map.begin();
41
while (iter != library_map.end())
43
delete (*iter).second;
49
void plugin::Registry::shutdown()
51
plugin::Registry& registry= singleton();
55
plugin::Module *plugin::Registry::find(string name)
57
transform(name.begin(), name.end(), name.begin(), ::tolower);
59
map<string, plugin::Module *>::iterator map_iter;
60
map_iter= module_map.find(name);
61
if (map_iter != module_map.end())
62
return (*map_iter).second;
66
void plugin::Registry::add(plugin::Module *handle)
68
string add_str(handle->getName());
69
transform(add_str.begin(), add_str.end(),
70
add_str.begin(), ::tolower);
72
module_map[add_str]= handle;
76
vector<plugin::Module *> plugin::Registry::getList(bool active)
78
plugin::Module *plugin= NULL;
80
vector<plugin::Module *> plugins;
81
plugins.reserve(module_map.size());
83
map<string, plugin::Module *>::iterator map_iter;
84
for (map_iter= module_map.begin();
85
map_iter != module_map.end();
88
plugin= (*map_iter).second;
90
plugins.push_back(plugin);
91
else if (plugin->isInited)
92
plugins.push_back(plugin);
98
plugin::Library *plugin::Registry::addLibrary(const string &plugin_name)
101
/* If this dll is already loaded just return it */
102
plugin::Library *library= findLibrary(plugin_name);
108
library= plugin::Library::loadLibrary(plugin_name);
111
/* Add this dll to the map */
112
library_map.insert(make_pair(plugin_name, library));
118
void plugin::Registry::removeLibrary(const string &plugin_name)
120
map<string, plugin::Library *>::iterator iter=
121
library_map.find(plugin_name);
122
if (iter != library_map.end())
124
library_map.erase(iter);
125
delete (*iter).second;
129
plugin::Library *plugin::Registry::findLibrary(const string &plugin_name) const
131
map<string, plugin::Library *>::const_iterator iter=
132
library_map.find(plugin_name);
133
if (iter != library_map.end())
134
return (*iter).second;
138
} /* namespace drizzled */