Re: [gnome-db] gda_data_model_import_from_model ()





2009/7/20 Massimo Cora' <maxcvs email it>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi Vivien,

Vivien Malerba wrote:
>
>
> What you can do is create a new empty GdaDataModel and fill it with the
> 2 data models you have. To create a new empty data model, use
> gda_data_model_array_new() or gda_data_model_array_new_with_g_types()
> and then
>
> gda_data_model_import_from_model (new_model, to);
> gda_data_model_import_from_model (new_model, from);
>
> where to and from are your 2 data models you mentionned. This has the
> drawback of consuming more memory as data is being copied to the new
> data model.


yep, this works good.

>
> Another solution is to create a new object which implements the
> GdaDataModel interface and, for each virtual method to be implemented,
> calls the same virtual method of the concatenated data models (I suppose
> they have the same number of columns and column types). This is fairly
> simple and the most efficient approach as no data is copied. For an
> example of this kind of approach, look at the gda-data-meta-wrapper.h
> and gda-data-meta-wrapper.c files which implement a GdaDataModel
> interface which transforms some values of another data model.
>

this kind of solution was more attracting. I've implemented a
GdaDataModelConcat class, on which you can append more models and access
them by row number. Everything was working until I encountered another
problem: the GdaDataModelIter. In my current application setup I'm using
it to browse the model's records and, being the GdaDataModelIter not an
interface, I'm afraid that I cannot maintain the same naming to iter
through the GdaDataModelConcat records.
More: I don't see a method, analyzing gda-data-model-iter.[c|h], to
switch on the fly the underlying model.

There is no reason the default GdaDataModel iter's implementation should not work. Can you send me a standalone version of your code so I can try to figure out what the problem is?

Anyway, even though the GdaDataModelIter is not an interface, you can still subclass it if you need, and then implement the GdaDataModel::i_create_iter method to instanciate your own GdaDataModelIter.

Vivien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]