908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
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.
|
|
9 |
*
|
|
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.
|
|
14 |
*
|
|
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
|
|
18 |
*/
|
|
19 |
||
20 |
#include "drizzled/server_includes.h" |
|
971.1.45
by Monty Taylor
Collapsed plugin_registry. _impl class not needed. |
21 |
#include "drizzled/plugin_registry.h" |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
22 |
|
23 |
#include "drizzled/plugin.h" |
|
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
24 |
#include "drizzled/show.h" |
25 |
#include "drizzled/handler.h" |
|
26 |
#include "drizzled/errmsg.h" |
|
27 |
#include "drizzled/authentication.h" |
|
28 |
#include "drizzled/qcache.h" |
|
29 |
#include "drizzled/scheduling.h" |
|
30 |
#include "drizzled/logging.h" |
|
31 |
#include "drizzled/sql_udf.h" |
|
32 |
#include "drizzled/protocol.h" |
|
971.1.49
by Monty Taylor
Hooked transaction_services into Plugin_registry. |
33 |
#include "drizzled/transaction_services.h" |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
34 |
|
35 |
#include <string> |
|
36 |
#include <vector> |
|
37 |
#include <map> |
|
38 |
||
39 |
using namespace std; |
|
40 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
41 |
static PluginRegistry the_registry; |
990
by Brian Aker
Merge Monty |
42 |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
43 |
PluginRegistry& PluginRegistry::getPluginRegistry() |
971.1.45
by Monty Taylor
Collapsed plugin_registry. _impl class not needed. |
44 |
{
|
45 |
return the_registry; |
|
46 |
}
|
|
47 |
||
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
48 |
st_plugin_int *PluginRegistry::find(const LEX_STRING *name) |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
49 |
{
|
50 |
string find_str(name->str,name->length); |
|
51 |
transform(find_str.begin(), find_str.end(), find_str.begin(), ::tolower); |
|
52 |
||
53 |
map<string, st_plugin_int *>::iterator map_iter; |
|
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
54 |
map_iter= plugin_map.find(find_str); |
55 |
if (map_iter != plugin_map.end()) |
|
56 |
return (*map_iter).second; |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
57 |
return(0); |
58 |
}
|
|
59 |
||
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
60 |
void PluginRegistry::add(st_plugin_int *plugin) |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
61 |
{
|
62 |
string add_str(plugin->name.str); |
|
63 |
transform(add_str.begin(), add_str.end(), |
|
64 |
add_str.begin(), ::tolower); |
|
65 |
||
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
66 |
plugin_map[add_str]= plugin; |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
67 |
}
|
68 |
||
69 |
||
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
70 |
vector<st_plugin_int *> PluginRegistry::get_list(bool active) |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
71 |
{
|
72 |
st_plugin_int *plugin= NULL; |
|
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
73 |
|
74 |
vector <st_plugin_int *> plugins; |
|
75 |
plugins.reserve(plugin_map.size()); |
|
76 |
||
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
77 |
map<string, st_plugin_int *>::iterator map_iter; |
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
78 |
for (map_iter= plugin_map.begin(); |
79 |
map_iter != plugin_map.end(); |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
80 |
map_iter++) |
81 |
{
|
|
82 |
plugin= (*map_iter).second; |
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
83 |
if (active) |
84 |
plugins.push_back(plugin); |
|
85 |
else if (plugin->isInited) |
|
86 |
plugins.push_back(plugin); |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
87 |
}
|
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
88 |
|
89 |
return plugins; |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
90 |
}
|
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
91 |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
92 |
void PluginRegistry::add(StorageEngine *engine) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
93 |
{
|
94 |
add_storage_engine(engine); |
|
95 |
}
|
|
96 |
||
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
97 |
void PluginRegistry::add(InfoSchemaTable *schema_table) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
98 |
{
|
99 |
add_infoschema_table(schema_table); |
|
100 |
}
|
|
101 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
102 |
void PluginRegistry::add(Function_builder *udf) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
103 |
{
|
104 |
add_udf(udf); |
|
105 |
}
|
|
106 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
107 |
void PluginRegistry::add(Logging_handler *handler) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
108 |
{
|
109 |
add_logger(handler); |
|
110 |
}
|
|
111 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
112 |
void PluginRegistry::add(Error_message_handler *handler) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
113 |
{
|
114 |
add_errmsg_handler(handler); |
|
115 |
}
|
|
116 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
117 |
void PluginRegistry::add(Authentication *auth) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
118 |
{
|
119 |
add_authentication(auth); |
|
120 |
}
|
|
121 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
122 |
void PluginRegistry::add(QueryCache *qcache) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
123 |
{
|
124 |
add_query_cache(qcache); |
|
125 |
}
|
|
126 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
127 |
void PluginRegistry::add(SchedulerFactory *factory) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
128 |
{
|
129 |
add_scheduler_factory(factory); |
|
130 |
}
|
|
131 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
132 |
void PluginRegistry::add(ProtocolFactory *factory) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
133 |
{
|
134 |
add_protocol_factory(factory); |
|
135 |
}
|
|
971.1.49
by Monty Taylor
Hooked transaction_services into Plugin_registry. |
136 |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
137 |
void PluginRegistry::add(drizzled::plugin::Replicator *repl) |
971.1.49
by Monty Taylor
Hooked transaction_services into Plugin_registry. |
138 |
{
|
139 |
add_replicator(repl); |
|
140 |
}
|
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
141 |
|
142 |
void PluginRegistry::remove(StorageEngine *engine) |
|
143 |
{
|
|
144 |
remove_storage_engine(engine); |
|
145 |
}
|
|
146 |
||
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
147 |
void PluginRegistry::remove(InfoSchemaTable *schema_table) |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
148 |
{
|
149 |
remove_infoschema_table(schema_table); |
|
150 |
}
|
|
151 |
||
152 |
void PluginRegistry::remove(Function_builder *udf) |
|
153 |
{
|
|
154 |
remove_udf(udf); |
|
155 |
}
|
|
156 |
||
157 |
void PluginRegistry::remove(Logging_handler *handler) |
|
158 |
{
|
|
159 |
remove_logger(handler); |
|
160 |
}
|
|
161 |
||
162 |
void PluginRegistry::remove(Error_message_handler *handler) |
|
163 |
{
|
|
164 |
remove_errmsg_handler(handler); |
|
165 |
}
|
|
166 |
||
167 |
void PluginRegistry::remove(Authentication *auth) |
|
168 |
{
|
|
169 |
remove_authentication(auth); |
|
170 |
}
|
|
171 |
||
172 |
void PluginRegistry::remove(QueryCache *qcache) |
|
173 |
{
|
|
174 |
remove_query_cache(qcache); |
|
175 |
}
|
|
176 |
||
177 |
void PluginRegistry::remove(SchedulerFactory *factory) |
|
178 |
{
|
|
179 |
remove_scheduler_factory(factory); |
|
180 |
}
|
|
181 |
||
182 |
void PluginRegistry::remove(ProtocolFactory *factory) |
|
183 |
{
|
|
184 |
remove_protocol_factory(factory); |
|
185 |
}
|
|
186 |
||
187 |
void PluginRegistry::remove(drizzled::plugin::Replicator *repl) |
|
188 |
{
|
|
189 |
remove_replicator(repl); |
|
190 |
}
|