OrderByItem.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/OrderByItem.h
22 
23  \brief A class that can be used in an ORDER BY clause to sort the items of a resulting query.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_ORDERBYITEM_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_ORDERBYITEM_H
28 
29 // TerraLib
30 #include "../Config.h"
31 #include "../Enums.h"
32 
33 // STL
34 #include <memory>
35 #include <string>
36 
37 namespace te
38 {
39  namespace da
40  {
41 // Forward declarations
42  class Expression;
43 
44  /*!
45  \class OrderByItem
46 
47  \brief A class that can be used in an ORDER BY clause to sort the items of a resulting query.
48 
49  The order default will be ascendent if none is informed.
50 
51  \sa OrderBy
52  */
54  {
55  public:
56 
57  /*!
58  \brief Constructor.
59 
60  \param e An expression to be used in an ORDER BY clause.
61  \param order The sort order.
62  */
63  explicit OrderByItem(const Expression& e, SortOrder order = ASC);
64 
65  /*!
66  \brief Constructor.
67 
68  \param e An expression to be used in an ORDER BY clause.
69  \param order The sort order.
70 
71  \note The OrderByItem will take the ownership of Expression.
72  */
73  explicit OrderByItem(Expression* e, SortOrder order = ASC);
74 
75  /*!
76  \brief Constructor.
77 
78  \param propertyName A property name.
79  \param order The sort order.
80  */
81  explicit OrderByItem(const std::string& propertyName, SortOrder order = ASC);
82 
83  /*! \brief Copy constructor. */
84  explicit OrderByItem(const OrderByItem& rhs);
85 
86  /*! \brief Destructor. */
87  ~OrderByItem();
88 
89  /*! Assignment operator. */
90  OrderByItem& operator=(const OrderByItem& rhs);
91 
92  /*!
93  \brief It sets the expression to sort the result of a query.
94 
95  \param e The expression to be used to sort the result of a query.
96 
97  \note The OrderByItem will take the expression ownership.
98  */
99  void setExpression(Expression* e);
100 
101  /*!
102  \brief It returns the exprsssion to be used to sort the result of a query.
103 
104  \return The exprsssion to be used to sort the result of a query.
105  */
106  Expression* getExpression() const;
107 
108  /*!
109  \brief It sets the order to be used during the sorting of a query.
110 
111  \param o The order to be used during the sorting of a query.
112  */
113  void setSortOrder(SortOrder o);
114 
115  /*!
116  \brief It returns the order of sorting: Asc or Desc.
117 
118  \return The order of sorting: Asc or Desc.
119  */
120  SortOrder getSortOrder() const;
121 
122  private:
123 
124  std::auto_ptr<Expression> m_field; //!< A valid expression.
125  SortOrder m_order; //!< Sort order.
126  };
127 
128  } // end namespace da
129 } // end namespace te
130 
131 #endif // __TERRALIB_DATAACCESS_INTERNAL_ORDERBYITEM_H
132 
std::auto_ptr< Expression > m_field
A valid expression.
Definition: OrderByItem.h:124
This is an abstract class that models a query expression.
Definition: Expression.h:47
SortOrder m_order
Sort order.
Definition: OrderByItem.h:125
URI C++ Library.
SortOrder
Sort order type: asc or desc.
Definition: Enums.h:38
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Definition: OrderByItem.h:53