Subclassing GdaDataSelect

Subclassing GdaDataSelect — Base class for all the data models returned by DBMS providers when a SELECT statement is executed

Synopsis


#include <providers-support/gda-data-select-priv.h>

                    GdaDataSelectClass;
void                gda_data_select_take_row            (GdaDataSelect *model,
                                                         GdaRow *row,
                                                         gint rownum);
GdaRow*             gda_data_select_get_stored_row      (GdaDataSelect *model,
                                                         gint rownum);
GdaConnection*      gda_data_select_get_connection      (GdaDataSelect *model);

Description

All database providers should subclass this class when returning a data model after the execution of a SELECT statement. Specifically it has the following features:

  • Manages its list of GdaColumn using the list exported by the prepared statement object (GdaPStmt)

  • Allows random or cursor based access

  • Allows for efficient memory usage allowing the subclass to finely tune its memory usage

  • Provides a generic mechanism for writable data models

See the Virtual methods for recordsets section for more information about how to implement the virtual methods of the subclassed object.

This section documents the methods available for the database provider's implementations.

Details

GdaDataSelectClass

typedef struct {
	GObjectClass      parent_class;

	/* GDA_DATA_MODEL_ACCESS_RANDOM */
	gint             (*fetch_nb_rows) (GdaDataSelect *model);
	gboolean         (*fetch_random)  (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error);
	gboolean         (*store_all)     (GdaDataSelect *model, GError **error);

	/* GDA_STATEMENT_MODEL_CURSOR_* */
	gboolean         (*fetch_next)    (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error);
	gboolean         (*fetch_prev)    (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error);
	gboolean         (*fetch_at)      (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error);
} GdaDataSelectClass;

GObjectClass parent_class;

parent object class

fetch_nb_rows ()

virtual method which must be implemented when access method is GDA_DATA_MODEL_ACCESS_RANDOM

fetch_random ()

virtual method which must be implemented when access method is GDA_DATA_MODEL_ACCESS_RANDOM

store_all ()

fetch_next ()

virtual method which must be implemented when access method is GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD

fetch_prev ()

virtual method which must be implemented when access method is GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD

fetch_at ()

virtual method which can be implemented when access method is GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD or GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD

gda_data_select_take_row ()

void                gda_data_select_take_row            (GdaDataSelect *model,
                                                         GdaRow *row,
                                                         gint rownum);

Stores row into model, externally advertized at row number rownum (if no row has been removed). The reference to row is stolen.

model :

a GdaDataSelect data model

row :

a GdaRow row

rownum :

"external" advertized row number

gda_data_select_get_stored_row ()

GdaRow*             gda_data_select_get_stored_row      (GdaDataSelect *model,
                                                         gint rownum);

Get the GdaRow object stored within model at row rownum (without taking care of removed rows)

model :

a GdaDataSelect data model

rownum :

"external" advertized row number

Returns :

the requested GdaRow, or NULL if not found

gda_data_select_get_connection ()

GdaConnection*      gda_data_select_get_connection      (GdaDataSelect *model);

Get a pointer to the GdaConnection object which was used when model was created (and which may be used internally by model).

model :

a GdaDataSelect data model

Returns :

a pointer to the GdaConnection, or NULL