~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/registry.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:
23
23
#include <vector>
24
24
#include <map>
25
25
 
26
 
#include "drizzled/plugin/registry.h"
 
26
#include "drizzled/module/registry.h"
 
27
#include "drizzled/module/library.h"
27
28
 
28
29
#include "drizzled/plugin.h"
29
 
#include "drizzled/plugin/library.h"
30
30
#include "drizzled/show.h"
31
31
#include "drizzled/cursor.h"
32
32
 
35
35
namespace drizzled
36
36
{
37
37
 
38
 
plugin::Registry::~Registry()
 
38
 
 
39
module::Registry::~Registry()
39
40
{
40
41
  map<string, plugin::Plugin *>::iterator plugin_iter= plugin_registry.begin();
41
42
  while (plugin_iter != plugin_registry.end())
47
48
 
48
49
  /*
49
50
    @TODO When we delete modules here, we segfault on a bad string. Why?
50
 
    map<string, plugin::Module *>::iterator module_iter= module_map.begin();
 
51
    map<string, module::Module *>::iterator module_iter= module_map.begin();
51
52
  while (module_iter != module_map.end())
52
53
  {
53
54
    delete (*module_iter).second;
55
56
  }
56
57
  module_map.clear();
57
58
  */
58
 
  map<string, plugin::Library *>::iterator library_iter= library_map.begin();
 
59
  map<string, module::Library *>::iterator library_iter= library_map.begin();
59
60
  while (library_iter != library_map.end())
60
61
  {
61
62
    delete (*library_iter).second;
64
65
  library_map.clear();
65
66
}
66
67
 
67
 
void plugin::Registry::shutdown()
 
68
void module::Registry::shutdown()
68
69
{
69
 
  plugin::Registry& registry= singleton();
 
70
  module::Registry& registry= singleton();
70
71
  delete &registry;
71
72
}
72
73
 
73
 
plugin::Module *plugin::Registry::find(string name)
 
74
module::Module *module::Registry::find(string name)
74
75
{
75
76
  transform(name.begin(), name.end(), name.begin(), ::tolower);
76
77
 
77
 
  map<string, plugin::Module *>::iterator map_iter;
 
78
  map<string, module::Module *>::iterator map_iter;
78
79
  map_iter= module_map.find(name);
79
80
  if (map_iter != module_map.end())
80
81
    return (*map_iter).second;
81
82
  return(0);
82
83
}
83
84
 
84
 
void plugin::Registry::add(plugin::Module *handle)
 
85
void module::Registry::add(module::Module *handle)
85
86
{
86
87
  string add_str(handle->getName());
87
88
  transform(add_str.begin(), add_str.end(),
91
92
}
92
93
 
93
94
 
94
 
vector<plugin::Module *> plugin::Registry::getList(bool active)
 
95
vector<module::Module *> module::Registry::getList(bool active)
95
96
{
96
 
  plugin::Module *plugin= NULL;
 
97
  module::Module *plugin= NULL;
97
98
 
98
 
  vector<plugin::Module *> plugins;
 
99
  vector<module::Module *> plugins;
99
100
  plugins.reserve(module_map.size());
100
101
 
101
 
  map<string, plugin::Module *>::iterator map_iter;
 
102
  map<string, module::Module *>::iterator map_iter;
102
103
  for (map_iter= module_map.begin();
103
104
       map_iter != module_map.end();
104
105
       map_iter++)
113
114
  return plugins;
114
115
}
115
116
 
116
 
 
117
 
plugin::Library *plugin::Registry::addLibrary(const string &plugin_name,
 
117
module::Library *module::Registry::addLibrary(const string &plugin_name,
118
118
                                              bool builtin)
119
119
{
120
120
 
121
121
  /* If this dll is already loaded just return it */
122
 
  plugin::Library *library= findLibrary(plugin_name);
 
122
  module::Library *library= findLibrary(plugin_name);
123
123
  if (library != NULL)
124
124
  {
125
125
    return library;
126
126
  }
127
127
 
128
 
  library= plugin::Library::loadLibrary(plugin_name, builtin);
 
128
  library= module::Library::loadLibrary(plugin_name, builtin);
129
129
  if (library != NULL)
130
130
  {
131
131
    /* Add this dll to the map */
135
135
  return library;
136
136
}
137
137
 
138
 
void plugin::Registry::removeLibrary(const string &plugin_name)
 
138
void module::Registry::removeLibrary(const string &plugin_name)
139
139
{
140
 
  map<string, plugin::Library *>::iterator iter=
 
140
  map<string, module::Library *>::iterator iter=
141
141
    library_map.find(plugin_name);
142
142
  if (iter != library_map.end())
143
143
  {
146
146
  }
147
147
}
148
148
 
149
 
plugin::Library *plugin::Registry::findLibrary(const string &plugin_name) const
 
149
module::Library *module::Registry::findLibrary(const string &plugin_name) const
150
150
{
151
 
  map<string, plugin::Library *>::const_iterator iter=
 
151
  map<string, module::Library *>::const_iterator iter=
152
152
    library_map.find(plugin_name);
153
153
  if (iter != library_map.end())
154
154
    return (*iter).second;
155
155
  return NULL;
156
156
}
157
157
 
 
158
void module::Registry::shutdownModules()
 
159
{
 
160
  module_shutdown(*this);
 
161
}
 
162
 
158
163
} /* namespace drizzled */