~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/registry.h

  • Committer: Jay Pipes
  • Date: 2009-11-16 22:00:02 UTC
  • mto: (1234.1.1 push) (1237.2.10 push)
  • mto: This revision was merged to the branch mainline in revision 1229.
  • Revision ID: jpipes@serialcoder-20091116220002-rdsha64utt41i8w8
Adds INFORMATION_SCHEMA views for the transaction log:

TRANSACTION_LOG
TRANSACTION_LOG_ENTRIES
TRANSACTION_LOG_TRANSACTIONS

Adds a new user-defined function:

PRINT_TRANSACTION_MESSAGE(filename, offset)

Adds tests for all of the above

Implementation notes:

An indexer now runs when transaction messages are applied
to the transaction log.  It creates a simple index of the
transaction log entries.  This index is used when the
information schema views' fillTable() method is called.

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;
39
 
class Library;
 
37
class Plugin;
40
38
 
41
39
class Registry
42
40
{
43
41
private:
44
 
  std::map<std::string, Library *> library_map;
45
42
  std::map<std::string, Module *> module_map;
46
 
  std::map<std::string, plugin::Plugin *> plugin_registry;
 
43
  std::map<std::string, const Plugin *> plugin_registry;
 
44
 
 
45
  Module *current_module;
47
46
 
48
47
  Registry()
49
48
   : module_map(),
50
 
     plugin_registry()
 
49
     plugin_registry(),
 
50
     current_module(NULL)
51
51
  { }
52
52
 
53
53
  Registry(const Registry&);
54
54
  Registry& operator=(const Registry&);
55
 
  ~Registry();
56
55
public:
57
56
 
58
 
  static Registry& singleton()
 
57
  static plugin::Registry& singleton()
59
58
  {
60
 
    static Registry *registry= new Registry();
 
59
    static plugin::Registry *registry= new plugin::Registry();
61
60
    return *registry;
62
61
  }
63
62
 
64
 
  void copy(plugin::Plugin::vector &arg);
65
 
 
66
 
  static void shutdown();
67
 
 
68
 
  Module *find(std::string name);
 
63
  static void shutdown()
 
64
  {
 
65
    plugin::Registry& registry= singleton();
 
66
    delete &registry;
 
67
  }
 
68
 
 
69
  Module *find(const LEX_STRING *name);
69
70
 
70
71
  void add(Module *module);
71
72
 
72
 
  void remove(Module *module);
 
73
  void setCurrentModule(Module *module)
 
74
  {
 
75
    current_module= module;
 
76
  }
 
77
 
 
78
  void clearCurrentModule()
 
79
  {
 
80
    current_module= NULL;
 
81
  }
73
82
 
74
83
  std::vector<Module *> getList(bool active);
75
84
 
76
 
  const std::map<std::string, plugin::Plugin *> &getPluginsMap() const
 
85
  const std::map<std::string, const Plugin *> &getPluginsMap() const
77
86
  {
78
87
    return plugin_registry;
79
88
  }
80
89
 
81
 
  const std::map<std::string, Module *> &getModulesMap() const
82
 
  {
83
 
    return module_map;
84
 
  }
85
 
 
86
 
  Library *addLibrary(const std::string &plugin_name, bool builtin= false);
87
 
  void removeLibrary(const std::string &plugin_name);
88
 
  Library *findLibrary(const std::string &plugin_name) const;
89
 
 
90
 
  void shutdownModules();
91
 
 
92
90
  template<class T>
93
91
  void add(T *plugin)
94
92
  {
 
93
    plugin->setModule(current_module);
95
94
    bool failed= false;
96
95
    std::string plugin_name(plugin->getName());
97
96
    std::transform(plugin_name.begin(), plugin_name.end(),
100
99
    {
101
100
      errmsg_printf(ERRMSG_LVL_ERROR,
102
101
                    _("Loading plugin %s failed: a plugin by that name already "
103
 
                      "exists.\n"), plugin->getName().c_str());
 
102
                      "exists."), plugin->getName().c_str());
104
103
      failed= true;
105
104
    }
106
105
    if (T::addPlugin(plugin))
108
107
    if (failed)
109
108
    {
110
109
      errmsg_printf(ERRMSG_LVL_ERROR,
111
 
                    _("Fatal error: Failed initializing %s plugin.\n"),
 
110
                    _("Fatal error: Failed initializing %s plugin."),
112
111
                    plugin->getName().c_str());
113
112
      unireg_abort(1);
114
113
    }
115
 
    plugin_registry.insert(std::pair<std::string, plugin::Plugin *>(plugin_name, plugin));
116
114
  }
117
115
 
118
116
  template<class T>
125
123
    plugin_registry.erase(plugin_name);
126
124
  }
127
125
 
128
 
 
129
126
};
130
127
 
131
 
} /* namespace module */
132
 
} /* namespace drizzled */
133
 
#endif /* DRIZZLED_MODULE_REGISTRY_H */
 
128
} /* end namespace plugin */
 
129
} /* end namespace drizzled */
 
130
#endif /* DRIZZLED_PLUGIN_REGISTRY_H */