~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/registry.h

  • Committer: Lee Bieber
  • Date: 2011-01-05 05:15:02 UTC
  • mfrom: (2055.1.2 build)
  • Revision ID: kalebral@gmail.com-20110105051502-9v4xuoozzpkka8rs
Merge Evan - fix bug 682773 libdrizzle performance: in non-blocking mode don't attempt to read after write
Merge Stewart - add in more tests from the suites directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
class Registry
42
42
{
43
 
public:
44
 
  typedef std::map<std::string, Library *> LibraryMap;
45
 
  typedef std::map<std::string, Module *> ModuleMap;
46
43
private:
47
 
  LibraryMap library_registry_;
48
 
  ModuleMap module_registry_;
49
 
  
50
 
  plugin::Plugin::map plugin_registry;
 
44
  std::map<std::string, Library *> library_map;
 
45
  std::map<std::string, Module *> module_map;
 
46
  std::map<std::string, plugin::Plugin *> plugin_registry;
51
47
 
52
48
  Registry()
53
 
   : module_registry_(),
 
49
   : module_map(),
54
50
     plugin_registry()
55
51
  { }
56
52
 
77
73
 
78
74
  std::vector<Module *> getList(bool active);
79
75
 
80
 
  const plugin::Plugin::map &getPluginsMap() const
 
76
  const std::map<std::string, plugin::Plugin *> &getPluginsMap() const
81
77
  {
82
78
    return plugin_registry;
83
79
  }
84
80
 
85
 
  const ModuleMap &getModulesMap() const
 
81
  const std::map<std::string, Module *> &getModulesMap() const
86
82
  {
87
 
    return module_registry_;
 
83
    return module_map;
88
84
  }
89
85
 
90
86
  Library *addLibrary(const std::string &plugin_name, bool builtin= false);
97
93
  void add(T *plugin)
98
94
  {
99
95
    bool failed= false;
100
 
    std::string plugin_type(plugin->getTypeName());
101
 
    std::transform(plugin_type.begin(), plugin_type.end(),
102
 
                   plugin_type.begin(), ::tolower);
103
96
    std::string plugin_name(plugin->getName());
104
97
    std::transform(plugin_name.begin(), plugin_name.end(),
105
98
                   plugin_name.begin(), ::tolower);
106
 
    if (plugin_registry.find(std::make_pair(plugin_type, plugin_name)) != plugin_registry.end())
 
99
    if (plugin_registry.find(plugin_name) != plugin_registry.end())
107
100
    {
108
101
      errmsg_printf(ERRMSG_LVL_ERROR,
109
 
                    _("Loading plugin %s failed: a %s plugin by that name "
110
 
                      "already exists.\n"),
111
 
                    plugin->getTypeName().c_str(),
112
 
                    plugin->getName().c_str());
 
102
                    _("Loading plugin %s failed: a plugin by that name already "
 
103
                      "exists.\n"), plugin->getName().c_str());
113
104
      failed= true;
114
105
    }
115
106
    if (T::addPlugin(plugin))
116
 
    {
117
107
      failed= true;
118
 
    }
119
 
 
120
108
    if (failed)
121
109
    {
122
110
      errmsg_printf(ERRMSG_LVL_ERROR,
123
 
                    _("Fatal error: Failed initializing %s::%s plugin.\n"),
124
 
                    plugin->getTypeName().c_str(),
 
111
                    _("Fatal error: Failed initializing %s plugin.\n"),
125
112
                    plugin->getName().c_str());
126
113
      unireg_abort(1);
127
114
    }
128
 
    plugin_registry.insert(std::make_pair(std::make_pair(plugin_type, plugin_name), plugin));
 
115
    plugin_registry.insert(std::pair<std::string, plugin::Plugin *>(plugin_name, plugin));
129
116
  }
130
117
 
131
118
  template<class T>
132
119
  void remove(T *plugin)
133
120
  {
134
 
    std::string plugin_type(plugin->getTypeName());
135
 
    std::transform(plugin_type.begin(), plugin_type.end(),
136
 
                   plugin_type.begin(), ::tolower);
137
121
    std::string plugin_name(plugin->getName());
138
122
    std::transform(plugin_name.begin(), plugin_name.end(),
139
123
                   plugin_name.begin(), ::tolower);
140
124
    T::removePlugin(plugin);
141
 
    plugin_registry.erase(std::make_pair(plugin_type, plugin_name));
 
125
    plugin_registry.erase(plugin_name);
142
126
  }
143
127
 
144
128