1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Padraig O'Sullivan
8
* Padraig O'Sullivan <posullivan@akibainc.com>
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.
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.
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
24
#ifndef DRIZZLED_PLUGIN_QUERY_REWRITE_H
25
#define DRIZZLED_PLUGIN_QUERY_REWRITE_H
27
#include "drizzled/atomics.h"
28
#include "drizzled/plugin/plugin.h"
31
* @file Defines the API for a QueryRewriter.
41
* Class which rewrites queries
43
class QueryRewriter : public Plugin
48
explicit QueryRewriter(std::string name_arg)
50
Plugin(name_arg, "QueryRewriter")
53
virtual ~QueryRewriter() {}
56
* Rewrite a query in the form of a std::string
58
* @param[out] to_rewrite string representing the query to rewrite
60
virtual void rewrite(std::string &to_rewrite)= 0;
62
static bool addPlugin(QueryRewriter *in_rewriter);
63
static void removePlugin(QueryRewriter *in_rewriter);
66
* Take a query to be rewritten and go through all the rewriters that are registered as plugins
67
* and let the enabled ones rewrite they query.
68
* TODO: does it make sense to have multiple rewriters?
70
* @param[out] to_rewrite string representing the query to rewrite
72
static void rewriteQuery(std::string &to_rewrite);
77
QueryRewriter(const QueryRewriter&);
78
QueryRewriter& operator=(const QueryRewriter&);
83
} /* namespace plugin */
85
} /* namespace drizzled */
87
#endif /* DRIZZLED_PLUGIN_QUERY_REWRITE_H */