~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/loader.cc

  • Committer: Monty Taylor
  • Date: 2010-05-15 18:23:34 UTC
  • mto: (1530.6.1)
  • mto: This revision was merged to the branch mainline in revision 1556.
  • Revision ID: mordred@inaugust.com-20100515182334-bgbmwij0mioklajx
Renamed classes that were in drizzled::plugin but which were not meant
for consumption by plugin authors to drizzled::module - since they
really have to do with plugin module loading. This way when we
look in drizzled/plugin, we see nothing but plugin interfaces. Win.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "drizzled/internal/m_string.h"
29
29
 
30
30
#include "drizzled/plugin.h"
31
 
#include "drizzled/plugin/load_list.h"
 
31
#include "drizzled/module/load_list.h"
 
32
#include "drizzled/module/library.h"
 
33
#include "drizzled/module/registry.h"
32
34
#include "drizzled/sql_parse.h"
33
35
#include "drizzled/show.h"
34
36
#include "drizzled/cursor.h"
35
37
#include "drizzled/set_var.h"
36
38
#include "drizzled/session.h"
37
39
#include "drizzled/item/null.h"
38
 
#include "drizzled/plugin/registry.h"
39
40
#include "drizzled/error.h"
40
41
#include "drizzled/gettext.h"
41
42
#include "drizzled/errmsg_print.h"
42
 
#include "drizzled/plugin/library.h"
43
43
#include "drizzled/strfunc.h"
44
44
#include "drizzled/pthread_globals.h"
45
45
#include "drizzled/util/tokenize.h"
51
51
 
52
52
using namespace std;
53
53
 
 
54
/** These exist just to prevent symbols from being optimized out */
 
55
typedef drizzled::module::Manifest drizzled_builtin_list[];
 
56
extern drizzled_builtin_list PANDORA_BUILTIN_SYMBOLS_LIST;
 
57
drizzled::module::Manifest *drizzled_builtins[]=
 
58
{
 
59
  PANDORA_BUILTIN_SYMBOLS_LIST, NULL
 
60
};
 
61
 
54
62
namespace drizzled
55
63
{
56
64
 
120
128
class sys_var_pluginvar: public sys_var
121
129
{
122
130
public:
123
 
  plugin::Module *plugin;
 
131
  module::Module *plugin;
124
132
  drizzle_sys_var *plugin_var;
125
133
 
126
134
  sys_var_pluginvar(const std::string name_arg,
147
155
/* prototypes */
148
156
static void plugin_prune_list(vector<string> &plugin_list,
149
157
                              const vector<string> &plugins_to_remove);
150
 
static bool plugin_load_list(plugin::Registry &registry,
 
158
static bool plugin_load_list(module::Registry &registry,
151
159
                             memory::Root *tmp_root, int *argc, char **argv,
152
160
                             const set<string> &plugin_list,
153
161
                             bool builtin= false);
154
 
static int test_plugin_options(memory::Root *, plugin::Module *,
 
162
static int test_plugin_options(memory::Root *, module::Module *,
155
163
                               int *, char **);
156
164
static void unlock_variables(Session *session, struct system_variables *vars);
157
165
static void cleanup_variables(Session *session, struct system_variables *vars);
234
242
  NOTE
235
243
    Requires that a write-lock is held on LOCK_system_variables_hash
236
244
*/
237
 
static bool plugin_add(plugin::Registry &registry, memory::Root *tmp_root,
238
 
                       plugin::Library *library,
 
245
static bool plugin_add(module::Registry &registry, memory::Root *tmp_root,
 
246
                       module::Library *library,
239
247
                       int *argc, char **argv)
240
248
{
241
249
  if (! initialized)
248
256
    return false;
249
257
  }
250
258
 
251
 
  plugin::Module *tmp= NULL;
 
259
  module::Module *tmp= NULL;
252
260
  /* Find plugin by name */
253
 
  const plugin::Manifest *manifest= library->getManifest();
 
261
  const module::Manifest *manifest= library->getManifest();
254
262
 
255
263
  if (registry.find(manifest->name))
256
264
  {
262
270
    return true;
263
271
  }
264
272
 
265
 
  tmp= new (std::nothrow) plugin::Module(manifest, library);
 
273
  tmp= new (std::nothrow) module::Module(manifest, library);
266
274
  if (tmp == NULL)
267
275
    return true;
268
276
 
277
285
}
278
286
 
279
287
 
280
 
static void delete_module(plugin::Module *module)
 
288
static void delete_module(module::Module *module)
281
289
{
282
290
  /* Free allocated strings before deleting the plugin. */
283
291
  plugin_vars_free_values(module->system_vars);
289
297
}
290
298
 
291
299
 
292
 
static void reap_plugins(plugin::Registry &registry)
 
300
static void reap_plugins(module::Registry &registry)
293
301
{
294
 
  std::map<std::string, plugin::Module *>::const_iterator modules=
 
302
  std::map<std::string, module::Module *>::const_iterator modules=
295
303
    registry.getModulesMap().begin();
296
304
 
297
305
  while (modules != registry.getModulesMap().end())
298
306
  {
299
 
    plugin::Module *module= (*modules).second;
 
307
    module::Module *module= (*modules).second;
300
308
    delete_module(module);
301
309
    ++modules;
302
310
  }
305
313
}
306
314
 
307
315
 
308
 
static void plugin_initialize_vars(plugin::Module *module)
 
316
static void plugin_initialize_vars(module::Module *module)
309
317
{
310
318
  /*
311
319
    set the plugin attribute of plugin's sys vars so they are pointing
325
333
}
326
334
 
327
335
 
328
 
static bool plugin_initialize(plugin::Registry &registry,
329
 
                              plugin::Module *module)
 
336
static bool plugin_initialize(module::Registry &registry,
 
337
                              module::Module *module)
330
338
{
331
339
  assert(module->isInited == false);
332
340
 
364
372
 
365
373
  Finally we initialize everything, aka the dynamic that have yet to initialize.
366
374
*/
367
 
bool plugin_init(plugin::Registry &registry,
 
375
bool plugin_init(module::Registry &registry,
368
376
                 int *argc, char **argv,
369
377
                 bool skip_init)
370
378
{
371
 
  plugin::Module *module;
 
379
  module::Module *module;
372
380
  memory::Root tmp_root(4096);
373
381
 
374
382
  if (initialized)
444
452
  /*
445
453
    Now we initialize all remaining plugins
446
454
  */
447
 
  std::map<std::string, plugin::Module *>::const_iterator modules=
 
455
  std::map<std::string, module::Module *>::const_iterator modules=
448
456
    registry.getModulesMap().begin();
449
457
    
450
458
  while (modules != registry.getModulesMap().end())
500
508
/*
501
509
  called only by plugin_init()
502
510
*/
503
 
static bool plugin_load_list(plugin::Registry &registry,
 
511
static bool plugin_load_list(module::Registry &registry,
504
512
                             memory::Root *tmp_root, int *argc, char **argv,
505
513
                             const set<string> &plugin_list,
506
514
                             bool builtin)
507
515
{
508
 
  plugin::Library *library= NULL;
 
516
  module::Library *library= NULL;
509
517
 
510
518
  for (set<string>::const_iterator iter= plugin_list.begin();
511
519
       iter != plugin_list.end();
537
545
}
538
546
 
539
547
 
540
 
void plugin_shutdown(plugin::Registry &registry)
 
548
void module_shutdown(module::Registry &registry)
541
549
{
542
550
 
543
551
  if (initialized)
771
779
{
772
780
  sys_var *var;
773
781
  sys_var_pluginvar *pi= NULL;
774
 
  plugin::Module *module;
 
782
  module::Module *module;
775
783
 
776
784
  pthread_rwlock_rdlock(&LOCK_system_variables_hash);
777
785
  if ((var= intern_find_sys_var(str, length, false)) &&
1426
1434
}
1427
1435
 
1428
1436
 
1429
 
static int construct_options(memory::Root *mem_root, plugin::Module *tmp,
 
1437
static int construct_options(memory::Root *mem_root, module::Module *tmp,
1430
1438
                             option *options)
1431
1439
{
1432
1440
  
1596
1604
}
1597
1605
 
1598
1606
 
1599
 
static option *construct_help_options(memory::Root *mem_root, plugin::Module *p)
 
1607
static option *construct_help_options(memory::Root *mem_root, module::Module *p)
1600
1608
{
1601
1609
  drizzle_sys_var **opt;
1602
1610
  option *opts;
1645
1653
  NOTE:
1646
1654
    Requires that a write-lock is held on LOCK_system_variables_hash
1647
1655
*/
1648
 
static int test_plugin_options(memory::Root *tmp_root, plugin::Module *tmp,
 
1656
static int test_plugin_options(memory::Root *tmp_root, module::Module *tmp,
1649
1657
                               int *argc, char **argv)
1650
1658
{
1651
1659
  struct sys_var_chain chain= { NULL, NULL };
1761
1769
 
1762
1770
void my_print_help_inc_plugins(option *main_options)
1763
1771
{
1764
 
  plugin::Registry &registry= plugin::Registry::singleton();
 
1772
  module::Registry &registry= module::Registry::singleton();
1765
1773
  vector<option> all_options;
1766
 
  plugin::Module *p;
1767
1774
  memory::Root mem_root(4096);
1768
1775
  option *opt= NULL;
1769
1776
 
 
1777
 
1770
1778
  if (initialized)
1771
1779
  {
1772
 
    std::map<std::string, plugin::Module *>::const_iterator modules=
 
1780
    std::map<std::string, module::Module *>::const_iterator modules=
1773
1781
      registry.getModulesMap().begin();
1774
1782
    
1775
1783
    while (modules != registry.getModulesMap().end())
1776
1784
    {
1777
 
      p= (*modules).second;
 
1785
      module::Module *p= (*modules).second;
1778
1786
      ++modules;
1779
1787
 
1780
1788
      if (p->getManifest().system_vars == NULL)
1821
1829
 
1822
1830
} /* namespace drizzled */
1823
1831
 
1824
 
/** These exist just to prevent symbols from being optimized out */
1825
 
typedef drizzled::plugin::Manifest drizzled_builtin_list[];
1826
 
extern drizzled_builtin_list PANDORA_BUILTIN_SYMBOLS_LIST;
1827
 
drizzled::plugin::Manifest *drizzled_builtins[]=
1828
 
{
1829
 
  PANDORA_BUILTIN_SYMBOLS_LIST, NULL
1830
 
};
1831
1832