2
// Generated by gtkmmproc -- DO NOT MODIFY!
3
#ifndef _LIBGDAMM_DATASELECT_H
4
#define _LIBGDAMM_DATASELECT_H
7
#include <glibmm/ustring.h>
8
#include <sigc++/sigc++.h>
14
* Copyright 2006 libgdamm Development Team
16
* This library is free software; you can redistribute it and/or
17
* modify it under the terms of the GNU Lesser General Public
18
* License as published by the Free Software Foundation; either
19
* version 2.1 of the License, or(at your option) any later version.
21
* This library is distributed in the hope that it will be useful,
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
* Lesser General Public License for more details.
26
* You should have received a copy of the GNU Lesser General Public
27
* License along with this library; if not, write to the Free
28
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32
#include <libgdamm/datamodel.h>
33
#include <libgdamm/statement.h>
34
#include <libgdamm/set.h>
36
#ifndef DOXYGEN_SHOULD_SKIP_THIS
37
typedef struct _GdaDataSelect GdaDataSelect;
38
typedef struct _GdaDataSelectClass GdaDataSelectClass;
39
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
46
{ class DataSelect_Class; } // namespace Gda
55
/** Data models returned by the execution of a SELECT statement.
57
* This data model implements the Gda::DataModel interface and is the required
58
* base object when database providers implement a data model returned when a
59
* SELECT statement has been executed. As the GdaDataModel interface is implemented,
60
* consult the API to access and modify the data held in a GdaDataSelect object.
62
* The default behaviour however is to disallow modifications, and this section
63
* documents how to characterize a Gda::DataSelect to allow modifications.
64
* Once this is done, any modification done to the data model whill be propagated
65
* to the modified table in the database using INSERT, UPDATE or DELETE statements.
67
* After any modification, it is still possible to read values from the data model
68
* (even values for rows which have been modified or inserted). The data model
69
* might then execute some SELECT statement to fetch some actualized values.
70
* Note: there is a corner case where a modification made to a row would make
71
* the row not selected at first in the data model (for example is the original
72
* SELECT statement included a clause "WHERE id < 100" and the modification sets
73
* the "id" value to 110), then the row will still be in the data model
74
* even though it would not be if the SELECT statement which execution
75
* created the data model in the first place was re-run.
81
: public Glib::Object,
85
#ifndef DOXYGEN_SHOULD_SKIP_THIS
88
typedef DataSelect CppObjectType;
89
typedef DataSelect_Class CppClassType;
90
typedef GdaDataSelect BaseObjectType;
91
typedef GdaDataSelectClass BaseClassType;
93
private: friend class DataSelect_Class;
94
static CppClassType dataselect_class_;
98
DataSelect(const DataSelect&);
99
DataSelect& operator=(const DataSelect&);
102
explicit DataSelect(const Glib::ConstructParams& construct_params);
103
explicit DataSelect(GdaDataSelect* castitem);
105
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
108
virtual ~DataSelect();
110
#ifndef DOXYGEN_SHOULD_SKIP_THIS
111
static GType get_type() G_GNUC_CONST;
114
static GType get_base_type() G_GNUC_CONST;
117
///Provides access to the underlying C GObject.
118
GdaDataSelect* gobj() { return reinterpret_cast<GdaDataSelect*>(gobject_); }
120
///Provides access to the underlying C GObject.
121
const GdaDataSelect* gobj() const { return reinterpret_cast<GdaDataSelect*>(gobject_); }
123
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
124
GdaDataSelect* gobj_copy();
131
/** Specifies the SQL condition corresponding to the WHERE part of a SELECT statement which would
132
* return only 1 row (the expression of the primary key).
134
* For example for a table created as <![CDATA["CREATE TABLE mytable (part1 int NOT <tt>0</tt>, part2 string NOT <tt>0</tt>,
135
* name string, PRIMARY KEY (part1, part2))"]]>, and if @a pmodel corresponds to the execution of the
136
* <![CDATA["SELECT name, part1, part2 FROM mytable"]]>, then the sensible value for @a sql_where would be
137
* <![CDATA["part1 = ##-1::int AND part2 = ##-2::string"]]> because the values of the 'part1' field are located
138
* in @a pmodel's column number 1 and the values of the 'part2' field are located
139
* in @a pmodel's column number 2 and the primary key is composed of (part1, part2).
141
* For more information about the syntax of the parameters (named <![CDATA["##-1::int"]]> for example), see the
142
* GdaSqlParser documentation, and
143
* set_modification_statement().
144
* @param sql_where An SQL condition (without the WHERE keyword).
145
* @return <tt>true</tt> if no error occurred.
147
bool set_row_selection_condition_sql(const Glib::ustring& sql_where);
148
// This is internal only
151
/** Offers the same features as set_row_selection_condition() but the expression
152
* is computed from the meta data associated to the connection being used when @a model was created.
154
* NOTE1: make sure the meta data associated to the connection is up to date before using this
155
* method, see Gda::Connection::update_meta_store().
157
* NOTE2: if the SELECT statement from which @a model has been created uses more than one table, or
158
* if the table used does not have any primary key, then this method will fail
159
* @return <tt>true</tt> if no error occurred.
161
void compute_row_selection_condition();
163
/** Informs @a model that it should allow modifications to the data in some columns and some rows
164
* using @a mod_stmt to propagate those modifications into the database.
168
* <listitem>an UPDATE statement, then all the rows in @a model will be modifyable</listitem>
169
* <listitem>a DELETE statement, then it will be possible to delete rows in @a model</listitem>
170
* <listitem>in INSERT statement, then it will be possible to add some rows to @a model</listitem>
171
* <listitem>any other statement, then this method will return an error</listitem>
174
* This method can be called several times to specify different types of modification.
176
* If @a mod_stmt is an UPDATE or DELETE statement then it should have a WHERE part which identifies
177
* a unique row in @a model (please note that this property can't be checked but may result
178
* in @a model behaving in an unpredictable way).
180
* NOTE1: However, if the set_row_selection_condition()
181
* or set_row_selection_condition_sql() have been successfully be called before, the WHERE
182
* part of @a mod_stmt <em>WILL</em> be modified to use the row selection condition specified through one of
183
* these methods (please not that it is then possible to avoid specifying a WHERE part in @a mod_stmt then).
185
* NOTE2: if set_row_selection_condition()
186
* or set_row_selection_condition_sql() have not yet been successfully be called before, then
187
* the WHERE part of @a mod_stmt will be used as if one of these functions had been called.
188
* @param mod_stmt A Gda::Statement (INSERT, UPDATE or DELETE).
189
* @return <tt>true</tt> if no error occurred.
191
void set_modification_statement(const Glib::RefPtr<Statement>& mod_stmt);
193
/** Offers the same feature as set_modification_statement() but using an SQL statement
194
* @param sql An SQL text.
195
* @return <tt>true</tt> if no error occurred.
197
void set_modification_statement_sql(const Glib::ustring& sql);
199
/** Makes @a model try to compute INSERT, UPDATE and DELETE statements to be used when modifying @a model's contents.
200
* @note any modification statement set using set_modification_statement() will first be unset
201
* @return <tt>true</tt> if no error occurred. If <tt>false</tt> is returned, then some modification statement may still have been
204
void compute_modification_statements();
206
/** Computes correct attributes for each of @a model's columns, which includes the "NOT <tt>0</tt>" attribute, the
207
* default value, the precision and scale for numeric values.
208
* @return <tt>true</tt> if no error occurred.
210
void compute_columns_attributes();
213
/** Get a pointer to the Gda::Connection object which was used when @a model was created
214
* (and which may be used internally by @a model).
215
* @return A pointer to the Gda::Connection, or <tt>0</tt>.
217
Glib::RefPtr<Connection> get_connection();
220
/** Requests that @a model be re-run to have an updated result. If an error occurs,
221
* then @a model will not be changed.
224
* @return <tt>true</tt> if no error occurred.
228
#ifdef GLIBMM_PROPERTIES_ENABLED
229
/** Automatically re-run the SELECT statement if any parameter has changed since it was first executed.
231
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
232
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
233
* the value of the property changes.
235
Glib::PropertyProxy<bool> property_auto_reset() ;
236
#endif //#GLIBMM_PROPERTIES_ENABLED
238
#ifdef GLIBMM_PROPERTIES_ENABLED
239
/** Automatically re-run the SELECT statement if any parameter has changed since it was first executed.
241
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
242
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
243
* the value of the property changes.
245
Glib::PropertyProxy_ReadOnly<bool> property_auto_reset() const;
246
#endif //#GLIBMM_PROPERTIES_ENABLED
248
#ifdef GLIBMM_PROPERTIES_ENABLED
249
/** Tells if model has analyzed all the rows.
251
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
252
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
253
* the value of the property changes.
255
Glib::PropertyProxy<bool> property_store_all_rows() ;
256
#endif //#GLIBMM_PROPERTIES_ENABLED
258
#ifdef GLIBMM_PROPERTIES_ENABLED
259
/** Tells if model has analyzed all the rows.
261
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
262
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
263
* the value of the property changes.
265
Glib::PropertyProxy_ReadOnly<bool> property_store_all_rows() const;
266
#endif //#GLIBMM_PROPERTIES_ENABLED
268
#ifdef GLIBMM_PROPERTIES_ENABLED
269
/** Connection from which this data model is created.
271
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
272
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
273
* the value of the property changes.
275
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Connection> > property_connection() const;
276
#endif //#GLIBMM_PROPERTIES_ENABLED
279
#ifdef GLIBMM_PROPERTIES_ENABLED
280
/** DELETE Statement to be executed to remove data.
282
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
283
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
284
* the value of the property changes.
286
Glib::PropertyProxy< Glib::RefPtr<Statement> > property_delete_stmt() ;
287
#endif //#GLIBMM_PROPERTIES_ENABLED
289
#ifdef GLIBMM_PROPERTIES_ENABLED
290
/** DELETE Statement to be executed to remove data.
292
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
293
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
294
* the value of the property changes.
296
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_delete_stmt() const;
297
#endif //#GLIBMM_PROPERTIES_ENABLED
299
#ifdef GLIBMM_PROPERTIES_ENABLED
300
/** INSERT Statement to be executed to add data.
302
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
303
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
304
* the value of the property changes.
306
Glib::PropertyProxy< Glib::RefPtr<Statement> > property_insert_stmt() ;
307
#endif //#GLIBMM_PROPERTIES_ENABLED
309
#ifdef GLIBMM_PROPERTIES_ENABLED
310
/** INSERT Statement to be executed to add data.
312
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
313
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
314
* the value of the property changes.
316
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_insert_stmt() const;
317
#endif //#GLIBMM_PROPERTIES_ENABLED
319
#ifdef GLIBMM_PROPERTIES_ENABLED
320
/** Associated prepared statement (for internal usage).
322
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
323
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
324
* the value of the property changes.
326
Glib::PropertyProxy< Glib::RefPtr<Statement> > property_prepared_stmt() ;
327
#endif //#GLIBMM_PROPERTIES_ENABLED
329
#ifdef GLIBMM_PROPERTIES_ENABLED
330
/** Associated prepared statement (for internal usage).
332
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
333
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
334
* the value of the property changes.
336
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_prepared_stmt() const;
337
#endif //#GLIBMM_PROPERTIES_ENABLED
339
#ifdef GLIBMM_PROPERTIES_ENABLED
340
/** UPDATE Statement to be executed to update data.
342
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
343
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
344
* the value of the property changes.
346
Glib::PropertyProxy< Glib::RefPtr<Statement> > property_update_stmt() ;
347
#endif //#GLIBMM_PROPERTIES_ENABLED
349
#ifdef GLIBMM_PROPERTIES_ENABLED
350
/** UPDATE Statement to be executed to update data.
352
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
353
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
354
* the value of the property changes.
356
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_update_stmt() const;
357
#endif //#GLIBMM_PROPERTIES_ENABLED
359
#ifdef GLIBMM_PROPERTIES_ENABLED
360
/** GdaSet used when the SELECT statement was executed.
362
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
363
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
364
* the value of the property changes.
366
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Set> > property_exec_params() const;
367
#endif //#GLIBMM_PROPERTIES_ENABLED
370
#ifdef GLIBMM_PROPERTIES_ENABLED
371
/** Determines how the data model may be used.
373
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
374
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
375
* the value of the property changes.
377
Glib::PropertyProxy_ReadOnly<guint> property_model_usage() const;
378
#endif //#GLIBMM_PROPERTIES_ENABLED
384
//C++ methods used to invoke GTK+ virtual functions:
387
//GTK+ Virtual Functions (override these to change behaviour):
389
//Default Signal Handlers::
400
/** A Glib::wrap() method for this object.
402
* @param object The C instance.
403
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
404
* @result A C++ instance that wraps this C instance.
406
* @relates Gnome::Gda::DataSelect
408
Glib::RefPtr<Gnome::Gda::DataSelect> wrap(GdaDataSelect* object, bool take_copy = false);
412
#endif /* _LIBGDAMM_DATASELECT_H */