Drizzled Public API Documentation

plugin.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 #include <boost/program_options.hpp>
23 #include <boost/filesystem.hpp>
24 
25 #include <drizzled/module/manifest.h>
26 #include <drizzled/module/module.h>
27 #include <drizzled/plugin/version.h>
28 #include <drizzled/module/context.h>
29 #include <drizzled/definitions.h>
30 
31 #include <drizzled/lex_string.h>
32 #include <drizzled/sys_var.h>
33 
34 #include <drizzled/visibility.h>
35 
36 namespace drizzled {
37 
38 /*************************************************************************
39  Plugin API. Common for all plugin types.
40 */
41 
42 extern boost::filesystem::path plugin_dir;
43 
44 /*
45  Macros for beginning and ending plugin declarations. Between
46  DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
47  be a module::Manifest for each plugin to be declared.
48 */
49 
50 
51 #define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
52 #define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
53 #define DRIZZLE_DECLARE_PLUGIN \
54  DRIZZLED_API ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)=
55 
56 
57 #define DRIZZLE_DECLARE_PLUGIN_END
58 #define DRIZZLE_PLUGIN(init,system,options) \
59  DRIZZLE_DECLARE_PLUGIN \
60  { \
61  DRIZZLE_VERSION_ID, \
62  STRINGIFY_ARG(PANDORA_MODULE_NAME), \
63  STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
64  STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
65  STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
66  PANDORA_MODULE_LICENSE, \
67  init, \
68  STRINGIFY_ARG(PANDORA_MODULE_DEPENDENCIES), \
69  options \
70  }
71 
72 
73 /*
74  declarations for server variables and command line options
75 */
76 
77 
78 #define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
79 #define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */
80 #define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */
81 
82 struct drizzle_sys_var;
83 struct drizzle_value;
84 
85 /*
86  SYNOPSIS
87  (*var_check_func)()
88  session thread handle
89  var dynamic variable being altered
90  save pointer to temporary storage
91  value user provided value
92  RETURN
93  0 user provided value is OK and the update func may be called.
94  any other value indicates error.
95 
96  This function should parse the user provided value and store in the
97  provided temporary storage any data as required by the update func.
98  There is sufficient space in the temporary storage to store a double.
99  Note that the update func may not be called if any other error occurs
100  so any memory allocated should be thread-local so that it may be freed
101  automatically at the end of the statement.
102 */
103 
104 typedef int (*var_check_func)(Session*, drizzle_sys_var*, void* save, drizzle_value*);
105 
106 /*
107  SYNOPSIS
108  (*var_update_func)()
109  session thread handle
110  var dynamic variable being altered
111  var_ptr pointer to dynamic variable
112  save pointer to temporary storage
113  RETURN
114  NONE
115 
116  This function should use the validated value stored in the temporary store
117  and persist it in the provided pointer to the dynamic variable.
118  For example, strings may require memory to be allocated.
119 */
120 typedef void (*var_update_func)(Session*, drizzle_sys_var*, void*, const void* save);
121 
122 
123 
124 /*
125  skeleton of a plugin variable - portion of structure common to all.
126 */
127 struct drizzle_sys_var
128 {
129 };
130 
131 void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
132 
134 {
135  int (*value_type)(drizzle_value *);
136  const char *(*val_str)(drizzle_value *, char *buffer, int *length);
137  int (*val_real)(drizzle_value *, double *realbuf);
138  int (*val_int)(drizzle_value *, int64_t *intbuf);
139 };
140 
141 
142 /*************************************************************************
143  Miscellaneous functions for plugin implementors
144 */
145 
146 extern bool plugin_init(module::Registry&, boost::program_options::options_description &long_options);
147 extern bool plugin_finalize(module::Registry&);
148 extern void plugin_startup_window(module::Registry&, drizzled::Session&);
149 extern void my_print_help_inc_plugins(option* options);
150 extern void plugin_sessionvar_init(Session*);
151 extern void plugin_sessionvar_cleanup(Session*);
152 
153 DRIZZLED_API int64_t session_test_options(const Session*, int64_t test_options);
154 void compose_plugin_add(const std::vector<std::string>& options);
155 void compose_plugin_remove(const std::vector<std::string>& options);
156 void notify_plugin_load(const std::string& in_plugin_load);
157 
158 
171 DRIZZLED_API int tmpfile(const char *prefix);
172 
173 } /* namespace drizzled */
TODO: Rename this file - func.h is stupid.
#define DRIZZLED_API
Definition: visibility.h:62
Visibility Control Macros.
DRIZZLED_API int tmpfile(const char *prefix)
Definition: session.cc:121
void my_print_help_inc_plugins(option *main_options)
Definition: loader.cc:522