~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/registry.cc

  • Committer: Joseph Daly
  • Date: 2010-09-16 17:47:44 UTC
  • mto: (1774.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1775.
  • Revision ID: jdaly@rx7-20100916174744-9myzc6sigk4zrmtn
fix copyright

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;
44
 
 
45
 
  /* Give all plugins a chance to cleanup, before
46
 
   * all plugins are deleted.
47
 
   * This can be used if shutdown code references
48
 
   * other plugins.
49
 
   */
50
 
  plugin_iter= plugin_registry.begin();
51
 
  while (plugin_iter != plugin_registry.end())
52
 
  {
53
 
    (*plugin_iter).second->shutdownPlugin();
54
 
    ++plugin_iter;
55
 
  }
56
 
 
57
 
  plugin_iter= plugin_registry.begin();
 
41
  map<string, plugin::Plugin *>::iterator plugin_iter= plugin_registry.begin();
58
42
  while (plugin_iter != plugin_registry.end())
59
43
  {
60
44
    delete (*plugin_iter).second;
62
46
  }
63
47
  plugin_registry.clear();
64
48
 
65
 
#if 0
66
 
  @TODO When we delete modules here, we segfault on a bad string. Why?
 
49
  /*
 
50
    @TODO When we delete modules here, we segfault on a bad string. Why?
67
51
    map<string, module::Module *>::iterator module_iter= module_map.begin();
68
 
 
69
52
  while (module_iter != module_map.end())
70
53
  {
71
54
    delete (*module_iter).second;
72
55
    ++module_iter;
73
56
  }
74
57
  module_map.clear();
75
 
#endif
76
 
  std::map<std::string, module::Library *>::iterator library_iter= library_map.begin();
 
58
  */
 
59
  map<string, module::Library *>::iterator library_iter= library_map.begin();
77
60
  while (library_iter != library_map.end())
78
61
  {
79
62
    delete (*library_iter).second;
88
71
  delete &registry;
89
72
}
90
73
 
91
 
module::Module *module::Registry::find(std::string name)
 
74
module::Module *module::Registry::find(string name)
92
75
{
93
 
  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
 
76
  transform(name.begin(), name.end(), name.begin(), ::tolower);
94
77
 
95
 
  std::map<std::string, module::Module *>::iterator map_iter;
 
78
  map<string, module::Module *>::iterator map_iter;
96
79
  map_iter= module_map.find(name);
97
80
  if (map_iter != module_map.end())
98
81
    return (*map_iter).second;
101
84
 
102
85
void module::Registry::add(module::Module *handle)
103
86
{
104
 
  std::string add_str(handle->getName());
 
87
  string add_str(handle->getName());
105
88
  transform(add_str.begin(), add_str.end(),
106
89
            add_str.begin(), ::tolower);
107
90
 
110
93
 
111
94
void module::Registry::remove(module::Module *handle)
112
95
{
113
 
  std::string remove_str(handle->getName());
114
 
  std::transform(remove_str.begin(), remove_str.end(),
115
 
                 remove_str.begin(), ::tolower);
 
96
  string remove_str(handle->getName());
 
97
  transform(remove_str.begin(), remove_str.end(),
 
98
            remove_str.begin(), ::tolower);
116
99
 
117
100
  module_map.erase(remove_str);
118
101
}
119
102
 
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
103
vector<module::Module *> module::Registry::getList(bool active)
132
104
{
133
105
  module::Module *plugin= NULL;
134
106
 
135
 
  std::vector<module::Module *> plugins;
 
107
  vector<module::Module *> plugins;
136
108
  plugins.reserve(module_map.size());
137
109
 
138
 
  std::map<std::string, module::Module *>::iterator map_iter;
 
110
  map<string, module::Module *>::iterator map_iter;
139
111
  for (map_iter= module_map.begin();
140
112
       map_iter != module_map.end();
141
113
       map_iter++)
150
122
  return plugins;
151
123
}
152
124
 
153
 
module::Library *module::Registry::addLibrary(const std::string &plugin_name,
 
125
module::Library *module::Registry::addLibrary(const string &plugin_name,
154
126
                                              bool builtin)
155
127
{
156
128
 
171
143
  return library;
172
144
}
173
145
 
174
 
void module::Registry::removeLibrary(const std::string &plugin_name)
 
146
void module::Registry::removeLibrary(const string &plugin_name)
175
147
{
176
 
  std::map<std::string, module::Library *>::iterator iter=
 
148
  map<string, module::Library *>::iterator iter=
177
149
    library_map.find(plugin_name);
178
150
  if (iter != library_map.end())
179
151
  {
182
154
  }
183
155
}
184
156
 
185
 
module::Library *module::Registry::findLibrary(const std::string &plugin_name) const
 
157
module::Library *module::Registry::findLibrary(const string &plugin_name) const
186
158
{
187
 
  std::map<std::string, module::Library *>::const_iterator iter=
 
159
  map<string, module::Library *>::const_iterator iter=
188
160
    library_map.find(plugin_name);
189
161
  if (iter != library_map.end())
190
162
    return (*iter).second;