00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027
00028 #include <drizzled/visibility.h>
00029
00030 namespace drizzled
00031 {
00032
00033 class Session;
00034
00035 namespace module
00036 {
00037 class Module;
00038 }
00039
00040 namespace plugin
00041 {
00042
00043 class DRIZZLED_API Plugin
00044 {
00045 private:
00046 const std::string _name;
00047 bool _is_active;
00048 module::Module *_module;
00049 const std::string _type_name;
00050
00051 Plugin();
00052 Plugin(const Plugin&);
00053 Plugin& operator=(const Plugin &);
00054 public:
00055 typedef std::pair<const std::string, const std::string> map_key;
00056 typedef std::map<const map_key, plugin::Plugin *> map;
00057 typedef std::vector<Plugin *> vector;
00058
00059 explicit Plugin(const std::string &name, const std::string &type_name);
00060 virtual ~Plugin() {}
00061
00062
00063
00064
00065
00066
00067 virtual void shutdownPlugin()
00068 {
00069 }
00070
00071
00072 virtual void prime()
00073 {
00074 }
00075
00076 virtual void startup(drizzled::Session &)
00077 {
00078 }
00079
00080 void activate()
00081 {
00082 _is_active= true;
00083 }
00084
00085 void deactivate()
00086 {
00087 _is_active= false;
00088 }
00089
00090 bool isActive() const
00091 {
00092 return _is_active;
00093 }
00094
00095 const std::string &getName() const
00096 {
00097 return _name;
00098 }
00099
00100 void setModule(module::Module *module)
00101 {
00102 _module= module;
00103 }
00104
00105 const std::string& getTypeName() const
00106 {
00107 return _type_name;
00108 }
00109
00110 virtual bool removeLast() const
00111 {
00112 return false;
00113 }
00114
00115 const std::string& getModuleName() const;
00116 };
00117 }
00118 }
00119