SQLFunctionEncoder.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib 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 Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/dataaccess/query/SQLFunctionEncoder.h
22 
23  \brief A base class for encoders of SQL function expressions.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_SQLFUNCTIONENCODER_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_SQLFUNCTIONENCODER_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // STL
33 #include <string>
34 
35 // Boost
36 #include <boost/noncopyable.hpp>
37 
38 namespace te
39 {
40  namespace da
41  {
42 // Forward declarations
43  class Function;
44  class SQLVisitor;
45 
46  /*!
47  \class SQLFunctionEncoder
48 
49  \brief A base class for encoders of SQL function expressions.
50 
51  A Function is a named procedure that performs a distinct computation.
52 
53  \sa Function, TemplateEncoder, BinaryOpEncoder, UnaryOpEncoder, FunctionEncoder
54  */
55  class TEDATAACCESSEXPORT SQLFunctionEncoder : public boost::noncopyable
56  {
57  public:
58 
59  /*!
60  \brief Constructor.
61 
62  \param name The function name.
63  */
64  SQLFunctionEncoder(const std::string& name) : m_name(name) {}
65 
66  /*! \brief Virtual Destructor. */
67  virtual ~SQLFunctionEncoder() {}
68 
69  /*!
70  \brief It encodes the function to a SQL notation.
71 
72  Subclasses must provide implementations for the many ways a function
73  can be called in a database native language. For example, the '+' operator
74  is called A + B, while the ST_Intersects function is called ST_Intersects(A, B).
75 
76  Notice that this method will visit the expression arguments of a function.
77 
78  \param f The function to be translated to a SQL notation.
79  \param buff The destination string buffer where the translation will be written.
80  \param v The SQL visitor that will be used to visit the arguments expression.
81  */
82  virtual void toSQL(const Function& f,
83  std::string& buff,
84  SQLVisitor& v) const = 0;
85 
86  protected:
87 
88  std::string m_name; //!< The alias to the function.
89  };
90 
91  } // end namespace da
92 } // end namespace te
93 
94 #endif // __TERRALIB_DATAACCESS_INTERNAL_SQLFUNCTIONENCODER_H
95 
SQLFunctionEncoder(const std::string &name)
Constructor.
A base class for encoders of SQL function expressions.
std::string m_name
The alias to the function.
URI C++ Library.
A class that models a Function expression.
Definition: Function.h:47
virtual ~SQLFunctionEncoder()
Virtual Destructor.
A visitor for building an SQL statement from a given Query hierarchy.
Definition: SQLVisitor.h:58
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97