00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022
00023 #include <drizzled/item/func.h>
00024 #include <drizzled/plugin.h>
00025 #include <drizzled/plugin/plugin.h>
00026
00027 #include <string>
00028 #include <vector>
00029 #include <functional>
00030
00031 #include <boost/unordered_map.hpp>
00032
00033 #include <drizzled/visibility.h>
00034
00035 namespace drizzled {
00036 namespace plugin {
00037
00041 class DRIZZLED_API Function : public Plugin
00042 {
00043 public:
00044 Function(std::string in_name) : Plugin(in_name, "Function")
00045 { }
00046 virtual Item_func* operator()(memory::Root*) const= 0;
00047
00051 static bool addPlugin(const plugin::Function *function_obj);
00052
00056 static void removePlugin(const plugin::Function *function_obj);
00057
00058 static const plugin::Function *get(const std::string &name);
00059
00060 typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap;
00061 typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> Map;
00062
00063 static const UdfMap &getMap();
00064 };
00065
00066 template<class T>
00067 class Create_function : public Function
00068 {
00069 public:
00070 Create_function(const std::string& in_name) : Function(in_name)
00071 {
00072 }
00073
00074 virtual Item_func* operator()(memory::Root* root) const
00075 {
00076 return new (*root) T();
00077 }
00078 };
00079
00080 }
00081 }
00082
00083