GdaDataModel

GdaDataModel — Basic data model class

Functions

void gda_data_model_changed ()
void gda_data_model_row_inserted ()
void gda_data_model_row_updated ()
void gda_data_model_row_removed ()
void gda_data_model_column_inserted ()
void gda_data_model_column_updated ()
void gda_data_model_column_removed ()
void gda_data_model_freeze ()
void gda_data_model_thaw ()
gint gda_data_model_get_n_rows ()
gint gda_data_model_get_n_columns ()
GdaFieldAttributes * gda_data_model_describe_column ()
const gchar * gda_data_model_get_column_title ()
void gda_data_model_set_column_title ()
gint gda_data_model_get_column_position ()
const GdaRow * gda_data_model_get_row ()
const GdaValue * gda_data_model_get_value_at ()
gboolean gda_data_model_is_updatable ()
const GdaRow * gda_data_model_append_row ()
gboolean gda_data_model_remove_row ()
gboolean gda_data_model_update_row ()
gboolean gda_data_model_append_column ()
gboolean gda_data_model_update_column ()
gboolean gda_data_model_remove_column ()
gboolean (*GdaDataModelForeachFunc) ()
void gda_data_model_foreach ()
gboolean gda_data_model_has_changed ()
gboolean gda_data_model_begin_update ()
gboolean gda_data_model_cancel_update ()
gboolean gda_data_model_end_update ()
gchar * gda_data_model_to_comma_separated ()
gchar * gda_data_model_to_tab_separated ()
gchar * gda_data_model_to_xml ()
xmlNodePtr gda_data_model_to_xml_node ()
gboolean gda_data_model_add_data_from_xml_node ()
const gchar * gda_data_model_get_command_text ()
void gda_data_model_set_command_text ()
GdaCommandType gda_data_model_get_command_type ()
void gda_data_model_set_command_type ()

Types and Values

Description

Functions

gda_data_model_changed ()

void
gda_data_model_changed (GdaDataModel *model);

Notifies listeners of the given data model object of changes in the underlying data. Listeners usually will connect themselves to the "changed" signal in the GdaDataModel class, thus being notified of any new data being appended or removed from the data model.

Parameters

model

a GdaDataModel object.

 

gda_data_model_row_inserted ()

void
gda_data_model_row_inserted (GdaDataModel *model,
                             gint row);

Emits the 'row_inserted' and 'changed' signals on model .

Parameters

model

a GdaDataModel object.

 

row

row number.

 

gda_data_model_row_updated ()

void
gda_data_model_row_updated (GdaDataModel *model,
                            gint row);

Emits the 'row_updated' and 'changed' signals on model .

Parameters

model

a GdaDataModel object.

 

row

row number.

 

gda_data_model_row_removed ()

void
gda_data_model_row_removed (GdaDataModel *model,
                            gint row);

Emits the 'row_removed' and 'changed' signal on model .

Parameters

model

a GdaDataModel object.

 

row

row number.

 

gda_data_model_column_inserted ()

void
gda_data_model_column_inserted (GdaDataModel *model,
                                gint col);

Emits the 'column_inserted' and 'changed' signals on model .

Parameters

model

a GdaDataModel object.

 

col

column number.

 

gda_data_model_column_updated ()

void
gda_data_model_column_updated (GdaDataModel *model,
                               gint col);

Emits the 'column_updated' and 'changed' signals on model .

Parameters

model

a GdaDataModel object.

 

col

column number.

 

gda_data_model_column_removed ()

void
gda_data_model_column_removed (GdaDataModel *model,
                               gint col);

Emits the 'column_removed' and 'changed' signal on model .

Parameters

model

a GdaDataModel object.

 

col

column number.

 

gda_data_model_freeze ()

void
gda_data_model_freeze (GdaDataModel *model);

Disables notifications of changes on the given data model. To re-enable notifications again, you should call the gda_data_model_thaw function.

Parameters

model

a GdaDataModel object.

 

gda_data_model_thaw ()

void
gda_data_model_thaw (GdaDataModel *model);

Re-enables notifications of changes on the given data model.

Parameters

model

a GdaDataModel object.

 

gda_data_model_get_n_rows ()

gint
gda_data_model_get_n_rows (GdaDataModel *model);

Parameters

model

a GdaDataModel object.

 

Returns

the number of rows in the given data model.


gda_data_model_get_n_columns ()

gint
gda_data_model_get_n_columns (GdaDataModel *model);

Parameters

model

a GdaDataModel object.

 

Returns

the number of columns in the given data model.


gda_data_model_describe_column ()

GdaFieldAttributes *
gda_data_model_describe_column (GdaDataModel *model,
                                gint col);

Queries the underlying data model implementation for a description of a given column. That description is returned in the form of a GdaFieldAttributes structure, which contains all the information about the given column in the data model.

Parameters

model

a GdaDataModel object.

 

col

column number.

 

Returns

the description of the column.


gda_data_model_get_column_title ()

const gchar *
gda_data_model_get_column_title (GdaDataModel *model,
                                 gint col);

Parameters

model

a GdaDataModel object.

 

col

column number.

 

Returns

the title for the given column in a data model object.


gda_data_model_set_column_title ()

void
gda_data_model_set_column_title (GdaDataModel *model,
                                 gint col,
                                 const gchar *title);

Sets the title of the given col in model .

Parameters

model

a GdaDataModel object.

 

col

column number

 

title

title for the given column.

 

gda_data_model_get_column_position ()

gint
gda_data_model_get_column_position (GdaDataModel *model,
                                    const gchar *title);

Gets the position of a column on the data model, based on the column's title.

Parameters

model

a GdaDataModel object.

 

title

column title.

 

Returns

the position of the column in the data model, or -1 if the column could not be found.


gda_data_model_get_row ()

const GdaRow *
gda_data_model_get_row (GdaDataModel *model,
                        gint row);

Retrieves a given row from a data model.

Parameters

model

a GdaDataModel object.

 

row

row number.

 

Returns

a GdaRow object.


gda_data_model_get_value_at ()

const GdaValue *
gda_data_model_get_value_at (GdaDataModel *model,
                             gint col,
                             gint row);

Retrieves the data stored in the given position (identified by the col and row parameters) on a data model.

This is the main function for accessing data in a model.

Parameters

model

a GdaDataModel object.

 

col

column number.

 

row

row number.

 

Returns

a GdaValue containing the value stored in the given position, or NULL on error (out-of-bound position, etc).


gda_data_model_is_updatable ()

gboolean
gda_data_model_is_updatable (GdaDataModel *model);

Checks whether the given data model can be updated or not.

Parameters

model

a GdaDataModel object.

 

Returns

TRUE if it can be updated, FALSE if not.


gda_data_model_append_row ()

const GdaRow *
gda_data_model_append_row (GdaDataModel *model,
                           const GList *values);

Appends a row to the given data model.

Parameters

model

a GdaDataModel object.

 

values

GList of GdaValue* representing the row to add. The length must match model's column count. These GdaValue are value-copied. The user is still responsible for freeing them.

 

Returns

the added row.


gda_data_model_remove_row ()

gboolean
gda_data_model_remove_row (GdaDataModel *model,
                           const GdaRow *row);

Removes a row from the data model. This results in the underlying database row being removed in the database.

Parameters

model

a GdaDataModel object.

 

row

the GdaRow to be removed.

 

Returns

TRUE if successful, FALSE otherwise.


gda_data_model_update_row ()

gboolean
gda_data_model_update_row (GdaDataModel *model,
                           const GdaRow *row);

Updates a row data model. This results in the underlying database row's values being changed.

Parameters

model

a GdaDataModel object.

 

row

the GdaRow to be updated.

 

Returns

TRUE if successful, FALSE otherwise.


gda_data_model_append_column ()

gboolean
gda_data_model_append_column (GdaDataModel *model,
                              const GdaFieldAttributes *attrs);

Appends a column to the given data model. If successful, the position of the new column in the data model is set on col , and you can grab it using gda_field_attributes_get_position .

Parameters

model

a GdaDataModel object.

 

attrs

a GdaFieldAttributes describing the column to add.

 

Returns

TRUE if successful, FALSE otherwise.


gda_data_model_update_column ()

gboolean
gda_data_model_update_column (GdaDataModel *model,
                              gint col,
                              const GdaFieldAttributes *attrs);

Updates a column in the given data model. This results in the underlying database row's values being changed.

Parameters

model

a GdaDataModel object.

 

col

the column to be updated.

 

attrs

attributes for the column.

 

Returns

TRUE if successful, FALSE otherwise.


gda_data_model_remove_column ()

gboolean
gda_data_model_remove_column (GdaDataModel *model,
                              gint col);

Removes a column from the data model. This means that all values attached to this column in the data model will be destroyed in the underlying database.

Parameters

model

a GdaDataModel object.

 

col

the column to be removed.

 

Returns

TRUE if successful, FALSE otherwise.


GdaDataModelForeachFunc ()

gboolean
(*GdaDataModelForeachFunc) (GdaDataModel *model,
                            GdaRow *row,
                            gpointer user_data);


gda_data_model_foreach ()

void
gda_data_model_foreach (GdaDataModel *model,
                        GdaDataModelForeachFunc func,
                        gpointer user_data);

Calls the specified callback function for each row in the data model. This will just traverse all rows, and call the given callback function for each of them.

The callback function must have the following form:

gboolean foreach_func (GdaDataModel *model, GdaRow *row, gpointer user_data)

where "row" would be the row being read, and "user_data" the parameter specified in user_data in the call to gda_data_model_foreach. This callback function can return FALSE to stop the processing. If it returns TRUE, processing will continue until no rows remain.

Parameters

model

a GdaDataModel object.

 

func

callback function.

 

user_data

context data for the callback function.

 

gda_data_model_has_changed ()

gboolean
gda_data_model_has_changed (GdaDataModel *model);

Checks whether this data model is in updating mode or not. Updating mode is set to TRUE when gda_data_model_begin_update has been called successfully, and is not set back to FALSE until either gda_data_model_cancel_update or gda_data_model_end_update have been called.

Parameters

model

a GdaDataModel object.

 

Returns

TRUE if updating mode, FALSE otherwise.


gda_data_model_begin_update ()

gboolean
gda_data_model_begin_update (GdaDataModel *model);

Starts update of this data model. This function should be the first called when modifying the data model.

Parameters

model

a GdaDataModel object.

 

Returns

TRUE on success, FALSE if there was an error.


gda_data_model_cancel_update ()

gboolean
gda_data_model_cancel_update (GdaDataModel *model);

Cancels update of this data model. This means that all changes will be discarded, and the old data put back in the model.

Parameters

model

a GdaDataModel object.

 

Returns

TRUE on success, FALSE if there was an error.


gda_data_model_end_update ()

gboolean
gda_data_model_end_update (GdaDataModel *model);

Approves all modifications and send them to the underlying data source/store.

Parameters

model

a GdaDataModel object.

 

Returns

TRUE on success, FALSE if there was an error.


gda_data_model_to_comma_separated ()

gchar *
gda_data_model_to_comma_separated (GdaDataModel *model);

Converts the given model into a comma-separated series of rows.

Parameters

model

a GdaDataModel object.

 

Returns

the representation of the model. You should free this string when you no longer need it.


gda_data_model_to_tab_separated ()

gchar *
gda_data_model_to_tab_separated (GdaDataModel *model);

Converts the given model into a tab-separated series of rows.

Parameters

model

a GdaDataModel object.

 

Returns

the representation of the model. You should free this string when you no longer need it.


gda_data_model_to_xml ()

gchar *
gda_data_model_to_xml (GdaDataModel *model,
                       gboolean standalone);

Converts the given model into a XML representation.

Parameters

model

a GdaDataModel object.

 

standalone

whether ...

 

Returns

the representation of the model. You should free this string when you no longer need it.


gda_data_model_to_xml_node ()

xmlNodePtr
gda_data_model_to_xml_node (GdaDataModel *model,
                            const gchar *name);

Converts a GdaDataModel into a xmlNodePtr (as used in libxml).

Parameters

model

a GdaDataModel object.

 

name

name to use for the XML resulting table.

 

Returns

a xmlNodePtr representing the whole data model.


gda_data_model_add_data_from_xml_node ()

gboolean
gda_data_model_add_data_from_xml_node (GdaDataModel *model,
                                       xmlNodePtr node);

Adds the data from a XML node to the given data model.

Parameters

model

a GdaDataModel.

 

node

a XML node representing a <data> XML node.

 

Returns

TRUE if successful, FALSE otherwise.


gda_data_model_get_command_text ()

const gchar *
gda_data_model_get_command_text (GdaDataModel *model);

Gets the text of command that generated this data model.

Parameters

model

a GdaDataModel.

 

Returns

a string with the command issued.


gda_data_model_set_command_text ()

void
gda_data_model_set_command_text (GdaDataModel *model,
                                 const gchar *txt);

Sets the command text of the given model .

Parameters

model

a GdaDataModel.

 

txt

the command text.

 

gda_data_model_get_command_type ()

GdaCommandType
gda_data_model_get_command_type (GdaDataModel *model);

Gets the type of command that generated this data model.

Parameters

model

a GdaDataModel.

 

Returns

a GdaCommandType.


gda_data_model_set_command_type ()

void
gda_data_model_set_command_type (GdaDataModel *model,
                                 GdaCommandType type);

Sets the type of command that generated this data model.

Parameters

model

a GdaDataModel.

 

type

the type of the command (one of GdaCommandType)

 

Types and Values

GdaDataModelPrivate

typedef struct _GdaDataModelPrivate GdaDataModelPrivate;