~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/query_rewrite.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2010 Padraig O'Sullivan
5
 
 *
6
 
 *  Authors:
7
 
 *
8
 
 *    Padraig O'Sullivan <posullivan@akibainc.com>
9
 
 *
10
 
 *  This program is free software; you can redistribute it and/or modify
11
 
 *  it under the terms of the GNU General Public License as published by
12
 
 *  the Free Software Foundation; version 2 of the License.
13
 
 *
14
 
 *  This program is distributed in the hope that it will be useful,
15
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 *  GNU General Public License for more details.
18
 
 *
19
 
 *  You should have received a copy of the GNU General Public License
20
 
 *  along with this program; if not, write to the Free Software
21
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22
 
 */
23
 
 
24
 
#ifndef DRIZZLED_PLUGIN_QUERY_REWRITE_H
25
 
#define DRIZZLED_PLUGIN_QUERY_REWRITE_H
26
 
 
27
 
#include "drizzled/atomics.h"
28
 
#include "drizzled/plugin/plugin.h"
29
 
 
30
 
/**
31
 
 * @file Defines the API for a QueryRewriter.  
32
 
 */
33
 
 
34
 
namespace drizzled
35
 
{
36
 
 
37
 
namespace plugin
38
 
{
39
 
 
40
 
/**
41
 
 * Class which rewrites queries
42
 
 */
43
 
class QueryRewriter : public Plugin
44
 
{
45
 
 
46
 
public:
47
 
 
48
 
  explicit QueryRewriter(std::string name_arg)
49
 
    : 
50
 
      Plugin(name_arg, "QueryRewriter")
51
 
  {}
52
 
 
53
 
  virtual ~QueryRewriter() {}
54
 
 
55
 
  /**
56
 
   * Rewrite a query in the form of a std::string
57
 
   *
58
 
   * @param[in] schema the schema the current session is in
59
 
   * @param[out] to_rewrite string representing the query to rewrite
60
 
   */
61
 
  virtual void rewrite(const std::string &schema, std::string &to_rewrite)= 0; 
62
 
 
63
 
  static bool addPlugin(QueryRewriter *in_rewriter);
64
 
  static void removePlugin(QueryRewriter *in_rewriter);
65
 
 
66
 
  /**
67
 
   * Take a query to be rewritten and go through all the rewriters that are registered as plugins
68
 
   * and let the enabled ones rewrite they query.
69
 
   * TODO: does it make sense to have multiple rewriters?
70
 
   *
71
 
   * @param[in] schema the schema the current session is
72
 
   * @param[out] to_rewrite string representing the query to rewrite
73
 
   */
74
 
  static void rewriteQuery(const std::string &schema, std::string &to_rewrite);
75
 
 
76
 
private:
77
 
 
78
 
  QueryRewriter();
79
 
  QueryRewriter(const QueryRewriter&);
80
 
  QueryRewriter& operator=(const QueryRewriter&);
81
 
 
82
 
 
83
 
};
84
 
 
85
 
} /* namespace plugin */
86
 
 
87
 
} /* namespace drizzled */
88
 
 
89
 
#endif /* DRIZZLED_PLUGIN_QUERY_REWRITE_H */