FilterEncoder.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/maptools/FilterEncoder.h
22 
23  \brief A visitor that converts a TerraLib Expression to OGC Filter Expression.
24  */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_FILTERENCODER_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_FILTERENCODER_H
28 
29 // TerraLib
30 #include "Config.h"
31 #include "../dataaccess/query/QueryVisitor.h"
32 
33 // STL
34 #include <map>
35 
36 namespace te
37 {
38 // Forward declarations
39  namespace fe
40  {
41  class AbstractOp;
42  class Expression;
43  class Filter;
44  }
45 
46  namespace map
47  {
48  /*!
49  \class FilterEncoder
50 
51  \brief A visitor that converts a TerraLib Expression to OGC Filter Expression.
52 
53  \sa Visitor
54  */
56  {
57  public:
58 
59  /** @name Initializer Methods
60  * Methods related to instantiation and destruction of a Filter visitor.
61  */
62  //@{
63 
64  /*! \brief Default constructor. */
65  FilterEncoder();
66 
67  /*! \brief Virtual destructor. */
68  ~FilterEncoder();
69 
70  //@}
71 
72  /** @name Conversion Methods
73  * Methods that can be used to convert a OGC Filter Expression to a TerraLib Expression.
74  */
75  //@{
76 
77  /*!
78  \brief It converts the TerraLib Expression to a OGC Filter Expression.
79 
80  \param exp A valid Terralib expression.
81 
82  \return An ogc filter for the given expression.
83 
84  \note The caller of this method will take the ownership of the returned expression.
85  */
86  te::fe::Filter* getFilter(const te::da::Expression* exp);
87 
88  //@}
89 
90  /** @name Visitor Methods
91  * All concrete visitors must implement these methods.
92  */
93  //@{
94 
95  void visit(const te::da::Expression& visited);
96  void visit(const te::da::DataSetName& visited);
97  void visit(const te::da::FromItem& visited);
98  void visit(const te::da::Function& visited);
99  void visit(const te::da::Insert& visited);
100  void visit(const te::da::Join& visited);
101  void visit(const te::da::JoinCondition& visited);
102  void visit(const te::da::JoinConditionOn& visited);
103  void visit(const te::da::JoinConditionUsing& visited);
104  void visit(const te::da::Like& visited) override;
105  void visit(const te::da::Literal& visited);
106  void visit(const te::da::LiteralBool& visited);
107  void visit(const te::da::LiteralByteArray& visited);
108  void visit(const te::da::LiteralDateTime& visited);
109  void visit(const te::da::LiteralDouble& visited);
110  void visit(const te::da::LiteralEnvelope& visited);
111  void visit(const te::da::LiteralGeom& visited);
112  void visit(const te::da::LiteralInt16& visited);
113  void visit(const te::da::LiteralInt32& visited);
114  void visit(const te::da::LiteralInt64& visited);
115  void visit(const te::da::LiteralString& visited);
116  void visit(const te::da::PropertyName& visited);
117  void visit(const te::da::Query& visited);
118  void visit(const te::da::Select& visited);
119  void visit(const te::da::SelectExpression& visited);
120  void visit(const te::da::SubSelect& visited);
121  void visit(const te::da::In& visited);
122  void visit(const te::da::Cast& visited);
123 
124  //@}
125 
126  private:
127 
128  /*! \brief Static method to initialize the FilterEncoder. */
129  static void initialize();
130 
131  private:
132 
133  /** @name Not Allowed Methods
134  * No copy allowed.
135  */
136  //@{
137 
138  /*!
139  \brief No copy constructor allowed.
140 
141  \param rhs The other object.
142  */
143  FilterEncoder(const FilterEncoder& rhs);
144 
145  /*!
146  \brief No assignment operator allowed.
147 
148  \param rhs The other object.
149 
150  \return A reference for this.
151  */
152  FilterEncoder& operator=(const FilterEncoder& rhs);
153 
154  //@}
155 
156  private:
157 
158  te::fe::Expression* m_expression; //!< Expression used during conversion.
159  te::fe::AbstractOp* m_op; //!< Operation used during conversion.
160 
161  static std::map<std::string, std::string> sm_fnameMap; //!< A map that associates Filter Operator names to Query Functions names.
162 
163  friend class Module;
164  };
165 
166  } // end namespace map
167 } // end namespace te
168 
169 #endif // __TERRALIB_MAPTOOLS_INTERNAL_FILTERENCODER_H
An abstract class that models a source of data in a query.
Definition: FromItem.h:50
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
A class that models the name of any property of an object.
Definition: PropertyName.h:50
This singleton defines the TerraLib Map Tools module entry.
Definition: Module.h:45
This class models a bool Literal value.
Definition: LiteralBool.h:43
A visitor that converts a TerraLib Expression to OGC Filter Expression.
Definition: FilterEncoder.h:55
The Insert object can add the return of a select object.
Definition: Insert.h:50
te::fe::Expression * m_expression
Expression used during conversion.
This is an abstract class that models a query expression.
Definition: Expression.h:47
A class that models a literal for Date and Time values.
A visitor interface for the Query hierarchy.
Definition: QueryVisitor.h:47
This class models a literal value.
Definition: Literal.h:53
TerraLib.
A class that models a literal for ByteArray values.
This is an abstract class that models a Filter Encoding expression.
Definition: Expression.h:50
A condition to be used in a Join clause.
Definition: JoinCondition.h:44
It is intended to encode a character string comparison operator with pattern matching.
Definition: Like.h:43
te::fe::AbstractOp * m_op
Operation used during conversion.
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
A class that models a Function expression.
Definition: Function.h:47
A Join clause combines two FromItems.
Definition: Join.h:50
A filter is any valid predicate expression.
Definition: Filter.h:55
A class that models a literal for double values.
Definition: LiteralDouble.h:43
static std::map< std::string, std::string > sm_fnameMap
A map that associates Filter Operator names to Query Functions names.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
An abstract interface for operators.
Definition: AbstractOp.h:47
A Select can be used as a source of information in another query.
JoinConditionUsing class can be used to model a USING clause in a Join.
A class that models a literal for Envelope values.
Cast a expression function.
Definition: Cast.h:46
A class that represents the IN operator.
Definition: In.h:52
JoinConditionOn is a boolean expression and it specifies which items in a join are considered to matc...
A Select can be used as a source of information in another query.
Definition: SubSelect.h:49
A Query is independent from the data source language/dialect.
Definition: Query.h:46
A class that models a literal for Geometry values.
Definition: LiteralGeom.h:46
This class models a string Literal value.
Definition: LiteralString.h:46