~drizzle-trunk/drizzle/development

942.1.12 by Monty Taylor
Converted udf_func into a factory.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
942.1.12 by Monty Taylor
Converted udf_func into a factory.
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
942.1.12 by Monty Taylor
Converted udf_func into a factory.
21
22
2148.7.12 by Brian Aker
Merge in header fixes.
23
#include <drizzled/item/func.h>
24
#include <drizzled/plugin.h>
25
#include <drizzled/plugin/plugin.h>
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
26
942.1.12 by Monty Taylor
Converted udf_func into a factory.
27
#include <string>
971.1.23 by Monty Taylor
Add generalized registry to be used for case-insensitive mappings.
28
#include <vector>
942.1.12 by Monty Taylor
Converted udf_func into a factory.
29
#include <functional>
30
2154.2.4 by Brian Aker
This fixes 716459
31
#include <boost/unordered_map.hpp>
32
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
33
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
34
2252.1.22 by Olaf van der Spek
Common fwd
35
namespace drizzled {
36
namespace plugin {
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
37
38
/**
39
 * Functions in the server: AKA UDF
40
 */
2318.6.75 by Olaf van der Spek
Refactor
41
class DRIZZLED_API Function : public Plugin
942.1.12 by Monty Taylor
Converted udf_func into a factory.
42
{
43
public:
2318.6.75 by Olaf van der Spek
Refactor
44
  Function(std::string in_name) : Plugin(in_name, "Function")
1130.2.1 by Monty Taylor
Introduced plugin::Plugin class. Made Function use it.
45
  { }
2318.6.75 by Olaf van der Spek
Refactor
46
  virtual Item_func* operator()(memory::Root*) const= 0;
942.1.12 by Monty Taylor
Converted udf_func into a factory.
47
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
48
  /**
49
   * Add a new Function factory to the list of factories we manage.
50
   */
1130.1.19 by Monty Taylor
Added error reporting to plugin registration.
51
  static bool addPlugin(const plugin::Function *function_obj);
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
52
53
  /**
54
   * Remove a Function factory from the list of factory we manage.
55
   */
1130.1.18 by Monty Taylor
Changed ::add() and ::remove() to ::addPlugin() and ::removePlugin() so that
56
  static void removePlugin(const plugin::Function *function_obj);
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
57
2198.6.15 by Brian Aker
Remove caller convert to std::string (ie we were going back and forth in
58
  static const plugin::Function *get(const std::string &name);
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
59
1751.3.2 by Brian Aker
Adding in data dictionary table to list out functions.
60
  typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap;
2060 by Brian Aker
Added native functions into the function table.
61
  typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> Map;
1751.3.2 by Brian Aker
Adding in data dictionary table to list out functions.
62
63
  static const UdfMap &getMap();
942.1.12 by Monty Taylor
Converted udf_func into a factory.
64
};
65
66
template<class T>
2318.6.76 by Olaf van der Spek
Refactor
67
class Create_function : public Function
942.1.12 by Monty Taylor
Converted udf_func into a factory.
68
{
69
public:
2318.6.76 by Olaf van der Spek
Refactor
70
  Create_function(const std::string& in_name) : Function(in_name)
71
  { 
72
  }
73
2318.6.75 by Olaf van der Spek
Refactor
74
  virtual Item_func* operator()(memory::Root* root) const
942.1.12 by Monty Taylor
Converted udf_func into a factory.
75
  {
2318.6.76 by Olaf van der Spek
Refactor
76
    return new (*root) T();
942.1.12 by Monty Taylor
Converted udf_func into a factory.
77
  }
78
};
79
1130.2.6 by Monty Taylor
Merged in latest plugin-slot-reorg.
80
} /* namespace plugin */
81
} /* namespace drizzled */
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
82
83