~drizzle-trunk/drizzle/development

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;
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
1093.3.1 by Monty Taylor
Rename of plugin classes.
48
drizzled::plugin::Handle *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
1093.3.1 by Monty Taylor
Rename of plugin classes.
53
  map<string, drizzled::plugin::Handle *>::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
1093.3.1 by Monty Taylor
Rename of plugin classes.
60
void PluginRegistry::add(drizzled::plugin::Handle *plugin)
908.2.1 by Monty Taylor
First pass at refactoring plugins - factored out sql_map.
61
{
1093.3.4 by Monty Taylor
Naming cleanups.
62
  string add_str(plugin->getName());
908.2.1 by Monty Taylor
First pass at refactoring plugins - factored out sql_map.
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
1093.3.1 by Monty Taylor
Rename of plugin classes.
70
vector<drizzled::plugin::Handle *> PluginRegistry::get_list(bool active)
908.2.1 by Monty Taylor
First pass at refactoring plugins - factored out sql_map.
71
{
1093.3.1 by Monty Taylor
Rename of plugin classes.
72
  drizzled::plugin::Handle *plugin= NULL;
971.1.54 by Monty Taylor
Trimmed out some plugin type stuff.
73
1093.3.1 by Monty Taylor
Rename of plugin classes.
74
  vector <drizzled::plugin::Handle *> plugins;
971.1.54 by Monty Taylor
Trimmed out some plugin type stuff.
75
  plugins.reserve(plugin_map.size());
76
1093.3.1 by Monty Taylor
Rename of plugin classes.
77
  map<string, drizzled::plugin::Handle *>::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.3.51 by Eric Day
Finished up new Listen plugin interface.
132
void PluginRegistry::add(const Listen &listen_obj)
971.1.46 by Monty Taylor
Made plugin registration go through Plugin_registry.
133
{
971.3.48 by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup.
134
  add_listen(listen_obj);
971.1.46 by Monty Taylor
Made plugin registration go through Plugin_registry.
135
}
971.1.49 by Monty Taylor
Hooked transaction_services into Plugin_registry.
136
1039.5.1 by Jay Pipes
* New serial event log plugin
137
void PluginRegistry::add(drizzled::plugin::Replicator *replicator)
138
{
139
  add_replicator(replicator);
140
}
141
142
void PluginRegistry::add(drizzled::plugin::Applier *applier)
143
{
144
  add_applier(applier);
971.1.49 by Monty Taylor
Hooked transaction_services into Plugin_registry.
145
}
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
146
147
void PluginRegistry::remove(StorageEngine *engine)
148
{
149
  remove_storage_engine(engine);
150
}
151
971.1.68 by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders)
152
void PluginRegistry::remove(InfoSchemaTable *schema_table)
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
153
{
154
  remove_infoschema_table(schema_table);
155
}
156
157
void PluginRegistry::remove(Function_builder *udf)
158
{
159
  remove_udf(udf);
160
}
161
162
void PluginRegistry::remove(Logging_handler *handler)
163
{
164
  remove_logger(handler);
165
}
166
167
void PluginRegistry::remove(Error_message_handler *handler)
168
{
169
  remove_errmsg_handler(handler);
170
}
171
172
void PluginRegistry::remove(Authentication *auth)
173
{
174
  remove_authentication(auth);
175
}
176
177
void PluginRegistry::remove(QueryCache *qcache)
178
{
179
  remove_query_cache(qcache);
180
}
181
182
void PluginRegistry::remove(SchedulerFactory *factory)
183
{
184
  remove_scheduler_factory(factory);
185
}
186
971.3.51 by Eric Day
Finished up new Listen plugin interface.
187
void PluginRegistry::remove(const Listen &listen_obj)
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
188
{
971.3.48 by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup.
189
  remove_listen(listen_obj);
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
190
}
191
1039.5.1 by Jay Pipes
* New serial event log plugin
192
void PluginRegistry::remove(drizzled::plugin::Replicator *replicator)
193
{
194
  remove_replicator(replicator);
195
}
196
197
void PluginRegistry::remove(drizzled::plugin::Applier *applier)
198
{
199
  remove_applier(applier);
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
200
}