QueryEncoder.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/QueryEncoder.h
22 
23  \brief A visitor that converts a OGC Filter Expression to TerraLib Expression.
24  */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_QUERYENCODER_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_QUERYENCODER_H
28 
29 // TerraLib
30 #include "Config.h"
31 #include "../fe/Visitor.h"
32 
33 // STL
34 #include <map>
35 
36 namespace te
37 {
38 // Forward declarations
39  namespace da
40  {
41  class Expression;
42  }
43 
44  namespace map
45  {
46  /*!
47  \class QueryEncoder
48 
49  \brief A visitor that converts a OGC Filter Expression to TerraLib Expression.
50 
51  \sa Visitor
52  */
54  {
55  public:
56 
57  /** @name Initializer Methods
58  * Methods related to instantiation and destruction of a Filter visitor.
59  */
60  //@{
61 
62  /*! \brief Default constructor. */
63  QueryEncoder();
64 
65  /*! \brief Virtual destructor. */
66  ~QueryEncoder();
67 
68  //@}
69 
70  /** @name Conversion Methods
71  * Methods that can be used to convert a OGC Filter Expression to a TerraLib Expression.
72  */
73  //@{
74 
75  /*!
76  \brief It converts the OGC Filter Expression to a TerraLib Expression.
77 
78  \param f A valid filter expression.
79 
80  \return An equivalent TerraLib expression for the given filter.
81 
82  \note The caller of this method will take the ownership of the returned expression.
83  */
84  te::da::Expression* getExpression(const te::fe::Filter* f);
85 
86  //@}
87 
88  /** @name Visitor Methods
89  * All concrete visitors must implement these methods.
90  */
91  //@{
92 
93  void visit(const te::fe::AbstractOp& visited);
94  void visit(const te::fe::SpatialOp& visited);
95  void visit(const te::fe::ComparisonOp& visited);
96  void visit(const te::fe::LogicOp& visited);
97  void visit(const te::fe::BBOXOp& visited);
98  void visit(const te::fe::BinaryComparisonOp& visited);
99  void visit(const te::fe::BinaryLogicOp& visited);
100  void visit(const te::fe::BinarySpatialOp& visited);
101  void visit(const te::fe::DistanceBuffer& visited);
102  void visit(const te::fe::PropertyIsBetween& visited);
103  void visit(const te::fe::PropertyIsLike& visited);
104  void visit(const te::fe::PropertyIsNull& visited);
105  void visit(const te::fe::UnaryLogicOp& visited);
106  void visit(const te::fe::Expression& visited);
107  void visit(const te::fe::BinaryOperator& visited);
108  void visit(const te::fe::Function& visited);
109  void visit(const te::fe::Literal& visited);
110  void visit(const te::fe::PropertyName& visited);
111 
112  //@}
113 
114  private:
115 
116  /*! \brief Static method to initialize the QueryEncoder. */
117  static void initialize();
118 
119  private:
120 
121  /** @name Not Allowed Methods
122  * No copy allowed.
123  */
124  //@{
125 
126  /*!
127  \brief No copy constructor allowed.
128 
129  \param rhs The other object.
130  */
131  QueryEncoder(const QueryEncoder& rhs);
132 
133  /*!
134  \brief No assignment operator allowed.
135 
136  \param rhs The other object.
137 
138  \return A reference for this.
139  */
140  QueryEncoder& operator=(const QueryEncoder& rhs);
141 
142  //@}
143 
144  private:
145 
146  te::da::Expression* m_expression; //!< Expression used during conversion.
147  static std::map<std::string, std::string> sm_fnameMap; //!< A map that associates Filter Operator names to Query Functions names.
148 
149  friend class Module;
150  };
151 
152  } // end namespace map
153 } // end namespace te
154 
155 #endif // __TERRALIB_MAPTOOLS_INTERNAL_QUERYENCODER_H
Distance buffer operator.
A convenient and more compact way of encoding the very common bounding box constraint based on an env...
Definition: BBOXOp.h:71
A spatial operator determines whether its geometric arguments satisfy the stated spatial relationship...
Definition: SpatialOp.h:49
This singleton defines the TerraLib Map Tools module entry.
Definition: Module.h:41
static std::map< std::string, std::string > sm_fnameMap
A map that associates Filter Operator names to Query Functions names.
Definition: QueryEncoder.h:147
A class for binary spatial operators.
The PropertyIsBetween element is defined as a compact way of encoding a range check.
A comparison operator is used to form expressions that evaluate the mathematical comparison between t...
Definition: ComparisonOp.h:49
A logical operator that can be used to combine one conditional expressions.
Definition: UnaryLogicOp.h:46
The PropertyIsNull class encodes an operator that checks to see if the value of its content is NULL...
This is an abstract class that models a query expression.
Definition: Expression.h:47
A function is a named procedure that performs a distinct computation.
Definition: Function.h:54
It is intended to encode a character string comparison operator with pattern matching.
This class can be used to represent binary operation expressions.
This class is used to encode the name of any property of an object.
Definition: PropertyName.h:54
URI C++ Library.
This is an abstract class that models a Filter Encoding expression.
Definition: Expression.h:50
A visitor that converts a OGC Filter Expression to TerraLib Expression.
Definition: QueryEncoder.h:53
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
A filter is any valid predicate expression.
Definition: Filter.h:52
An abstract interface for operators.
Definition: AbstractOp.h:47
A class for binary comparison operators.
This class can be used to represent literal values.
Definition: Literal.h:56
A logical operator can be used to combine one or more conditional expressions.
Definition: LogicOp.h:52
A logical operator can be used to combine two or more conditional expressions.
Definition: BinaryLogicOp.h:58
A visitor interface for a Filter expression.
Definition: Visitor.h:47
te::da::Expression * m_expression
Expression used during conversion.
Definition: QueryEncoder.h:146