~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/create.h

  • Committer: Monty Taylor
  • Date: 2009-04-20 14:42:34 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090420144234-4k1x60fiag2l1y0n
Ported InnoDB to register_plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_PLUGIN_FUNCTION_H
21
 
#define DRIZZLED_PLUGIN_FUNCTION_H
 
20
#ifndef DRIZZLED_FUNCTION_CREATE_H
 
21
#define DRIZZLED_FUNCTION_CREATE_H
22
22
 
23
23
 
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"
29
27
 
30
28
#include <string>
31
29
#include <vector>
32
30
#include <functional>
33
31
 
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 &);
 
32
class Function_builder
 
33
  : public std::unary_function<MEM_ROOT*, Item_func *>
 
34
{
 
35
  std::string name;
 
36
  std::vector<std::string> aliases;
50
37
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
 
 
 
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() {}
 
42
 
 
43
  std::string getName() const
 
44
  {
 
45
    return name;
 
46
  }
 
47
 
 
48
  const std::vector<std::string>& getAliases() const
 
49
  {
 
50
    return aliases;
 
51
  }
 
52
 
 
53
  void addAlias(std::string alias)
 
54
  {
 
55
    aliases.push_back(alias);
 
56
  }
74
57
};
75
58
 
76
59
template<class T>
77
 
class Create_function
78
 
 : public Function
 
60
class Create_function : public Function_builder
79
61
{
80
62
public:
81
 
  typedef T FunctionClass;
82
 
  Create_function(std::string in_name)
83
 
    : Function(in_name)
84
 
  { }
 
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
86
67
  {
87
 
    return new (root) FunctionClass();
 
68
    return new (root) Function_class();
88
69
  }
89
70
};
90
71
 
91
 
} /* namespace plugin */
92
 
} /* namespace drizzled */
93
 
 
94
 
 
95
 
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */
 
72
 
 
73
 
 
74
#endif /* DRIZZLED_FUNCTION_CREATE_H */