~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.h

Merge default plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
27
28
#include "drizzled/function/func.h"
28
29
 
29
 
 
30
30
#include <string>
31
31
#include <vector>
32
32
#include <functional>
41
41
 * Functions in the server: AKA UDF
42
42
 */
43
43
class Function
44
 
  : public std::unary_function<MEM_ROOT*, Item_func *>
 
44
  : public Plugin,
 
45
    std::unary_function<MEM_ROOT*, Item_func *>
45
46
{
46
 
  std::string name;
47
 
  std::vector<std::string> aliases;
 
47
  Function();
 
48
  Function(const Function &);
 
49
  Function& operator=(const Function &);
48
50
public:
49
 
  Function(std::string in_name) : name(in_name) {}
50
 
  virtual result_type operator()(argument_type session) const= 0;
 
51
  Function(std::string in_name)
 
52
   : Plugin(in_name),
 
53
     std::unary_function<MEM_ROOT*, Item_func *>()
 
54
  { }
 
55
  virtual result_type operator()(argument_type root) const= 0;
51
56
  virtual ~Function() {}
52
57
 
53
 
  std::string getName() const
54
 
  {
55
 
    return name;
56
 
  }
57
 
 
58
 
  const std::vector<std::string>& getAliases() const
59
 
  {
60
 
    return aliases;
61
 
  }
62
 
 
63
 
  void addAlias(std::string alias)
64
 
  {
65
 
    aliases.push_back(alias);
66
 
  }
67
 
 
68
58
  /**
69
59
   * Add a new Function factory to the list of factories we manage.
70
60
   */
84
74
};
85
75
 
86
76
template<class T>
87
 
class Create_function : public Function
 
77
class Create_function
 
78
 : public Function
88
79
{
89
80
public:
90
 
  typedef T Function_class;
91
 
  Create_function(std::string in_name): Function(in_name) {}
92
 
  Create_function(const char *in_name): Function(in_name) {}
 
81
  typedef T FunctionClass;
 
82
  Create_function(std::string in_name)
 
83
    : Function(in_name)
 
84
  { }
93
85
  virtual result_type operator()(argument_type root) const
94
86
  {
95
 
    return new (root) Function_class();
 
87
    return new (root) FunctionClass();
96
88
  }
97
89
};
98
90
 
99
 
} /* end namespace plugin */
100
 
} /* end namespace drizzled */
 
91
} /* namespace plugin */
 
92
} /* namespace drizzled */
101
93
 
102
94
 
103
95
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */