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" |
|
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
32 |
#include "drizzled/listen.h" |
1039.5.31
by Jay Pipes
This patch does a few things: |
33 |
#include "drizzled/replication_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; |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
40 |
using namespace drizzled; |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
41 |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
42 |
static PluginRegistry the_registry; |
990
by Brian Aker
Merge Monty |
43 |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
44 |
PluginRegistry& PluginRegistry::getPluginRegistry() |
971.1.45
by Monty Taylor
Collapsed plugin_registry. _impl class not needed. |
45 |
{
|
46 |
return the_registry; |
|
47 |
}
|
|
48 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
49 |
plugin::Handle *PluginRegistry::find(const LEX_STRING *name) |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
50 |
{
|
51 |
string find_str(name->str,name->length); |
|
52 |
transform(find_str.begin(), find_str.end(), find_str.begin(), ::tolower); |
|
53 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
54 |
map<string, plugin::Handle *>::iterator map_iter; |
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
55 |
map_iter= plugin_map.find(find_str); |
56 |
if (map_iter != plugin_map.end()) |
|
57 |
return (*map_iter).second; |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
58 |
return(0); |
59 |
}
|
|
60 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
61 |
void PluginRegistry::add(plugin::Handle *plugin) |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
62 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
63 |
string add_str(plugin->getName()); |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
64 |
transform(add_str.begin(), add_str.end(), |
65 |
add_str.begin(), ::tolower); |
|
66 |
||
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
67 |
plugin_map[add_str]= plugin; |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
68 |
}
|
69 |
||
70 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
71 |
vector<plugin::Handle *> PluginRegistry::get_list(bool active) |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
72 |
{
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
73 |
plugin::Handle *plugin= NULL; |
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
74 |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
75 |
vector <plugin::Handle *> plugins; |
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
76 |
plugins.reserve(plugin_map.size()); |
77 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
78 |
map<string, plugin::Handle *>::iterator map_iter; |
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
79 |
for (map_iter= plugin_map.begin(); |
80 |
map_iter != plugin_map.end(); |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
81 |
map_iter++) |
82 |
{
|
|
83 |
plugin= (*map_iter).second; |
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
84 |
if (active) |
85 |
plugins.push_back(plugin); |
|
86 |
else if (plugin->isInited) |
|
87 |
plugins.push_back(plugin); |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
88 |
}
|
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
89 |
|
90 |
return plugins; |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
91 |
}
|
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
92 |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
93 |
void PluginRegistry::add(StorageEngine *engine) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
94 |
{
|
95 |
add_storage_engine(engine); |
|
96 |
}
|
|
97 |
||
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
98 |
void PluginRegistry::add(InfoSchemaTable *schema_table) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
99 |
{
|
100 |
add_infoschema_table(schema_table); |
|
101 |
}
|
|
102 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
103 |
void PluginRegistry::add(Function_builder *udf) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
104 |
{
|
105 |
add_udf(udf); |
|
106 |
}
|
|
107 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
108 |
void PluginRegistry::add(Logging_handler *handler) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
109 |
{
|
110 |
add_logger(handler); |
|
111 |
}
|
|
112 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
113 |
void PluginRegistry::add(Error_message_handler *handler) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
114 |
{
|
115 |
add_errmsg_handler(handler); |
|
116 |
}
|
|
117 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
118 |
void PluginRegistry::add(Authentication *auth) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
119 |
{
|
120 |
add_authentication(auth); |
|
121 |
}
|
|
122 |
||
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
123 |
void PluginRegistry::add(QueryCache *qcache) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
124 |
{
|
125 |
add_query_cache(qcache); |
|
126 |
}
|
|
127 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
128 |
void PluginRegistry::add(plugin::SchedulerFactory *factory) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
129 |
{
|
130 |
add_scheduler_factory(factory); |
|
131 |
}
|
|
132 |
||
971.3.65
by Eric Day
Namespace cleanup for Protocol and Listen. |
133 |
void PluginRegistry::add(const plugin::Listen &listen_obj) |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
134 |
{
|
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
135 |
add_listen(listen_obj); |
971.1.46
by Monty Taylor
Made plugin registration go through Plugin_registry. |
136 |
}
|
971.1.49
by Monty Taylor
Hooked transaction_services into Plugin_registry. |
137 |
|
971.3.68
by Eric Day
Merged Trunk. |
138 |
void PluginRegistry::add(plugin::Replicator *replicator) |
1039.5.1
by Jay Pipes
* New serial event log plugin |
139 |
{
|
140 |
add_replicator(replicator); |
|
141 |
}
|
|
142 |
||
971.3.68
by Eric Day
Merged Trunk. |
143 |
void PluginRegistry::add(plugin::Applier *applier) |
1039.5.1
by Jay Pipes
* New serial event log plugin |
144 |
{
|
145 |
add_applier(applier); |
|
971.1.49
by Monty Taylor
Hooked transaction_services into Plugin_registry. |
146 |
}
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
147 |
|
148 |
void PluginRegistry::remove(StorageEngine *engine) |
|
149 |
{
|
|
150 |
remove_storage_engine(engine); |
|
151 |
}
|
|
152 |
||
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
153 |
void PluginRegistry::remove(InfoSchemaTable *schema_table) |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
154 |
{
|
155 |
remove_infoschema_table(schema_table); |
|
156 |
}
|
|
157 |
||
158 |
void PluginRegistry::remove(Function_builder *udf) |
|
159 |
{
|
|
160 |
remove_udf(udf); |
|
161 |
}
|
|
162 |
||
163 |
void PluginRegistry::remove(Logging_handler *handler) |
|
164 |
{
|
|
165 |
remove_logger(handler); |
|
166 |
}
|
|
167 |
||
168 |
void PluginRegistry::remove(Error_message_handler *handler) |
|
169 |
{
|
|
170 |
remove_errmsg_handler(handler); |
|
171 |
}
|
|
172 |
||
173 |
void PluginRegistry::remove(Authentication *auth) |
|
174 |
{
|
|
175 |
remove_authentication(auth); |
|
176 |
}
|
|
177 |
||
178 |
void PluginRegistry::remove(QueryCache *qcache) |
|
179 |
{
|
|
180 |
remove_query_cache(qcache); |
|
181 |
}
|
|
182 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
183 |
void PluginRegistry::remove(plugin::SchedulerFactory *factory) |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
184 |
{
|
185 |
remove_scheduler_factory(factory); |
|
186 |
}
|
|
187 |
||
971.3.65
by Eric Day
Namespace cleanup for Protocol and Listen. |
188 |
void PluginRegistry::remove(const plugin::Listen &listen_obj) |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
189 |
{
|
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
190 |
remove_listen(listen_obj); |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
191 |
}
|
192 |
||
971.3.68
by Eric Day
Merged Trunk. |
193 |
void PluginRegistry::remove(plugin::Replicator *replicator) |
1039.5.1
by Jay Pipes
* New serial event log plugin |
194 |
{
|
195 |
remove_replicator(replicator); |
|
196 |
}
|
|
197 |
||
971.3.68
by Eric Day
Merged Trunk. |
198 |
void PluginRegistry::remove(plugin::Applier *applier) |
1039.5.1
by Jay Pipes
* New serial event log plugin |
199 |
{
|
200 |
remove_applier(applier); |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
201 |
}
|