~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.h

Merge Revision revid:vasil.dimov@oracle.com-20100514133832-unwj9x313jfvn5ev from MySQL InnoDB

Original revid:vasil.dimov@oracle.com-20100514133832-unwj9x313jfvn5ev

Original Authors: Vasil Dimov <vasil.dimov@oracle.com>
Original commit message:
Add a debug assertion to make it clear that we expect
to own the kernel mutex in fill_trx_row().

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/plugin/plugin.h"
 
25
#include "drizzled/item/func.h"
 
26
 
 
27
#include <string>
 
28
#include <vector>
 
29
#include <functional>
 
30
 
 
31
namespace drizzled
 
32
{
 
33
 
 
34
class Item_func;
 
35
 
 
36
namespace memory
 
37
{
 
38
  class Root;
 
39
}
 
40
 
 
41
namespace plugin
 
42
{
 
43
 
 
44
/**
 
45
 * Functions in the server: AKA UDF
 
46
 */
 
47
class Function
 
48
  : public Plugin,
 
49
    public std::unary_function<memory::Root*, Item_func *>
 
50
{
 
51
  Function();
 
52
  Function(const Function &);
 
53
  Function& operator=(const Function &);
 
54
public:
 
55
  Function(std::string in_name)
 
56
   : Plugin(in_name, "Function"),
 
57
     std::unary_function<memory::Root*, Item_func *>()
 
58
  { }
 
59
  virtual result_type operator()(argument_type root) const= 0;
 
60
  virtual ~Function() {}
 
61
 
 
62
  /**
 
63
   * Add a new Function factory to the list of factories we manage.
 
64
   */
 
65
  static bool addPlugin(const plugin::Function *function_obj);
 
66
 
 
67
  /**
 
68
   * Remove a Function factory from the list of factory we manage.
 
69
   */
 
70
  static void removePlugin(const plugin::Function *function_obj);
 
71
 
 
72
  /**
 
73
   * Accept a new connection (Protocol object) on one of the configured
 
74
   * listener interfaces.
 
75
   */
 
76
  static const plugin::Function *get(const char *name, size_t len=0);
 
77
 
 
78
  typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap;
 
79
 
 
80
  static const UdfMap &getMap();
 
81
};
 
82
 
 
83
template<class T>
 
84
class Create_function
 
85
 : public Function
 
86
{
 
87
public:
 
88
  typedef T FunctionClass;
 
89
  Create_function(std::string in_name)
 
90
    : Function(in_name)
 
91
  { }
 
92
  virtual result_type operator()(argument_type root) const
 
93
  {
 
94
    return new (root) FunctionClass();
 
95
  }
 
96
};
 
97
 
 
98
} /* namespace plugin */
 
99
} /* namespace drizzled */
 
100
 
 
101
 
 
102
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */