All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OrderByItem.cpp
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.cpp
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 // TerraLib
27 #include "Expression.h"
28 #include "OrderByItem.h"
29 #include "PropertyName.h"
30 
32  : m_field(e.clone()),
33  m_order(order)
34 {
35 }
36 
38  : m_field(e),
39  m_order(order)
40 {
41 }
42 
43 te::da::OrderByItem::OrderByItem(const std::string& propertyName, SortOrder order)
44  : m_field(new PropertyName(propertyName)),
45  m_order(order)
46 {
47 }
48 
50  : m_field(0),
51  m_order(rhs.m_order)
52 {
53  m_field.reset(rhs.m_field.get() ? rhs.m_field->clone() : 0);
54 }
55 
57 {
58 }
59 
61 {
62  if(this != &rhs)
63  {
64  m_field.reset(rhs.m_field.get() ? m_field->clone() : 0);
65  m_order = rhs.m_order;
66  }
67 
68  return *this;
69 }
70 
72 {
73  m_field.reset(e);
74 }
75 
77 {
78  return m_field.get();
79 }
80 
82 {
83  m_order = o;
84 }
85 
87 {
88  return m_order;
89 }
90 
~OrderByItem()
Destructor.
Definition: OrderByItem.cpp:56
OrderByItem(const Expression &e, SortOrder order=ASC)
Constructor.
Definition: OrderByItem.cpp:31
A class that models the name of any property of an object.
std::auto_ptr< Expression > m_field
A valid expression.
Definition: OrderByItem.h:124
A class that models the name of any property of an object.
Definition: PropertyName.h:50
This is an abstract class that models a query expression.
Definition: Expression.h:47
SortOrder getSortOrder() const
It returns the order of sorting: Asc or Desc.
Definition: OrderByItem.cpp:86
SortOrder m_order
Sort order.
Definition: OrderByItem.h:125
void setSortOrder(SortOrder o)
It sets the order to be used during the sorting of a query.
Definition: OrderByItem.cpp:81
OrderByItem & operator=(const OrderByItem &rhs)
Definition: OrderByItem.cpp:60
This is an abstract class that models a query expression.
SortOrder
Sort order type: asc or desc.
Definition: Enums.h:38
void setExpression(Expression *e)
It sets the expression to sort the result of a query.
Definition: OrderByItem.cpp:71
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Definition: OrderByItem.h:53
Expression * getExpression() const
It returns the exprsssion to be used to sort the result of a query.
Definition: OrderByItem.cpp:76