Insert.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/Insert.cpp
22 
23  \brief A Insert can be used to add information in a table.
24 */
25 
26 // TerraLib
27 #include "Insert.h"
28 
30  : m_dsName(d),
31  m_fields(f),
32  m_select(s)
33 {
34 }
35 
36 te::da::Insert::Insert(const DataSetName& d, const Fields& f, const Select& s)
37  : m_dsName(static_cast<DataSetName*>(d.clone())),
38 
39  m_select(static_cast<Select*>(s.clone()))
40 {
41  m_fields.reset(new Fields(f));
42 }
43 
45  : m_dsName(d),
46  m_select(s)
47 {
48 }
49 
51  : m_dsName(static_cast<DataSetName*>(d.clone())),
52  m_select(static_cast<Select*>(s.clone()))
53 {
54 }
55 
57 
58 {
59  m_dsName.reset(rhs.m_dsName.get() ? new DataSetName(*rhs.m_dsName) : nullptr);
60  m_fields.reset(rhs.m_fields.get() ? new Fields(*rhs.m_fields) : nullptr);
61  m_select.reset(rhs.m_select.get() ? new Select(*rhs.m_select) : nullptr);
62 }
63 
64 te::da::Insert::~Insert() = default;
65 
67 {
68  if(this != &rhs)
69  {
70  m_dsName.reset(rhs.m_dsName.get() ? new DataSetName(*rhs.m_dsName) : nullptr);
71  m_fields.reset(rhs.m_fields.get() ? new Fields(*rhs.m_fields) : nullptr);
72  m_select.reset(rhs.m_select.get() ? new Select(*rhs.m_select) : nullptr);
73  }
74 
75  return *this;
76 }
77 
79 {
80  return new Insert(*this);
81 }
82 
84 {
85  return m_dsName.get();
86 }
87 
89 {
90  m_dsName.reset(d);
91 }
92 
94 {
95  return m_fields.get();
96 }
97 
99 {
100  m_fields.reset(f);
101 }
102 
104 {
105  return m_select.get();
106 }
107 
109 {
110  m_select.reset(s);
111 }
112 
Insert & operator=(const Insert &rhs)
Definition: Insert.cpp:66
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
void setDataSetName(DataSetName *d)
It sets the DataSetName associated to this object.
Definition: Insert.cpp:88
~Insert()
Destructor.
std::unique_ptr< Select > m_select
The associated Select.
Definition: Insert.h:158
std::unique_ptr< DataSetName > m_dsName
The associated DataSetName.
Definition: Insert.h:156
The Insert object can add the return of a select object.
Definition: Insert.h:50
Query * clone() const
It creates a new copy of this Insert.
Definition: Insert.cpp:78
void setFields(Fields *f)
It sets the Fields associated to this object.
Definition: Insert.cpp:98
std::unique_ptr< Fields > m_fields
The associated Fields.
Definition: Insert.h:157
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
Fields * getFields() const
It returns the associated fields.
Definition: Insert.cpp:93
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
TE_DEFINE_VISITABLE Insert(DataSetName *d, Fields *f, Select *s)
Constructor.
Definition: Insert.cpp:29
A Insert can be used to add information in a table.
DataSetName * getDataSetName() const
It returns the associated DataSetName.
Definition: Insert.cpp:83
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
void setSelect(Select *s)
It sets the select associated to this object.
Definition: Insert.cpp:108
Select * getSelect() const
It returns the associated select.
Definition: Insert.cpp:103
A Query is independent from the data source language/dialect.
Definition: Query.h:46