~ubuntu-branches/ubuntu/trusty/libgdamm5.0/trusty

« back to all changes in this revision

Viewing changes to libgda/libgdamm/dataselect.h

  • Committer: Package Import Robot
  • Author(s): Daniel Holbach
  • Date: 2012-02-07 16:44:36 UTC
  • Revision ID: package-import@ubuntu.com-20120207164436-j1odzs6zz6gz2vae
Tags: upstream-4.99.6
ImportĀ upstreamĀ versionĀ 4.99.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
// Generated by gtkmmproc -- DO NOT MODIFY!
 
3
#ifndef _LIBGDAMM_DATASELECT_H
 
4
#define _LIBGDAMM_DATASELECT_H
 
5
 
 
6
 
 
7
#include <glibmm/ustring.h>
 
8
#include <sigc++/sigc++.h>
 
9
 
 
10
// -*- C++ -*- //
 
11
 
 
12
/* dataselect.h
 
13
 *
 
14
 * Copyright 2006 libgdamm Development Team
 
15
 *
 
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.
 
20
 *
 
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.
 
25
 *
 
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.
 
29
 */
 
30
 
 
31
 
 
32
#include <libgdamm/datamodel.h>
 
33
#include <libgdamm/statement.h>
 
34
#include <libgdamm/set.h>
 
35
 
 
36
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
37
typedef struct _GdaDataSelect GdaDataSelect;
 
38
typedef struct _GdaDataSelectClass GdaDataSelectClass;
 
39
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
40
 
 
41
 
 
42
namespace Gnome
 
43
{
 
44
 
 
45
namespace Gda
 
46
{ class DataSelect_Class; } // namespace Gda
 
47
 
 
48
} // namespace Gnome
 
49
namespace Gnome
 
50
{
 
51
 
 
52
namespace Gda
 
53
{
 
54
 
 
55
/** Data models returned by the execution of a SELECT statement.
 
56
 *
 
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.
 
61
 *
 
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.
 
66
 *
 
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.
 
76
 *
 
77
 * @ingroup DataModels
 
78
 */
 
79
 
 
80
class DataSelect
 
81
 : public Glib::Object,
 
82
   public DataModel
 
83
{
 
84
  
 
85
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
86
 
 
87
public:
 
88
  typedef DataSelect CppObjectType;
 
89
  typedef DataSelect_Class CppClassType;
 
90
  typedef GdaDataSelect BaseObjectType;
 
91
  typedef GdaDataSelectClass BaseClassType;
 
92
 
 
93
private:  friend class DataSelect_Class;
 
94
  static CppClassType dataselect_class_;
 
95
 
 
96
private:
 
97
  // noncopyable
 
98
  DataSelect(const DataSelect&);
 
99
  DataSelect& operator=(const DataSelect&);
 
100
 
 
101
protected:
 
102
  explicit DataSelect(const Glib::ConstructParams& construct_params);
 
103
  explicit DataSelect(GdaDataSelect* castitem);
 
104
 
 
105
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
106
 
 
107
public:
 
108
  virtual ~DataSelect();
 
109
 
 
110
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
111
  static GType get_type()      G_GNUC_CONST;
 
112
 
 
113
 
 
114
  static GType get_base_type() G_GNUC_CONST;
 
115
#endif
 
116
 
 
117
  ///Provides access to the underlying C GObject.
 
118
  GdaDataSelect*       gobj()       { return reinterpret_cast<GdaDataSelect*>(gobject_); }
 
119
 
 
120
  ///Provides access to the underlying C GObject.
 
121
  const GdaDataSelect* gobj() const { return reinterpret_cast<GdaDataSelect*>(gobject_); }
 
122
 
 
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();
 
125
 
 
126
private:
 
127
 
 
128
  
 
129
public:
 
130
  
 
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).
 
133
   * 
 
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).
 
140
   * 
 
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.
 
146
   */
 
147
  bool set_row_selection_condition_sql(const Glib::ustring& sql_where);
 
148
  // This is internal only
 
149
  
 
150
  
 
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.
 
153
   * 
 
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().
 
156
   * 
 
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.
 
160
   */
 
161
  void compute_row_selection_condition();
 
162
  
 
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.
 
165
   * 
 
166
   * If @a mod_stmt is:
 
167
   * <itemizedlist>
 
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>
 
172
   * </itemizedlist>
 
173
   * 
 
174
   * This method can be called several times to specify different types of modification.
 
175
   * 
 
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).
 
179
   * 
 
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).
 
184
   * 
 
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.
 
190
   */
 
191
  void set_modification_statement(const Glib::RefPtr<Statement>& mod_stmt);
 
192
  
 
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.
 
196
   */
 
197
  void set_modification_statement_sql(const Glib::ustring& sql);
 
198
  
 
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
 
202
   * computed.
 
203
   */
 
204
  void compute_modification_statements();
 
205
  
 
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.
 
209
   */
 
210
  void compute_columns_attributes();
 
211
 
 
212
  
 
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>.
 
216
   */
 
217
  Glib::RefPtr<Connection> get_connection();
 
218
 
 
219
  
 
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.
 
222
   * 
 
223
   * @newin{4,2}
 
224
   * @return <tt>true</tt> if no error occurred.
 
225
   */
 
226
  void rerun();
 
227
 
 
228
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
229
/** Automatically re-run the SELECT statement if any parameter has changed since it was first executed.
 
230
   *
 
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.
 
234
   */
 
235
  Glib::PropertyProxy<bool> property_auto_reset() ;
 
236
#endif //#GLIBMM_PROPERTIES_ENABLED
 
237
 
 
238
#ifdef GLIBMM_PROPERTIES_ENABLED
 
239
/** Automatically re-run the SELECT statement if any parameter has changed since it was first executed.
 
240
   *
 
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.
 
244
   */
 
245
  Glib::PropertyProxy_ReadOnly<bool> property_auto_reset() const;
 
246
#endif //#GLIBMM_PROPERTIES_ENABLED
 
247
 
 
248
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
249
/** Tells if model has analyzed all the rows.
 
250
   *
 
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.
 
254
   */
 
255
  Glib::PropertyProxy<bool> property_store_all_rows() ;
 
256
#endif //#GLIBMM_PROPERTIES_ENABLED
 
257
 
 
258
#ifdef GLIBMM_PROPERTIES_ENABLED
 
259
/** Tells if model has analyzed all the rows.
 
260
   *
 
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.
 
264
   */
 
265
  Glib::PropertyProxy_ReadOnly<bool> property_store_all_rows() const;
 
266
#endif //#GLIBMM_PROPERTIES_ENABLED
 
267
 
 
268
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
269
/** Connection from which this data model is created.
 
270
   *
 
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.
 
274
   */
 
275
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Connection> > property_connection() const;
 
276
#endif //#GLIBMM_PROPERTIES_ENABLED
 
277
 
 
278
 
 
279
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
280
/** DELETE Statement to be executed to remove data.
 
281
   *
 
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.
 
285
   */
 
286
  Glib::PropertyProxy< Glib::RefPtr<Statement> > property_delete_stmt() ;
 
287
#endif //#GLIBMM_PROPERTIES_ENABLED
 
288
 
 
289
#ifdef GLIBMM_PROPERTIES_ENABLED
 
290
/** DELETE Statement to be executed to remove data.
 
291
   *
 
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.
 
295
   */
 
296
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_delete_stmt() const;
 
297
#endif //#GLIBMM_PROPERTIES_ENABLED
 
298
 
 
299
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
300
/** INSERT Statement to be executed to add data.
 
301
   *
 
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.
 
305
   */
 
306
  Glib::PropertyProxy< Glib::RefPtr<Statement> > property_insert_stmt() ;
 
307
#endif //#GLIBMM_PROPERTIES_ENABLED
 
308
 
 
309
#ifdef GLIBMM_PROPERTIES_ENABLED
 
310
/** INSERT Statement to be executed to add data.
 
311
   *
 
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.
 
315
   */
 
316
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_insert_stmt() const;
 
317
#endif //#GLIBMM_PROPERTIES_ENABLED
 
318
 
 
319
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
320
/** Associated prepared statement (for internal usage).
 
321
   *
 
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.
 
325
   */
 
326
  Glib::PropertyProxy< Glib::RefPtr<Statement> > property_prepared_stmt() ;
 
327
#endif //#GLIBMM_PROPERTIES_ENABLED
 
328
 
 
329
#ifdef GLIBMM_PROPERTIES_ENABLED
 
330
/** Associated prepared statement (for internal usage).
 
331
   *
 
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.
 
335
   */
 
336
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_prepared_stmt() const;
 
337
#endif //#GLIBMM_PROPERTIES_ENABLED
 
338
 
 
339
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
340
/** UPDATE Statement to be executed to update data.
 
341
   *
 
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.
 
345
   */
 
346
  Glib::PropertyProxy< Glib::RefPtr<Statement> > property_update_stmt() ;
 
347
#endif //#GLIBMM_PROPERTIES_ENABLED
 
348
 
 
349
#ifdef GLIBMM_PROPERTIES_ENABLED
 
350
/** UPDATE Statement to be executed to update data.
 
351
   *
 
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.
 
355
   */
 
356
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Statement> > property_update_stmt() const;
 
357
#endif //#GLIBMM_PROPERTIES_ENABLED
 
358
 
 
359
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
360
/** GdaSet used when the SELECT statement was executed.
 
361
   *
 
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.
 
365
   */
 
366
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Set> > property_exec_params() const;
 
367
#endif //#GLIBMM_PROPERTIES_ENABLED
 
368
 
 
369
 
 
370
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
371
/** Determines how the data model may be used.
 
372
   *
 
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.
 
376
   */
 
377
  Glib::PropertyProxy_ReadOnly<guint> property_model_usage() const;
 
378
#endif //#GLIBMM_PROPERTIES_ENABLED
 
379
 
 
380
 
 
381
public:
 
382
 
 
383
public:
 
384
  //C++ methods used to invoke GTK+ virtual functions:
 
385
 
 
386
protected:
 
387
  //GTK+ Virtual Functions (override these to change behaviour):
 
388
 
 
389
  //Default Signal Handlers::
 
390
 
 
391
 
 
392
};
 
393
 
 
394
} // namespace Gda
 
395
} // namespace Gnome
 
396
 
 
397
 
 
398
namespace Glib
 
399
{
 
400
  /** A Glib::wrap() method for this object.
 
401
   * 
 
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.
 
405
   *
 
406
   * @relates Gnome::Gda::DataSelect
 
407
   */
 
408
  Glib::RefPtr<Gnome::Gda::DataSelect> wrap(GdaDataSelect* object, bool take_copy = false);
 
409
}
 
410
 
 
411
 
 
412
#endif /* _LIBGDAMM_DATASELECT_H */
 
413