Drizzled Public API Documentation

plugin.h
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, Inc.
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 
21 
22 #pragma once
23 
24 #include <string>
25 #include <vector>
26 #include <map>
27 
28 #include <drizzled/visibility.h>
29 #include <drizzled/common_fwd.h>
30 
31 namespace drizzled {
32 namespace plugin {
33 
34 class DRIZZLED_API Plugin : boost::noncopyable
35 {
36 private:
37  const std::string _name;
38  bool _is_active;
39  module::Module *_module;
40  const std::string _type_name;
41 
42 public:
43  typedef std::pair<const std::string, const std::string> map_key;
44  typedef std::map<const map_key, plugin::Plugin *> map;
45  typedef std::vector<Plugin *> vector;
46 
47  explicit Plugin(const std::string &name, const std::string &type_name);
48  virtual ~Plugin() {}
49 
50  /*
51  * This method is called for all plug-ins on shutdown,
52  * _before_ the plug-ins are deleted. It can be used
53  * when shutdown code references other plug-ins.
54  */
55  virtual void shutdownPlugin()
56  {
57  }
58 
59  // This is run after all plugins have been initialized.
60  virtual void prime()
61  {
62  }
63 
64  virtual void startup(drizzled::Session &)
65  {
66  }
67 
68  void activate()
69  {
70  _is_active= true;
71  }
72 
73  void deactivate()
74  {
75  _is_active= false;
76  }
77 
78  bool isActive() const
79  {
80  return _is_active;
81  }
82 
83  const std::string &getName() const
84  {
85  return _name;
86  }
87 
88  void setModule(module::Module *module)
89  {
90  _module= module;
91  }
92 
93  const std::string& getTypeName() const
94  {
95  return _type_name;
96  }
97 
98  virtual bool removeLast() const
99  {
100  return false;
101  }
102 
103  const std::string& getModuleName() const;
104 };
105 } /* end namespace plugin */
106 } /* end namespace drizzled */
107 
TODO: Rename this file - func.h is stupid.
#define DRIZZLED_API
Definition: visibility.h:62
Visibility Control Macros.
Definition: engine.cc:41