~drizzle-trunk/drizzle/development

1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2009 Sun Microsystems
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
20
#ifndef DRIZZLED_PLUGIN_PLUGIN_H
21
#define DRIZZLED_PLUGIN_PLUGIN_H
22
1130.2.6 by Monty Taylor
Merged in latest plugin-slot-reorg.
23
#include <string>
24
#include <vector>
25
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
26
namespace drizzled
27
{
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
28
namespace module
29
{
30
class Module;
31
}
32
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
33
namespace plugin
34
{
35
36
class Plugin
37
{
38
private:
39
  const std::string name;
1130.2.29 by Monty Taylor
Removed runtime active flag from plugin::Plugin. Put a runtime enabled flag on CommandApplier and CommandReplicator - we can refactor this down into plugin::Plugin later if we need to.
40
  bool is_active;
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
41
  module::Module *module;
1192.2.5 by Monty Taylor
Replaced overridable virtual methods with passing name to constructor. Now individual plugins will not be allowed to set their own plugin type name. :)
42
  const std::string type_name;
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
43
44
  Plugin();
45
  Plugin(const Plugin&);
46
  Plugin& operator=(const Plugin &);
47
public:
1130.2.24 by Monty Taylor
Additional changes to command_log to work with how jay was using active/enable.
48
1192.2.5 by Monty Taylor
Replaced overridable virtual methods with passing name to constructor. Now individual plugins will not be allowed to set their own plugin type name. :)
49
  explicit Plugin(std::string in_name, std::string in_type_name);
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
50
  virtual ~Plugin() {}
51
1784.4.1 by Paul McCullagh
Fixed PBXT recovery and shutdown, added shutdownPlugin() call to all plugins before the plugins are deleted
52
  /*
53
   * This method is called for all plug-ins on shutdown,
54
   * _before_ the plug-ins are deleted. It can be used
55
   * when shutdown code references other plug-ins.
56
   */
57
  virtual void shutdownPlugin()
58
  {
59
  }
60
 
1130.2.29 by Monty Taylor
Removed runtime active flag from plugin::Plugin. Put a runtime enabled flag on CommandApplier and CommandReplicator - we can refactor this down into plugin::Plugin later if we need to.
61
  void activate()
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
62
  {
1130.2.24 by Monty Taylor
Additional changes to command_log to work with how jay was using active/enable.
63
    is_active= true;
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
64
  }
65
 
1130.2.29 by Monty Taylor
Removed runtime active flag from plugin::Plugin. Put a runtime enabled flag on CommandApplier and CommandReplicator - we can refactor this down into plugin::Plugin later if we need to.
66
  void deactivate()
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
67
  {
1130.2.24 by Monty Taylor
Additional changes to command_log to work with how jay was using active/enable.
68
    is_active= false;
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
69
  }
70
 
1130.2.29 by Monty Taylor
Removed runtime active flag from plugin::Plugin. Put a runtime enabled flag on CommandApplier and CommandReplicator - we can refactor this down into plugin::Plugin later if we need to.
71
  bool isActive() const
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
72
  {
1130.2.24 by Monty Taylor
Additional changes to command_log to work with how jay was using active/enable.
73
    return is_active;
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
74
  }
75
76
  const std::string &getName() const
77
  {
78
    return name;
79
  } 
80
1530.2.5 by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant
81
  void setModule(module::Module *module_arg)
1130.2.2 by Monty Taylor
Added support for the global list of plugin::Plugin objects to slot::Function
82
  {
1192.2.3 by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity.
83
    module= module_arg;
1130.2.2 by Monty Taylor
Added support for the global list of plugin::Plugin objects to slot::Function
84
  }
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
85
1192.2.5 by Monty Taylor
Replaced overridable virtual methods with passing name to constructor. Now individual plugins will not be allowed to set their own plugin type name. :)
86
  const std::string& getTypeName() const
1192.2.1 by Monty Taylor
Added the MODULES table.
87
  {
1192.2.5 by Monty Taylor
Replaced overridable virtual methods with passing name to constructor. Now individual plugins will not be allowed to set their own plugin type name. :)
88
    return type_name;
1192.2.1 by Monty Taylor
Added the MODULES table.
89
  }
90
91
  const std::string& getModuleName() const;
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
92
};
93
} /* end namespace plugin */
94
} /* end namespace drizzled */
95
96
#endif /* DRIZZLED_PLUGIN_PLUGIN_H */