Top |
struct | GdaDataComparator |
struct | GdaDataComparatorClass |
GdaDataComparatorPrivate | |
GdaDiff | |
enum | GdaDiffType |
The GdaDataComparator is a simple object which takes two GdaDataModel objects and compare them.
Actual comparison is performed when the gda_data_comparator_compute_diff()
is called; for each
difference found, the diff-computed signal
is emitted (any user installed signal handler which returns FALSE stops the computing process).
There are some limitations to this object:
The data models compared must have the same number and type of columns
The comparison is done column-for-column: one cannot omit columns in the comparison, nor compare columns with different positions
GObject * gda_data_comparator_new (GdaDataModel *old_model
,GdaDataModel *new_model
);
Creates a new comparator to compute the differences from old_model
to new_model
: if one applies
all the computed differences (as GdaDiff structures) to old_model
, the resulting data model
should have the same contents as new_model
.
void gda_data_comparator_set_key_columns (GdaDataComparator *comp
,const gint *col_numbers
,gint nb_cols
);
Defines the columns which will be used as a key when searching data. This is not mandatory but will speed things up as less data will be processed.
comp |
a GdaDataComparator object |
|
nb_cols |
the size of the |
|
col_numbers |
an array of |
[array length=nb_cols] |
gboolean gda_data_comparator_compute_diff (GdaDataComparator *comp
,GError **error
);
Actually computes the differences between the data models for which comp
is defined.
For each difference computed, stored in a GdaDiff structure, the "diff-computed" signal is emitted. If one connects to this signal and returns FALSE in the signal handler, then computing differences will be stopped and an error will be returned.
gint
gda_data_comparator_get_n_diffs (GdaDataComparator *comp
);
Get the number of differences as computed by the last time gda_data_comparator_compute_diff()
was called.
const GdaDiff * gda_data_comparator_get_diff (GdaDataComparator *comp
,gint pos
);
Get a pointer to the GdaDiff structure representing the difference which number is pos
struct GdaDataComparator { GObject object; GdaDataComparatorPrivate *priv; };
struct GdaDataComparatorClass { GObjectClass parent_class; gboolean (* diff_computed) (GdaDataComparator *comp, GdaDiff *diff); };
typedef struct { GdaDiffType type; gint old_row; gint new_row; GHashTable *values; /* key = ('+' or '-') and a column position starting at 0 (string) * value = a GValue pointer */ } GdaDiff;