942.1.12
by Monty Taylor
Converted udf_func into a factory. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
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 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
20 |
#pragma once
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
21 |
|
22 |
||
2148.7.12
by Brian Aker
Merge in header fixes. |
23 |
#include <drizzled/item/func.h> |
24 |
#include <drizzled/plugin.h> |
|
25 |
#include <drizzled/plugin/plugin.h> |
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
26 |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
27 |
#include <string> |
971.1.23
by Monty Taylor
Add generalized registry to be used for case-insensitive mappings. |
28 |
#include <vector> |
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
29 |
#include <functional> |
30 |
||
2154.2.4
by Brian Aker
This fixes 716459 |
31 |
#include <boost/unordered_map.hpp> |
32 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
33 |
#include <drizzled/visibility.h> |
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
34 |
|
2252.1.22
by Olaf van der Spek
Common fwd |
35 |
namespace drizzled { |
1253.1.3
by Monty Taylor
MEM_ROOT == memory::Root |
36 |
|
2154.2.4
by Brian Aker
This fixes 716459 |
37 |
namespace util |
38 |
{
|
|
39 |
struct insensitive_hash; |
|
40 |
struct insensitive_equal_to; |
|
41 |
}
|
|
42 |
||
2252.1.22
by Olaf van der Spek
Common fwd |
43 |
namespace plugin { |
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
44 |
|
45 |
/**
|
|
46 |
* Functions in the server: AKA UDF
|
|
47 |
*/
|
|
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
48 |
class DRIZZLED_API Function |
1130.2.16
by Monty Taylor
Cleaned up the constructor initializer lists per Brian. |
49 |
: public Plugin, |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
50 |
public std::unary_function<memory::Root*, Item_func *> |
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
51 |
{
|
1130.2.16
by Monty Taylor
Cleaned up the constructor initializer lists per Brian. |
52 |
Function(); |
53 |
Function(const Function &); |
|
54 |
Function& operator=(const Function &); |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
55 |
public: |
1130.2.1
by Monty Taylor
Introduced plugin::Plugin class. Made Function use it. |
56 |
Function(std::string in_name) |
1192.2.5
by Monty Taylor
Replaced overridable virtual methods with passing name to constructor. Now individual plugins will not be allowed to set their own plugin type name. :) |
57 |
: Plugin(in_name, "Function"), |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
58 |
std::unary_function<memory::Root*, Item_func *>() |
1130.2.1
by Monty Taylor
Introduced plugin::Plugin class. Made Function use it. |
59 |
{ } |
60 |
virtual result_type operator()(argument_type root) const= 0; |
|
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
61 |
virtual ~Function() {} |
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
62 |
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
63 |
/**
|
64 |
* Add a new Function factory to the list of factories we manage.
|
|
65 |
*/
|
|
1130.1.19
by Monty Taylor
Added error reporting to plugin registration. |
66 |
static bool addPlugin(const plugin::Function *function_obj); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
67 |
|
68 |
/**
|
|
69 |
* Remove a Function factory from the list of factory we manage.
|
|
70 |
*/
|
|
1130.1.18
by Monty Taylor
Changed ::add() and ::remove() to ::addPlugin() and ::removePlugin() so that |
71 |
static void removePlugin(const plugin::Function *function_obj); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
72 |
|
2198.6.15
by Brian Aker
Remove caller convert to std::string (ie we were going back and forth in |
73 |
static const plugin::Function *get(const std::string &name); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
74 |
|
1751.3.2
by Brian Aker
Adding in data dictionary table to list out functions. |
75 |
typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap; |
2060
by Brian Aker
Added native functions into the function table. |
76 |
typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> Map; |
1751.3.2
by Brian Aker
Adding in data dictionary table to list out functions. |
77 |
|
78 |
static const UdfMap &getMap(); |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
79 |
};
|
80 |
||
81 |
template<class T> |
|
1130.2.1
by Monty Taylor
Introduced plugin::Plugin class. Made Function use it. |
82 |
class Create_function |
83 |
: public Function |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
84 |
{
|
85 |
public: |
|
1130.2.1
by Monty Taylor
Introduced plugin::Plugin class. Made Function use it. |
86 |
typedef T FunctionClass; |
87 |
Create_function(std::string in_name) |
|
88 |
: Function(in_name) |
|
89 |
{ } |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
90 |
virtual result_type operator()(argument_type root) const |
91 |
{
|
|
1130.2.1
by Monty Taylor
Introduced plugin::Plugin class. Made Function use it. |
92 |
return new (root) FunctionClass(); |
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
93 |
}
|
94 |
};
|
|
95 |
||
1130.2.6
by Monty Taylor
Merged in latest plugin-slot-reorg. |
96 |
} /* namespace plugin */ |
97 |
} /* namespace drizzled */ |
|
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
98 |
|
99 |