~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/create.h

Moved the last of the libdrizzleclient calls into Protocol.

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
22
 
 
23
 
 
24
 
#include "drizzled/plugin/plugin.h"
25
 
#include "drizzled/item/func.h"
 
20
#ifndef DRIZZLED_FUNCTION_CREATE_H
 
21
#define DRIZZLED_FUNCTION_CREATE_H
 
22
 
 
23
 
 
24
#include <drizzled/item.h>
 
25
#include <drizzled/sql_list.h>
 
26
#include <drizzled/item/bin_string.h>
26
27
 
27
28
#include <string>
28
 
#include <vector>
29
29
#include <functional>
30
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 &);
 
31
class Function_builder
 
32
  : public std::unary_function<MEM_ROOT*, Item_func *>
 
33
{
 
34
  std::string name;
54
35
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
 
 
 
36
  Function_builder(std::string in_name) : name(in_name) {}
 
37
  virtual result_type operator()(argument_type session) const= 0;
 
38
  virtual ~Function_builder() {}
 
39
 
 
40
  std::string get_name() const
 
41
  {
 
42
      return name;
 
43
  }
78
44
};
79
45
 
80
46
template<class T>
81
 
class Create_function
82
 
 : public Function
 
47
class Create_function : public Function_builder
83
48
{
84
49
public:
85
 
  typedef T FunctionClass;
86
 
  Create_function(std::string in_name)
87
 
    : Function(in_name)
88
 
  { }
 
50
  typedef T Function_class;
 
51
  Create_function(std::string in_name): Function_builder(in_name) {}
89
52
  virtual result_type operator()(argument_type root) const
90
53
  {
91
 
    return new (root) FunctionClass();
 
54
    return new (root) Function_class();
92
55
  }
93
56
};
94
57
 
95
 
} /* namespace plugin */
96
 
} /* namespace drizzled */
97
 
 
98
 
 
99
 
#endif /* DRIZZLED_PLUGIN_FUNCTION_H */
 
58
 
 
59
 
 
60
#endif /* DRIZZLED_FUNCTION_CREATE_H */