SQLDialect.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/SQLDialect.h
22 
23  \brief It represents the SQL query dialect accepted by a given data source.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_SQLDIALECT_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_SQLDIALECT_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // STL
33 #include <map>
34 #include <string>
35 
36 // Boost
37 #include <boost/noncopyable.hpp>
38 
39 namespace te
40 {
41  namespace da
42  {
43 // Forward declarations
44  class SQLFunctionEncoder;
45 
46  /*!
47  \class SQLDialect
48 
49  \brief It represents the SQL query dialect accepted by a given data source.
50 
51  This class is target for the portability of TerraLib...
52 
53  \ingroup dataaccess
54  */
55  class TEDATAACCESSEXPORT SQLDialect : public boost::noncopyable
56  {
57  public:
58 
59  /*! \brief Default constructor. */
61 
62  /*! \brief Destructor. */
63  ~SQLDialect();
64 
65  /*!
66  \brief It adds a new encoder for a given function.
67 
68  \param funcName The function name.
69  \param encoder The SQL dialect encoder for the given function.
70 
71  \exception Exception It thorws an exception if a given function is already registered.
72 
73  \note The SQLDialect will take the ownership of the given encoder.
74  */
75  void insert(const std::string& funcName,
76  SQLFunctionEncoder* encoder);
77 
78  /*!
79  \brief It searches for an encoder for the given function.
80 
81  \param funcName The function name.
82 
83  \return An encoder or NULL if none is found.
84  */
85  const SQLFunctionEncoder* find(const std::string& funcName) const;
86 
87  /*!
88  \brief It gets the all registered names from registed functions.
89 
90  \return A vector with TerraLib general name for SQL functions.
91  */
92  std::vector<std::string> getRegisteredNames() const;
93 
94  private:
95 
96  std::map<std::string, SQLFunctionEncoder*> m_regFunctions; //!< A map from the TerraLib general name to a given SQL formatter.
97  };
98 
99  } // end namespace da
100 } // end namespace te
101 
102 #endif // __TERRALIB_DATAACCESS_INTERNAL_SQLDIALECT_H
103 
A base class for encoders of SQL function expressions.
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:55
SQLDialect()
Default constructor.
Definition: SQLDialect.h:60
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
URI C++ Library.
std::map< std::string, SQLFunctionEncoder * > m_regFunctions
A map from the TerraLib general name to a given SQL formatter.
Definition: SQLDialect.h:96
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97