Loading...
Searching...
No Matches
PreparedQuery.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/datasource/PreparedQuery.h
22
23 \brief A class that models a prepared query.
24*/
25
26#ifndef __TERRALIB_DATAACCESS_INTERNAL_PREPAREDQUERY_H
27#define __TERRALIB_DATAACCESS_INTERNAL_PREPAREDQUERY_H
28
29// TerraLib
30#include "../../common/Enums.h"
31#include "../Config.h"
32
33// STL
34#include <string>
35#include <vector>
36
37// Boost
38#include <boost/cstdint.hpp>
39#include <boost/noncopyable.hpp>
40
41namespace te
42{
43// Forward declarations
44 namespace dt
45 {
46 class AbstractData;
47 class ByteArray;
48 class DateTime;
49 class Property;
50 }
51
52 namespace gm { class Geometry; }
53
54 namespace rst { class Raster; }
55
56 namespace da
57 {
58 class DataSet;
59 class DataSourceTransactor;
60 class Query;
61
62 /*!
63 \class PreparedQuery
64
65 \brief A class that model a prepared query.
66
67 \sa DataSourceTransactor, DataSet, Query, Literal
68 */
69 class TEDATAACCESSEXPORT PreparedQuery : public boost::noncopyable
70 {
71 public:
72
73 /*! \brief Constructor. */
75
76 /*! \brief Virtual destructor. */
77 virtual ~PreparedQuery() {}
78
79 /*!
80 \brief It returns the prepared query name.
81
82 \param return The prepared query name.
83 */
84 virtual std::string getName() const = 0;
85
86 /*!
87 \brief It prepares the query that may be used for commands that are used mutiple times (select, insert, update and delete).
88
89 This command will submit a request to create a prepared query with the given parameters.
90
91 \param query The query to be prepared.
92 \param paramTypes The list of parameters data type.
93
94 \exception Exception It throws an exception if the prepared query can not be created. For example
95 if another prepared query with the same name already exists, this may throws an exception.
96 */
97 virtual void prepare(const Query& query, const std::vector<te::dt::Property*>& paramTypes) = 0;
98
99 /*!
100 \brief It prepares the query using native dialect.
101
102 This command may be used for commands that are used mutiple times (select, insert, update and delete).
103
104 This command will submit a request to create a prepared query with the given parameters.
105
106 \param query The query to be prepared.
107 \param paramTypes The list of parameters data type.
108
109 \exception Exception It throws an exception if the prepared query can not be created. For example
110 if another prepared query with the same name already exists, this may throws an exception.
111 */
112 virtual void prepare(const std::string& query, const std::vector<te::dt::Property*>& paramTypes) = 0;
113
114 /*
115 \brief It executes a prepared query with parameters informed by bind methods.
116
117 \exception Excpetion It throws na exception if something goes wrong.
118 */
119 virtual void execute() = 0;
120
121 /*
122 \brief It executes a retrieval prepared query with parameters informed by bind methods.
123
124 \param travType The traverse type associated to the returned dataset (if any is returned).
125 \param rwRole The read and write permission associated to the returned dataset (if any is returned).
126
127 \return A dataset with the result of the given query. The caller will take its ownership.
128
129 \exception Excpetion It throws na exception if something goes wrong.
130 */
133
134 /*!
135 \brief Binds the i-th parameter of the query to a value.
136
137 \param i The parameter index.
138 \param value The parameter value.
139 */
140 virtual void bind(int i, char value) = 0;
141
142 /*!
143 \brief Binds the i-th parameter of the query to a value.
144
145 \param i The parameter index.
146 \param value The parameter value.
147 */
148 virtual void bind(int i, unsigned char value) = 0;
149
150 /*!
151 \brief Binds the i-th parameter of the query to a value.
152
153 \param i The parameter index.
154 \param value The parameter value.
155 */
156 virtual void bind(int i, boost::int16_t value) = 0;
157
158 /*!
159 \brief Binds the i-th parameter of the query to a value.
160
161 \param i The parameter index.
162 \param value The parameter value.
163 */
164 virtual void bind(int i, boost::int32_t value) = 0;
165
166 /*!
167 \brief Binds the i-th parameter of the query to a value.
168
169 \param i The parameter index.
170 \param value The parameter value.
171 */
172 virtual void bind(int i, boost::int64_t value) = 0;
173
174 /*!
175 \brief Binds the i-th parameter of the query to a value.
176
177 \param i The parameter index.
178 \param value The parameter value.
179 */
180 virtual void bind(int i, bool value) = 0;
181
182 /*!
183 \brief Binds the i-th parameter of the query to a value.
184
185 \param i The parameter index.
186 \param value The parameter value.
187 */
188 virtual void bind(int i, float value) = 0;
189
190 /*!
191 \brief Binds the i-th parameter of the query to a value.
192
193 \param i The parameter index.
194 \param value The parameter value.
195 */
196 virtual void bind(int i, double value) = 0;
197
198 /*!
199 \brief Binds the i-th parameter of the query to a value.
200
201 \param i The parameter index.
202 \param value The parameter value.
203
204 \todo The name of this method will change when we have a numeric type!
205 */
206 virtual void bindNumeric(int i, const std::string& value) = 0;
207
208 /*!
209 \brief Binds the i-th parameter of the query to a value.
210
211 \param i The parameter index.
212 \param value The parameter value.
213 */
214 virtual void bind(int i, const std::string& value) = 0;
215
216 /*!
217 \brief Binds the i-th parameter of the query to a value.
218
219 \param i The parameter index.
220 \param value The parameter value.
221 */
222 virtual void bind(int i, const te::dt::ByteArray& value) = 0;
223
224 /*!
225 \brief Binds the i-th parameter of the query to a value.
226
227 \param i The parameter index.
228 \param value The parameter value.
229 */
230 virtual void bind(int i, const te::gm::Geometry& value) = 0;
231
232 /*!
233 \brief Binds the i-th parameter of the query to a value.
234
235 \param i The parameter index.
236 \param value The parameter value.
237 */
238 virtual void bind(int i, const te::rst::Raster& value) = 0;
239
240 /*!
241 \brief Binds the i-th parameter of the query to a value.
242
243 \param i The parameter index.
244 \param value The parameter value.
245 */
246 virtual void bind(int i, const te::dt::DateTime& value) = 0;
247
248 /*!
249 \brief Binds the i-th parameter of the query to a value.
250
251 \param i The parameter index.
252 \param value The parameter value.
253 */
254 virtual void bind(int i, const DataSet& value) = 0;
255
256 /*!
257 \brief Binds the i-th parameter of the query to a value.
258
259 \param i The parameter index.
260 \param value The parameter value.
261 */
262 virtual void bind(int i, const te::dt::AbstractData& ad);
263
264 /*!
265 \brief It returns a pointer to the underlying data source transactor.
266
267 \return A pointer to the underlying data source transactor.
268 */
270 };
271
272 } // end namespace da
273} // end namespace te
274
275#endif // __TERRALIB_DATAACCESS_INTERNAL_PREPAREDQUERY_H
276
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
A class that model a prepared query.
Definition: PreparedQuery.h:70
virtual void bind(int i, const te::dt::AbstractData &ad)
Binds the i-th parameter of the query to a value.
virtual void bind(int i, const std::string &value)=0
Binds the i-th parameter of the query to a value.
virtual void execute()=0
virtual void bind(int i, const DataSet &value)=0
Binds the i-th parameter of the query to a value.
virtual DataSourceTransactor * getTransactor() const =0
It returns a pointer to the underlying data source transactor.
virtual void bind(int i, float value)=0
Binds the i-th parameter of the query to a value.
virtual ~PreparedQuery()
Virtual destructor.
Definition: PreparedQuery.h:77
virtual void bind(int i, boost::int16_t value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, const te::rst::Raster &value)=0
Binds the i-th parameter of the query to a value.
virtual DataSet * query(te::common::TraverseType travType=te::common::FORWARDONLY, te::common::AccessPolicy rwRole=te::common::RAccess)=0
virtual void bind(int i, double value)=0
Binds the i-th parameter of the query to a value.
virtual void prepare(const Query &query, const std::vector< te::dt::Property * > &paramTypes)=0
It prepares the query that may be used for commands that are used mutiple times (select,...
virtual std::string getName() const =0
It returns the prepared query name.
PreparedQuery()
Constructor.
Definition: PreparedQuery.h:74
virtual void bind(int i, const te::dt::DateTime &value)=0
Binds the i-th parameter of the query to a value.
virtual void bindNumeric(int i, const std::string &value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, boost::int64_t value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, unsigned char value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, boost::int32_t value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, bool value)=0
Binds the i-th parameter of the query to a value.
virtual void prepare(const std::string &query, const std::vector< te::dt::Property * > &paramTypes)=0
It prepares the query using native dialect.
virtual void bind(int i, char value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, const te::dt::ByteArray &value)=0
Binds the i-th parameter of the query to a value.
virtual void bind(int i, const te::gm::Geometry &value)=0
Binds the i-th parameter of the query to a value.
A Query is independent from the data source language/dialect.
Definition: Query.h:47
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
A class for representing binary data.
Definition: ByteArray.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
An abstract class for raster data strucutures.
Definition: Raster.h:72
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:54
@ FORWARDONLY
Definition: Enums.h:55
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
@ RAccess
Definition: Enums.h:43
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97