~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/registry.cc

Remove PLUGIN and MODULES.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "drizzled/server_includes.h"
 
20
#include "config.h"
 
21
 
 
22
#include <string>
 
23
#include <vector>
 
24
#include <map>
 
25
 
21
26
#include "drizzled/plugin/registry.h"
22
27
 
23
28
#include "drizzled/plugin.h"
 
29
#include "drizzled/plugin/library.h"
24
30
#include "drizzled/show.h"
25
31
#include "drizzled/cursor.h"
26
32
 
27
 
#include <string>
28
 
#include <vector>
29
 
#include <map>
30
 
 
31
33
using namespace std;
32
34
 
33
35
namespace drizzled
34
36
{
35
37
 
36
 
plugin::Module *plugin::Registry::find(const LEX_STRING *name)
37
 
{
38
 
  string find_str(name->str,name->length);
39
 
  transform(find_str.begin(), find_str.end(), find_str.begin(), ::tolower);
 
38
plugin::Registry::~Registry()
 
39
{
 
40
  map<string, plugin::Library *>::iterator iter= library_map.begin();
 
41
  while (iter != library_map.end())
 
42
  {
 
43
    delete (*iter).second;
 
44
    ++iter;
 
45
  }
 
46
  library_map.clear();
 
47
}
 
48
 
 
49
void plugin::Registry::shutdown()
 
50
{
 
51
  plugin::Registry& registry= singleton();
 
52
  delete &registry;
 
53
}
 
54
 
 
55
plugin::Module *plugin::Registry::find(string name)
 
56
{
 
57
  transform(name.begin(), name.end(), name.begin(), ::tolower);
40
58
 
41
59
  map<string, plugin::Module *>::iterator map_iter;
42
 
  map_iter= module_map.find(find_str);
 
60
  map_iter= module_map.find(name);
43
61
  if (map_iter != module_map.end())
44
62
    return (*map_iter).second;
45
63
  return(0);
59
77
{
60
78
  plugin::Module *plugin= NULL;
61
79
 
62
 
  vector <plugin::Module *> plugins;
 
80
  vector<plugin::Module *> plugins;
63
81
  plugins.reserve(module_map.size());
64
82
 
65
83
  map<string, plugin::Module *>::iterator map_iter;
77
95
  return plugins;
78
96
}
79
97
 
 
98
plugin::Library *plugin::Registry::addLibrary(const string &plugin_name)
 
99
{
 
100
 
 
101
  /* If this dll is already loaded just return it */
 
102
  plugin::Library *library= findLibrary(plugin_name);
 
103
  if (library != NULL)
 
104
  {
 
105
    return library;
 
106
  }
 
107
 
 
108
  library= plugin::Library::loadLibrary(plugin_name);
 
109
  if (library != NULL)
 
110
  {
 
111
    /* Add this dll to the map */
 
112
    library_map.insert(make_pair(plugin_name, library));
 
113
  }
 
114
 
 
115
  return library;
 
116
}
 
117
 
 
118
void plugin::Registry::removeLibrary(const string &plugin_name)
 
119
{
 
120
  map<string, plugin::Library *>::iterator iter=
 
121
    library_map.find(plugin_name);
 
122
  if (iter != library_map.end())
 
123
  {
 
124
    library_map.erase(iter);
 
125
    delete (*iter).second;
 
126
  }
 
127
}
 
128
 
 
129
plugin::Library *plugin::Registry::findLibrary(const string &plugin_name) const
 
130
{
 
131
  map<string, plugin::Library *>::const_iterator iter=
 
132
    library_map.find(plugin_name);
 
133
  if (iter != library_map.end())
 
134
    return (*iter).second;
 
135
  return NULL;
 
136
}
 
137
 
80
138
} /* namespace drizzled */