~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.h

  • Committer: Monty Taylor
  • Date: 2009-09-22 23:50:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090922235012-i0a3bs91f6krqduc
Fixed multi_malloc.h include guard.
Added include guard checking script.

Show diffs side-by-side

added added

removed removed

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