~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/registry.cc

  • Committer: Monty Taylor
  • Date: 2010-10-21 23:10:12 UTC
  • mto: (1879.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1880.
  • Revision ID: mordred@inaugust.com-20101021231012-uhsebiqo23xi0ygy
Updated AUTHORS list with everyone from bzr logs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "drizzled/show.h"
31
31
#include "drizzled/cursor.h"
32
32
 
33
 
#include <boost/bind.hpp>
34
 
 
35
33
using namespace std;
36
34
 
37
35
namespace drizzled
40
38
 
41
39
module::Registry::~Registry()
42
40
{
43
 
  std::map<std::string, plugin::Plugin *>::iterator plugin_iter;
 
41
  map<string, plugin::Plugin *>::iterator plugin_iter;
44
42
 
45
43
  /* Give all plugins a chance to cleanup, before
46
44
   * all plugins are deleted.
62
60
  }
63
61
  plugin_registry.clear();
64
62
 
65
 
#if 0
66
 
  @TODO When we delete modules here, we segfault on a bad string. Why?
 
63
  /*
 
64
    @TODO When we delete modules here, we segfault on a bad string. Why?
67
65
    map<string, module::Module *>::iterator module_iter= module_map.begin();
68
 
 
69
66
  while (module_iter != module_map.end())
70
67
  {
71
68
    delete (*module_iter).second;
72
69
    ++module_iter;
73
70
  }
74
71
  module_map.clear();
75
 
#endif
76
 
  std::map<std::string, module::Library *>::iterator library_iter= library_map.begin();
 
72
  */
 
73
  map<string, module::Library *>::iterator library_iter= library_map.begin();
77
74
  while (library_iter != library_map.end())
78
75
  {
79
76
    delete (*library_iter).second;
88
85
  delete &registry;
89
86
}
90
87
 
91
 
module::Module *module::Registry::find(std::string name)
 
88
module::Module *module::Registry::find(string name)
92
89
{
93
 
  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
 
90
  transform(name.begin(), name.end(), name.begin(), ::tolower);
94
91
 
95
 
  std::map<std::string, module::Module *>::iterator map_iter;
 
92
  map<string, module::Module *>::iterator map_iter;
96
93
  map_iter= module_map.find(name);
97
94
  if (map_iter != module_map.end())
98
95
    return (*map_iter).second;
101
98
 
102
99
void module::Registry::add(module::Module *handle)
103
100
{
104
 
  std::string add_str(handle->getName());
 
101
  string add_str(handle->getName());
105
102
  transform(add_str.begin(), add_str.end(),
106
103
            add_str.begin(), ::tolower);
107
104
 
110
107
 
111
108
void module::Registry::remove(module::Module *handle)
112
109
{
113
 
  std::string remove_str(handle->getName());
114
 
  std::transform(remove_str.begin(), remove_str.end(),
115
 
                 remove_str.begin(), ::tolower);
 
110
  string remove_str(handle->getName());
 
111
  transform(remove_str.begin(), remove_str.end(),
 
112
            remove_str.begin(), ::tolower);
116
113
 
117
114
  module_map.erase(remove_str);
118
115
}
119
116
 
120
 
void module::Registry::copy(plugin::Plugin::vector &arg)
121
 
{    
122
 
  arg.reserve(plugin_registry.size());
123
 
 
124
 
  std::transform(plugin_registry.begin(),
125
 
                 plugin_registry.end(),
126
 
                 std::back_inserter(arg),
127
 
                 boost::bind(&plugin::Plugin::map::value_type::second, _1) );
128
 
  assert(arg.size() == plugin_registry.size());
129
 
}
130
 
 
131
117
vector<module::Module *> module::Registry::getList(bool active)
132
118
{
133
119
  module::Module *plugin= NULL;
134
120
 
135
 
  std::vector<module::Module *> plugins;
 
121
  vector<module::Module *> plugins;
136
122
  plugins.reserve(module_map.size());
137
123
 
138
 
  std::map<std::string, module::Module *>::iterator map_iter;
 
124
  map<string, module::Module *>::iterator map_iter;
139
125
  for (map_iter= module_map.begin();
140
126
       map_iter != module_map.end();
141
127
       map_iter++)
150
136
  return plugins;
151
137
}
152
138
 
153
 
module::Library *module::Registry::addLibrary(const std::string &plugin_name,
 
139
module::Library *module::Registry::addLibrary(const string &plugin_name,
154
140
                                              bool builtin)
155
141
{
156
142
 
171
157
  return library;
172
158
}
173
159
 
174
 
void module::Registry::removeLibrary(const std::string &plugin_name)
 
160
void module::Registry::removeLibrary(const string &plugin_name)
175
161
{
176
 
  std::map<std::string, module::Library *>::iterator iter=
 
162
  map<string, module::Library *>::iterator iter=
177
163
    library_map.find(plugin_name);
178
164
  if (iter != library_map.end())
179
165
  {
182
168
  }
183
169
}
184
170
 
185
 
module::Library *module::Registry::findLibrary(const std::string &plugin_name) const
 
171
module::Library *module::Registry::findLibrary(const string &plugin_name) const
186
172
{
187
 
  std::map<std::string, module::Library *>::const_iterator iter=
 
173
  map<string, module::Library *>::const_iterator iter=
188
174
    library_map.find(plugin_name);
189
175
  if (iter != library_map.end())
190
176
    return (*iter).second;