first draft of a merge rule set

Linas Vepstas linas at
Wed Apr 14 11:58:03 EDT 2004

On Wed, Apr 14, 2004 at 11:21:20AM -0400, Derek Atkins was heard to remark:
> linas at (Linas Vepstas) writes:
> > Found it.
> >
> > The qof engine should get a function that allows the caller
> > to ask for all of the parameters in an object.  The user
> > can then loop over all of the paramaters and do whatever math 
> > is desired, such as comparing strings, dates, amounts.
> >
> > I would not want the compare func in the engine (at this time),
> > put it in the gui/druid directory. 
> Well, I was more thinking that each object would have its own compare
> function, so that the gui/druid doesn't have to implement one for each
> object (or even KNOW about each object).

yeah, I guess ... that's OK. I dunno. maybe not.   But a good baseline 
would be purely automated algo like so:

int get_distance (QofEntity *a, QofEntity*b)
   if (a->e_type != b->etype) return 10000000000;

   int total_difference = 0;

   GList * n = gof_class_get_params(a->e_type);
   for (n; n->next) {
      QofParam *p = n->data;
      swithc (p->type) {
        case OQF_INT32:
           int pa = p->param_getfcn (a);
           int pb = p->param_getfcn (b);
           if (pa != pb) total_difference ++;
        case QOF_STRING: ...
           char * sa = p->param_getfcn (a);
           // whitespace
           // strcasecmp .. 
   return total_difference;

Then, if you want to have a per-object compare func, you
could do that too ... but by default, you'd probably want
to work with this baseline.  If need be, each object type 
could tweak the baseline if needed.

But I'm thinking that the above function might be engough
to be pretty damn good in general, without needing per-object

Let me be direct: first thing should probably be to download
qof from add the gof_class_get_params() func, 
and then implement the get_distance() function as example
source code in the qof examples directory.  Then go from there.

I dunno, I guess we could add an object-distance metric as 
a core part of qof objects, as a per-object class function ...

I'll assist in merging tweaking fixing qof as needed to make
the above reasonably smooth.

pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas at>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933

More information about the gnucash-devel mailing list