Drizzled Public API Documentation

function.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
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 
20 #pragma once
21 
22 
23 #include <drizzled/item/func.h>
24 #include <drizzled/plugin.h>
25 #include <drizzled/plugin/plugin.h>
26 
27 #include <string>
28 #include <vector>
29 #include <functional>
30 
31 #include <boost/unordered_map.hpp>
32 
33 #include <drizzled/visibility.h>
34 
35 namespace drizzled {
36 namespace plugin {
37 
42 {
43 public:
44  Function(std::string in_name) : Plugin(in_name, "Function")
45  { }
46  virtual Item_func* operator()(memory::Root*) const= 0;
47 
51  static bool addPlugin(const plugin::Function *function_obj);
52 
56  static void removePlugin(const plugin::Function *function_obj);
57 
58  static const plugin::Function *get(const std::string &name);
59 
60  typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap;
61  typedef boost::unordered_map<std::string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> Map;
62 
63  static const UdfMap &getMap();
64 };
65 
66 template<class T>
67 class Create_function : public Function
68 {
69 public:
70  Create_function(const std::string& in_name) : Function(in_name)
71  {
72  }
73 
74  virtual Item_func* operator()(memory::Root* root) const
75  {
76  return new (*root) T();
77  }
78 };
79 
80 } /* namespace plugin */
81 } /* namespace drizzled */
82 
83 
#define DRIZZLED_API
Definition: visibility.h:62
Visibility Control Macros.