GdaVconnectionDataModel

GdaVconnectionDataModel — Virtual connection based on a list of GdaDataModel

Synopsis

struct              GdaVconnectionDataModel;
void                (*GdaVConnectionDataModelFunc)      (GdaDataModel *model,
                                                         const gchar *table_name,
                                                         gpointer data);
struct              GdaVconnectionDataModelSpec;
GList *             (*GdaVconnectionDataModelCreateColumnsFunc)
                                                        (GdaVconnectionDataModelSpec *Param1);
GdaDataModel *      (*GdaVconnectionDataModelCreateModelFunc)
                                                        (GdaVconnectionDataModelSpec *Param1);
gboolean            gda_vconnection_data_model_add      (GdaVconnectionDataModel *cnc,
                                                         GdaVconnectionDataModelSpec *spec,
                                                         GDestroyNotify spec_free_func,
                                                         const gchar *table_name,
                                                         GError **error);
gboolean            gda_vconnection_data_model_add_model
                                                        (GdaVconnectionDataModel *cnc,
                                                         GdaDataModel *model,
                                                         const gchar *table_name,
                                                         GError **error);
gboolean            gda_vconnection_data_model_remove   (GdaVconnectionDataModel *cnc,
                                                         const gchar *table_name,
                                                         GError **error);
const gchar *       gda_vconnection_data_model_get_table_name
                                                        (GdaVconnectionDataModel *cnc,
                                                         GdaDataModel *model);
GdaDataModel *      gda_vconnection_data_model_get_model
                                                        (GdaVconnectionDataModel *cnc,
                                                         const gchar *table_name);
void                gda_vconnection_data_model_foreach  (GdaVconnectionDataModel *cnc,
                                                         GdaVConnectionDataModelFunc func,
                                                         gpointer data);

Object Hierarchy

  GObject
   +----GdaConnection
         +----GdaVirtualConnection
               +----GdaVconnectionDataModel
                     +----GdaVconnectionHub

Description

the GdaVconnectionDataModel is a virtual connection in which GdaDataModel data models can bas added or removed, each representing a table in the connection.

Note that virtual connections have some inherent limitations [2]due to the implementation.

Details

struct GdaVconnectionDataModel

struct GdaVconnectionDataModel;


GdaVConnectionDataModelFunc ()

void                (*GdaVConnectionDataModelFunc)      (GdaDataModel *model,
                                                         const gchar *table_name,
                                                         gpointer data);


struct GdaVconnectionDataModelSpec

struct GdaVconnectionDataModelSpec {
	GdaDataModel                             *data_model;
	GdaVconnectionDataModelCreateColumnsFunc  create_columns_func;
	GdaVconnectionDataModelCreateModelFunc    create_model_func;
};


GdaVconnectionDataModelCreateColumnsFunc ()

GList *             (*GdaVconnectionDataModelCreateColumnsFunc)
                                                        (GdaVconnectionDataModelSpec *Param1);


GdaVconnectionDataModelCreateModelFunc ()

GdaDataModel *      (*GdaVconnectionDataModelCreateModelFunc)
                                                        (GdaVconnectionDataModelSpec *Param1);


gda_vconnection_data_model_add ()

gboolean            gda_vconnection_data_model_add      (GdaVconnectionDataModel *cnc,
                                                         GdaVconnectionDataModelSpec *spec,
                                                         GDestroyNotify spec_free_func,
                                                         const gchar *table_name,
                                                         GError **error);

Create a new virtual table named table_name in cnc. The contents of that new table is dictated by what's in spec.

If there is just one GdaDataModel to make appear as a table then the gda_vconnection_data_model_add_model() method is easier to use.

cnc :

a GdaVconnectionDataModel connection

spec :

a GdaVconnectionDataModelSpec structure

spec_free_func :

function to call when freeing spec, or NULL

table_name :

the name of the table

error :

a place to store errors, or NULL

Returns :

TRUE if no error occurred

gda_vconnection_data_model_add_model ()

gboolean            gda_vconnection_data_model_add_model
                                                        (GdaVconnectionDataModel *cnc,
                                                         GdaDataModel *model,
                                                         const gchar *table_name,
                                                         GError **error);

Make model appear as a table named table_name in the cnc connection (as if a "CREATE TABLE..." statement was executed, except that the data contained within model is actually used when table_name's contents is read or written).

For a more general approach, see the gda_vconnection_data_model_add() method.

cnc :

a GdaVconnectionDataModel connection

model :

a GdaDataModel

table_name :

the name of the table

error :

a place to store errors, or NULL

Returns :

TRUE if no error occurred

gda_vconnection_data_model_remove ()

gboolean            gda_vconnection_data_model_remove   (GdaVconnectionDataModel *cnc,
                                                         const gchar *table_name,
                                                         GError **error);

Remove the table named table_name in the cnc connection (as if a "DROP TABLE..." statement was executed, except that no data gets destroyed as the associated data model remains the same).

cnc :

a GdaVconnectionDataModel connection

table_name :

the name of the table to remove from cnc

error :

a place to store errors, or NULL

Returns :

TRUE if no error occurred

gda_vconnection_data_model_get_table_name ()

const gchar *       gda_vconnection_data_model_get_table_name
                                                        (GdaVconnectionDataModel *cnc,
                                                         GdaDataModel *model);

Find the name of the table associated to model in cnc

cnc :

a GdaVconnectionDataModel connection

model :

a GdaDataModel representing a table within cnc

Returns :

the table name, or NULL if not found

gda_vconnection_data_model_get_model ()

GdaDataModel *      gda_vconnection_data_model_get_model
                                                        (GdaVconnectionDataModel *cnc,
                                                         const gchar *table_name);

Find the GdaDataModel object representing the table_name table in cnc

cnc :

a GdaVconnectionDataModel connection

table_name :

a table name within cnc

Returns :

the GdaDataModel, or NULL if no table named table_name exists

gda_vconnection_data_model_foreach ()

void                gda_vconnection_data_model_foreach  (GdaVconnectionDataModel *cnc,
                                                         GdaVConnectionDataModelFunc func,
                                                         gpointer data);

Call func for each GdaDataModel represented as a table in cnc.

cnc :

a GdaVconnectionDataModel connection

func :

a GdaVConnectionDataModelFunc function pointer

data :

data to pass to cunc calls

See Also

The GdaVproviderDataModel provider to use to create such connection objects.



[2] As virtual connections are implemented using SQLite's virtual table features, the SQL dialect which can be used is the SQLite one (see the SQL as Understood By SQLite page), and there are a few limitations inherent to this implementation (see link for more information).

Also note that it is possible to create temporary tables in virtual connections using "CREATE TEMP TABLE..." statements, but the contents of such tables will be lost once the connection is closed.