~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/registry.h

Fixed a style variance.

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
 
#ifndef DRIZZLED_MODULE_REGISTRY_H
21
 
#define DRIZZLED_MODULE_REGISTRY_H
 
20
#ifndef DRIZZLED_PLUGIN_REGISTRY_H
 
21
#define DRIZZLED_PLUGIN_REGISTRY_H
22
22
 
23
23
#include <string>
24
24
#include <vector>
28
28
#include "drizzled/gettext.h"
29
29
#include "drizzled/unireg.h"
30
30
#include "drizzled/errmsg_print.h"
31
 
#include "drizzled/plugin/plugin.h"
32
31
 
33
32
namespace drizzled
34
33
{
35
 
 
36
 
namespace module
 
34
namespace plugin
37
35
{
38
36
class Module;
 
37
class Plugin;
39
38
class Library;
40
39
 
41
40
class Registry
43
42
private:
44
43
  std::map<std::string, Library *> library_map;
45
44
  std::map<std::string, Module *> module_map;
46
 
  std::map<std::string, plugin::Plugin *> plugin_registry;
 
45
  std::map<std::string, const Plugin *> plugin_registry;
 
46
 
 
47
  Module *current_module;
47
48
 
48
49
  Registry()
49
50
   : module_map(),
50
 
     plugin_registry()
 
51
     plugin_registry(),
 
52
     current_module(NULL)
51
53
  { }
52
54
 
53
55
  Registry(const Registry&);
55
57
  ~Registry();
56
58
public:
57
59
 
58
 
  static Registry& singleton()
 
60
  static plugin::Registry& singleton()
59
61
  {
60
 
    static Registry *registry= new Registry();
 
62
    static plugin::Registry *registry= new plugin::Registry();
61
63
    return *registry;
62
64
  }
63
65
 
64
 
  void copy(plugin::Plugin::vector &arg);
65
 
 
66
66
  static void shutdown();
67
67
 
68
68
  Module *find(std::string name);
69
69
 
70
70
  void add(Module *module);
71
71
 
72
 
  void remove(Module *module);
 
72
  void setCurrentModule(Module *module)
 
73
  {
 
74
    current_module= module;
 
75
  }
 
76
 
 
77
  void clearCurrentModule()
 
78
  {
 
79
    current_module= NULL;
 
80
  }
73
81
 
74
82
  std::vector<Module *> getList(bool active);
75
83
 
76
 
  const std::map<std::string, plugin::Plugin *> &getPluginsMap() const
 
84
  const std::map<std::string, const Plugin *> &getPluginsMap() const
77
85
  {
78
86
    return plugin_registry;
79
87
  }
83
91
    return module_map;
84
92
  }
85
93
 
86
 
  Library *addLibrary(const std::string &plugin_name, bool builtin= false);
 
94
  Library *addLibrary(const std::string &plugin_name);
87
95
  void removeLibrary(const std::string &plugin_name);
88
96
  Library *findLibrary(const std::string &plugin_name) const;
89
97
 
90
 
  void shutdownModules();
91
 
 
92
98
  template<class T>
93
99
  void add(T *plugin)
94
100
  {
 
101
    plugin->setModule(current_module);
95
102
    bool failed= false;
96
103
    std::string plugin_name(plugin->getName());
97
104
    std::transform(plugin_name.begin(), plugin_name.end(),
112
119
                    plugin->getName().c_str());
113
120
      unireg_abort(1);
114
121
    }
115
 
    plugin_registry.insert(std::pair<std::string, plugin::Plugin *>(plugin_name, plugin));
 
122
    plugin_registry.insert(std::pair<std::string, const Plugin *>(plugin_name, plugin));
116
123
  }
117
124
 
118
125
  template<class T>
128
135
 
129
136
};
130
137
 
131
 
} /* namespace module */
132
 
} /* namespace drizzled */
133
 
#endif /* DRIZZLED_MODULE_REGISTRY_H */
 
138
} /* end namespace plugin */
 
139
} /* end namespace drizzled */
 
140
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */