~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/gearman_udf/gman_do.h

  • Committer: Brian Aker
  • Date: 2009-05-11 23:55:31 UTC
  • mfrom: (971.3.38 eday-dev)
  • Revision ID: brian@gaz-20090511235531-j6n8i97wg2tyfg51
Merge of Eric's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2009 Sun Microsystems
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
#include <drizzled/server_includes.h>
 
17
#include <drizzled/item/func.h>
 
18
#include <drizzled/function/str/strfunc.h>
 
19
 
 
20
#include <libgearman/gearman.h>
 
21
 
 
22
class Item_func_gman_do :public Item_str_func
 
23
{
 
24
protected:
 
25
  typedef enum
 
26
  {
 
27
    GMAN_DO_OPTIONS_NONE=       0,
 
28
    GMAN_DO_OPTIONS_HIGH=       (1 << 0),
 
29
    GMAN_DO_OPTIONS_LOW=        (1 << 1),
 
30
    GMAN_DO_OPTIONS_BACKGROUND= (1 << 2),
 
31
    GMAN_DO_OPTIONS_CLIENT=     (1 << 3)
 
32
  } gman_do_options_t;
 
33
 
 
34
private:
 
35
  gman_do_options_t options;
 
36
  gearman_client_st client;
 
37
  String buffer;
 
38
 
 
39
public:
 
40
  Item_func_gman_do():
 
41
    Item_str_func(),
 
42
    options(GMAN_DO_OPTIONS_NONE) {}
 
43
  Item_func_gman_do(gman_do_options_t options_arg):
 
44
    Item_str_func(),
 
45
    options(options_arg) {}
 
46
  ~Item_func_gman_do();
 
47
  void fix_length_and_dec() { max_length=10; }
 
48
  virtual const char *func_name() const{ return "gman_do"; }
 
49
  String *val_str(String *);
 
50
  void *realloc(size_t size);
 
51
};
 
52
 
 
53
class Item_func_gman_do_high :public Item_func_gman_do
 
54
{
 
55
public:
 
56
  Item_func_gman_do_high():
 
57
    Item_func_gman_do(GMAN_DO_OPTIONS_HIGH) {}
 
58
  const char *func_name() const{ return "gman_do_high"; }
 
59
};
 
60
 
 
61
class Item_func_gman_do_low :public Item_func_gman_do
 
62
{
 
63
public:
 
64
  Item_func_gman_do_low():
 
65
    Item_func_gman_do(GMAN_DO_OPTIONS_LOW) {}
 
66
  const char *func_name() const{ return "gman_do_low"; }
 
67
};
 
68
 
 
69
class Item_func_gman_do_background :public Item_func_gman_do
 
70
{
 
71
public:
 
72
  Item_func_gman_do_background():
 
73
    Item_func_gman_do(GMAN_DO_OPTIONS_BACKGROUND) {}
 
74
  const char *func_name() const{ return "gman_do_background"; }
 
75
};
 
76
 
 
77
class Item_func_gman_do_high_background :public Item_func_gman_do
 
78
{
 
79
public:
 
80
  Item_func_gman_do_high_background():
 
81
    Item_func_gman_do((gman_do_options_t)(GMAN_DO_OPTIONS_HIGH |
 
82
                                          GMAN_DO_OPTIONS_BACKGROUND)) {}
 
83
  const char *func_name() const{ return "gman_do_high_background"; }
 
84
};
 
85
 
 
86
class Item_func_gman_do_low_background :public Item_func_gman_do
 
87
{
 
88
public:
 
89
  Item_func_gman_do_low_background():
 
90
    Item_func_gman_do((gman_do_options_t)(GMAN_DO_OPTIONS_LOW |
 
91
                                         GMAN_DO_OPTIONS_BACKGROUND)) {}
 
92
  const char *func_name() const{ return "gman_do_low_background"; }
 
93
};