~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/registry.cc

  • Committer: Brian Aker
  • Date: 2010-05-07 06:18:08 UTC
  • mto: (1527.1.1 staging)
  • mto: This revision was merged to the branch mainline in revision 1526.
  • Revision ID: brian@gaz-20100507061808-xtbz9dgb32o783yg
Remove members to functions that are no longer used.

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/module/registry.h"
27
 
#include "drizzled/module/library.h"
 
26
#include "drizzled/plugin/registry.h"
28
27
 
29
28
#include "drizzled/plugin.h"
 
29
#include "drizzled/plugin/library.h"
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
38
36
{
39
37
 
40
 
 
41
 
module::Registry::~Registry()
 
38
plugin::Registry::~Registry()
42
39
{
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();
 
40
  map<string, plugin::Plugin *>::iterator plugin_iter= plugin_registry.begin();
58
41
  while (plugin_iter != plugin_registry.end())
59
42
  {
60
43
    delete (*plugin_iter).second;
62
45
  }
63
46
  plugin_registry.clear();
64
47
 
65
 
#if 0
66
 
  @TODO When we delete modules here, we segfault on a bad string. Why?
67
 
    map<string, module::Module *>::iterator module_iter= module_map.begin();
68
 
 
 
48
  /*
 
49
    @TODO When we delete modules here, we segfault on a bad string. Why?
 
50
    map<string, plugin::Module *>::iterator module_iter= module_map.begin();
69
51
  while (module_iter != module_map.end())
70
52
  {
71
53
    delete (*module_iter).second;
72
54
    ++module_iter;
73
55
  }
74
56
  module_map.clear();
75
 
#endif
76
 
  std::map<std::string, module::Library *>::iterator library_iter= library_map.begin();
 
57
  */
 
58
  map<string, plugin::Library *>::iterator library_iter= library_map.begin();
77
59
  while (library_iter != library_map.end())
78
60
  {
79
61
    delete (*library_iter).second;
82
64
  library_map.clear();
83
65
}
84
66
 
85
 
void module::Registry::shutdown()
 
67
void plugin::Registry::shutdown()
86
68
{
87
 
  module::Registry& registry= singleton();
 
69
  plugin::Registry& registry= singleton();
88
70
  delete &registry;
89
71
}
90
72
 
91
 
module::Module *module::Registry::find(std::string name)
 
73
plugin::Module *plugin::Registry::find(string name)
92
74
{
93
 
  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
 
75
  transform(name.begin(), name.end(), name.begin(), ::tolower);
94
76
 
95
 
  std::map<std::string, module::Module *>::iterator map_iter;
 
77
  map<string, plugin::Module *>::iterator map_iter;
96
78
  map_iter= module_map.find(name);
97
79
  if (map_iter != module_map.end())
98
80
    return (*map_iter).second;
99
81
  return(0);
100
82
}
101
83
 
102
 
void module::Registry::add(module::Module *handle)
 
84
void plugin::Registry::add(plugin::Module *handle)
103
85
{
104
 
  std::string add_str(handle->getName());
 
86
  string add_str(handle->getName());
105
87
  transform(add_str.begin(), add_str.end(),
106
88
            add_str.begin(), ::tolower);
107
89
 
108
90
  module_map[add_str]= handle;
109
91
}
110
92
 
111
 
void module::Registry::remove(module::Module *handle)
112
 
{
113
 
  std::string remove_str(handle->getName());
114
 
  std::transform(remove_str.begin(), remove_str.end(),
115
 
                 remove_str.begin(), ::tolower);
116
 
 
117
 
  module_map.erase(remove_str);
118
 
}
119
 
 
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
 
vector<module::Module *> module::Registry::getList(bool active)
132
 
{
133
 
  module::Module *plugin= NULL;
134
 
 
135
 
  std::vector<module::Module *> plugins;
 
93
 
 
94
vector<plugin::Module *> plugin::Registry::getList(bool active)
 
95
{
 
96
  plugin::Module *plugin= NULL;
 
97
 
 
98
  vector<plugin::Module *> plugins;
136
99
  plugins.reserve(module_map.size());
137
100
 
138
 
  std::map<std::string, module::Module *>::iterator map_iter;
 
101
  map<string, plugin::Module *>::iterator map_iter;
139
102
  for (map_iter= module_map.begin();
140
103
       map_iter != module_map.end();
141
104
       map_iter++)
150
113
  return plugins;
151
114
}
152
115
 
153
 
module::Library *module::Registry::addLibrary(const std::string &plugin_name,
154
 
                                              bool builtin)
 
116
plugin::Library *plugin::Registry::addLibrary(const string &plugin_name)
155
117
{
156
118
 
157
119
  /* If this dll is already loaded just return it */
158
 
  module::Library *library= findLibrary(plugin_name);
 
120
  plugin::Library *library= findLibrary(plugin_name);
159
121
  if (library != NULL)
160
122
  {
161
123
    return library;
162
124
  }
163
125
 
164
 
  library= module::Library::loadLibrary(plugin_name, builtin);
 
126
  library= plugin::Library::loadLibrary(plugin_name);
165
127
  if (library != NULL)
166
128
  {
167
129
    /* Add this dll to the map */
171
133
  return library;
172
134
}
173
135
 
174
 
void module::Registry::removeLibrary(const std::string &plugin_name)
 
136
void plugin::Registry::removeLibrary(const string &plugin_name)
175
137
{
176
 
  std::map<std::string, module::Library *>::iterator iter=
 
138
  map<string, plugin::Library *>::iterator iter=
177
139
    library_map.find(plugin_name);
178
140
  if (iter != library_map.end())
179
141
  {
182
144
  }
183
145
}
184
146
 
185
 
module::Library *module::Registry::findLibrary(const std::string &plugin_name) const
 
147
plugin::Library *plugin::Registry::findLibrary(const string &plugin_name) const
186
148
{
187
 
  std::map<std::string, module::Library *>::const_iterator iter=
 
149
  map<string, plugin::Library *>::const_iterator iter=
188
150
    library_map.find(plugin_name);
189
151
  if (iter != library_map.end())
190
152
    return (*iter).second;
191
153
  return NULL;
192
154
}
193
155
 
194
 
void module::Registry::shutdownModules()
195
 
{
196
 
  module_shutdown(*this);
197
 
}
198
 
 
199
156
} /* namespace drizzled */