~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.h

pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
macros.
Add PANDORA_DRIZZLE_BUILD to run the extra checks that drizzle needs that 
plugins would also need to run so we can just use that macro in generated
external plugin builds.
Added support to register_plugins for external plugin building.
Renamed register_plugins.py to pandora-plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
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
 
 
20
#ifndef DRIZZLED_PLUGIN_FUNCTION_H
 
21
#define DRIZZLED_PLUGIN_FUNCTION_H
 
22
 
 
23
 
 
24
#include <drizzled/item.h>
 
25
#include <drizzled/sql_list.h>
 
26
#include <drizzled/item/bin_string.h>
 
27
#include "drizzled/plugin/plugin.h"
 
28
#include "drizzled/function/func.h"
 
29
 
 
30
#include <string>
 
31
#include <vector>
 
32
#include <functional>
 
33
 
 
34
 
 
35
namespace drizzled
 
36
{
 
37
namespace plugin
 
38
{
 
39
 
 
40
/**
 
41
 * Functions in the server: AKA UDF
 
42
 */
 
43
class Function
 
44
  : public Plugin,
 
45
    public std::unary_function<MEM_ROOT*, Item_func *>
 
46
{
 
47
  Function();
 
48
  Function(const Function &);
 
49
  Function& operator=(const Function &);
 
50
public:
 
51
  Function(std::string in_name)
 
52
   : Plugin(in_name, "Function"),
 
53
     std::unary_function<MEM_ROOT*, Item_func *>()
 
54
  { }
 
55
  virtual result_type operator()(argument_type root) const= 0;
 
56
  virtual ~Function() {}
 
57
 
 
58
  /**
 
59
   * Add a new Function factory to the list of factories we manage.
 
60
   */
 
61
  static bool addPlugin(const plugin::Function *function_obj);
 
62
 
 
63
  /**
 
64
   * Remove a Function factory from the list of factory we manage.
 
65
   */
 
66
  static void removePlugin(const plugin::Function *function_obj);
 
67
 
 
68
  /**
 
69
   * Accept a new connection (Protocol object) on one of the configured
 
70
   * listener interfaces.
 
71
   */
 
72
  static const plugin::Function *get(const char *name, size_t len=0);
 
73
 
 
74
};
 
75
 
 
76
template<class T>
 
77
class Create_function
 
78
 : public Function
 
79
{
 
80
public:
 
81
  typedef T FunctionClass;
 
82
  Create_function(std::string in_name)
 
83
    : Function(in_name)
 
84
  { }
 
85
  virtual result_type operator()(argument_type root) const
 
86
  {
 
87
    return new (root) FunctionClass();
 
88
  }
 
89
};
 
90
 
 
91
} /* namespace plugin */
 
92
} /* namespace drizzled */
 
93
 
 
94
 
 
95
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */