1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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.
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.
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
20
#ifndef DRIZZLED_PLUGIN_FUNCTION_H
21
#define DRIZZLED_PLUGIN_FUNCTION_H
24
#include <drizzled/item/func.h>
25
#include <drizzled/plugin.h>
26
#include <drizzled/plugin/plugin.h>
32
#include <boost/unordered_map.hpp>
34
#include <drizzled/visibility.h>
48
struct insensitive_hash;
49
struct insensitive_equal_to;
56
* Functions in the server: AKA UDF
58
class DRIZZLED_API Function
60
public std::unary_function<memory::Root*, Item_func *>
63
Function(const Function &);
64
Function& operator=(const Function &);
66
Function(std::string in_name)
67
: Plugin(in_name, "Function"),
68
std::unary_function<memory::Root*, Item_func *>()
70
virtual result_type operator()(argument_type root) const= 0;
71
virtual ~Function() {}
74
* Add a new Function factory to the list of factories we manage.
76
static bool addPlugin(const plugin::Function *function_obj);
79
* Remove a Function factory from the list of factory we manage.
81
static void removePlugin(const plugin::Function *function_obj);
83
static const plugin::Function *get(const char *name, size_t len=0);
85
typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap;
86
typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> Map;
88
static const UdfMap &getMap();
96
typedef T FunctionClass;
97
Create_function(std::string in_name)
100
virtual result_type operator()(argument_type root) const
102
return new (root) FunctionClass();
106
} /* namespace plugin */
107
} /* namespace drizzled */
110
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */