17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_PLUGIN_FUNCTION_H
21
#define DRIZZLED_PLUGIN_FUNCTION_H
20
#ifndef DRIZZLED_FUNCTION_CREATE_H
21
#define DRIZZLED_FUNCTION_CREATE_H
24
24
#include <drizzled/item.h>
25
25
#include <drizzled/sql_list.h>
26
26
#include <drizzled/item/bin_string.h>
27
#include "drizzled/plugin/plugin.h"
28
#include "drizzled/function/func.h"
32
30
#include <functional>
41
* Functions in the server: AKA UDF
45
public std::unary_function<MEM_ROOT*, Item_func *>
48
Function(const Function &);
49
Function& operator=(const Function &);
32
class Function_builder
33
: public std::unary_function<MEM_ROOT*, Item_func *>
36
std::vector<std::string> aliases;
51
Function(std::string in_name)
52
: Plugin(in_name, "Function"),
53
std::unary_function<MEM_ROOT*, Item_func *>()
55
virtual result_type operator()(argument_type root) const= 0;
56
virtual ~Function() {}
59
* Add a new Function factory to the list of factories we manage.
61
static bool addPlugin(const plugin::Function *function_obj);
64
* Remove a Function factory from the list of factory we manage.
66
static void removePlugin(const plugin::Function *function_obj);
69
* Accept a new connection (Protocol object) on one of the configured
70
* listener interfaces.
72
static const plugin::Function *get(const char *name, size_t len=0);
38
Function_builder(std::string in_name) : name(in_name) {}
39
Function_builder(const char *in_name) : name(in_name) {}
40
virtual result_type operator()(argument_type session) const= 0;
41
virtual ~Function_builder() {}
43
std::string getName() const
48
const std::vector<std::string>& getAliases() const
53
void addAlias(std::string alias)
55
aliases.push_back(alias);
60
class Create_function : public Function_builder
81
typedef T FunctionClass;
82
Create_function(std::string in_name)
63
typedef T Function_class;
64
Create_function(std::string in_name): Function_builder(in_name) {}
65
Create_function(const char *in_name): Function_builder(in_name) {}
85
66
virtual result_type operator()(argument_type root) const
87
return new (root) FunctionClass();
68
return new (root) Function_class();
91
} /* namespace plugin */
92
} /* namespace drizzled */
95
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */
74
#endif /* DRIZZLED_FUNCTION_CREATE_H */