All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Join.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/Join.cpp
22 
23  \brief A Join clause combines two FromItems.
24 */
25 
26 // TerraLib
27 #include "Join.h"
28 #include "JoinCondition.h"
29 
31  : FromItem(""),
32  m_first(first),
33  m_second(second),
34  m_condition(c),
35  m_type(t),
36  m_isNatural(false)
37 {
38 }
39 
40 te::da::Join::Join(const FromItem& first, const FromItem& second, JoinType t, const JoinCondition& c)
41  : FromItem(""),
42  m_first(0),
43  m_second(0),
44  m_condition(0),
45  m_type(t),
46  m_isNatural(false)
47 {
48  m_first.reset(first.clone());
49  m_second.reset(second.clone());
50  m_condition.reset(c.clone());
51 }
52 
54  : FromItem(rhs),
55  m_first(0),
56  m_second(0),
57  m_condition(0),
58  m_type(rhs.m_type),
59  m_isNatural(rhs.m_isNatural)
60 {
61  m_first.reset(rhs.m_first.get() ? rhs.m_first->clone() : 0);
62  m_second.reset(rhs.m_second.get() ? rhs.m_second->clone() : 0);
63  m_condition.reset(rhs.m_condition.get() ? rhs.m_condition->clone() : 0);
64 }
65 
67 {
68 }
69 
71 {
72  if(this != &rhs)
73  {
75 
76  m_first.reset(rhs.m_first.get() ? rhs.m_first->clone() : 0);
77  m_second.reset(rhs.m_second.get() ? rhs.m_second->clone() : 0);
78  m_condition.reset(rhs.m_condition.get() ? rhs.m_condition->clone() : 0);
79  m_type = rhs.m_type;
80  m_isNatural = rhs.m_isNatural;
81  }
82 
83  return *this;
84 }
85 
87 {
88  return new Join(*this);
89 }
90 
92 {
93  return m_first.get();
94 }
95 
97 {
98  m_first.reset(item);
99 }
100 
102 {
103  return m_second.get();
104 }
105 
107 {
108  m_second.reset(item);
109 }
110 
112 {
113  return m_type;
114 }
115 
117 {
118  m_type = t;
119 }
120 
122 {
123  return m_condition.get();
124 }
125 
127 {
128  m_condition.reset(c);
129 }
130 
void setSecond(FromItem *item)
It sets second item involved in the join.
Definition: Join.cpp:106
An abstract class that models a source of data in a query.
Definition: FromItem.h:50
std::auto_ptr< JoinCondition > m_condition
The join condition.
Definition: Join.h:170
virtual JoinCondition * clone() const =0
It creates a new copy of this JoinCondition.
JoinType m_type
The join type.
Definition: Join.h:171
void setCondition(JoinCondition *c)
It sets the join condition.
Definition: Join.cpp:126
JoinType getType() const
It returns the join type.
Definition: Join.cpp:111
FromItem * clone() const
It creates a new copy of this FromItem.
Definition: Join.cpp:86
TE_DEFINE_VISITABLE Join(FromItem *first, FromItem *second, JoinType t, JoinCondition *c)
Constructor.
Definition: Join.cpp:30
A Join clause combines two FromItems.
FromItem & operator=(const FromItem &rhs)
Definition: FromItem.cpp:34
void setFirst(FromItem *item)
It sets first item involved in the join.
Definition: Join.cpp:96
A condition to be used in a Join clause.
A condition to be used in a Join clause.
Definition: JoinCondition.h:44
JoinType
The type of join in a query.
Definition: Enums.h:49
std::auto_ptr< FromItem > m_second
The first item involved in the join.
Definition: Join.h:169
A Join clause combines two FromItems.
Definition: Join.h:50
virtual FromItem * clone() const =0
It creates a new copy of this FromItem.
FromItem * getSecond() const
It returns the second item involved in the join.
Definition: Join.cpp:101
JoinCondition * getCondition() const
It returns the join condition.
Definition: Join.cpp:121
Join & operator=(const Join &rhs)
Definition: Join.cpp:70
std::auto_ptr< FromItem > m_first
The first item involved in the join.
Definition: Join.h:168
void setType(JoinType t)
It sets join type.
Definition: Join.cpp:116
~Join()
Destructor.
Definition: Join.cpp:66
bool m_isNatural
Natural is a shorthand for a JoinConditionUsing list that mentions all columns in the two tables that...
Definition: Join.h:172
FromItem * getFirst() const
It returns the first from item involved in the join.
Definition: Join.cpp:91