~drizzle-trunk/drizzle/development

1324.2.1 by Monty Taylor
Create a plugin::Context object to carry information about the plugin module
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Monty Taylor
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
1324.2.1 by Monty Taylor
Create a plugin::Context object to carry information about the plugin module
21
1324.2.7 by Monty Taylor
Added a descriptive comment.
22
/**
23
 * @file Defines a Plugin Context
24
 *
1530.2.6 by Monty Taylor
Moved plugin::Context to module::Context.
25
 * A module::Context object is a proxy object containing state information
1324.2.7 by Monty Taylor
Added a descriptive comment.
26
 * about the plugin being registered that knows how to perform registration
27
 * actions.
28
 *
1530.2.6 by Monty Taylor
Moved plugin::Context to module::Context.
29
 * The plugin registration system creates a new module::Context for each
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
30
 * module::Module during the initializtion phase and passes a reference to
1530.2.6 by Monty Taylor
Moved plugin::Context to module::Context.
31
 * the module::Context to the module's init method. This allows the plugin
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
32
 * to call registration methods without having access to larger module::Registry
1324.2.7 by Monty Taylor
Added a descriptive comment.
33
 * calls. It also provides a filter layer through which calls are made in order
34
 * to force things like proper name prefixing and the like.
35
 */
36
2207.6.4 by Olaf van der Spek
Refactor
37
#include <boost/noncopyable.hpp>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
38
#include <drizzled/module/registry.h>
39
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
40
2207.6.4 by Olaf van der Spek
Refactor
41
namespace drizzled {
42
namespace module {
1626.2.1 by Monty Taylor
Added wrapper around variables_map to allow us to pull values back out of
43
2207.6.4 by Olaf van der Spek
Refactor
44
class DRIZZLED_API Context : boost::noncopyable
1324.2.1 by Monty Taylor
Create a plugin::Context object to carry information about the plugin module
45
{
46
public:
47
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
48
  Context(module::Registry &registry_arg,
49
          module::Module *module_arg) :
1324.2.1 by Monty Taylor
Create a plugin::Context object to carry information about the plugin module
50
     registry(registry_arg),
51
     module(module_arg)
52
  { }
53
54
  template<class T>
55
  void add(T *plugin)
56
  {
57
    plugin->setModule(module);
58
    registry.add(plugin);
59
  }
60
61
  template<class T>
62
  void remove(T *plugin)
63
  {
64
    registry.remove(plugin);
65
  }
66
67
  void registerVariable(sys_var *var);
1626.2.1 by Monty Taylor
Added wrapper around variables_map to allow us to pull values back out of
68
69
  option_map getOptions();
1857.3.1 by Monty Taylor
Added support for registering regular sys_var instances via module::Context.
70
71
  static std::string prepend_name(std::string module_name,
72
                                  const std::string &var_name);
2207.6.4 by Olaf van der Spek
Refactor
73
private:
74
  module::Registry &registry;
75
  module::Module *module;
1324.2.1 by Monty Taylor
Create a plugin::Context object to carry information about the plugin module
76
};
77
78
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
79
} /* namespace module */
80
} /* namespace drizzled */
1324.2.1 by Monty Taylor
Create a plugin::Context object to carry information about the plugin module
81