QOF and child objects

Derek Atkins warlord at MIT.EDU
Tue May 3 13:27:18 EDT 2005


Quoting Neil Williams <linux at codehelp.co.uk>:

> it's not easy to grep for a QOF parameter - it gets hidden behind 
> param_getfcn(). Yes, you can call the function directly but that's not the 
> point - I wasn't ever going to replace the function, just replace the 
> parameter.

True, but you can query for the #define to see if/where it's used in the code. 
In particular you can try grepping for "OWNER" :)

[snip]
> Agreed, it's just finding it.
> 
> The invoice (or whatever else is using GncOwner) just needs to tell me what 
> kind of Owner it has, as a parameter. A string is the obvious choice - use 
> the e_type?

The GncOwner XML code does exactly this....

> > Effectively GncOwner is just a QofEntity with a limited range of values. 
> 
> But a QofEntity is an instance, QofObject is the definition and that's the 
> basis of the tables.

True, but GncOwner is effectively a QofEntity, which was sort of my point.  All
it does is say that the contained object is of type X with guid Y.

I think we can solve that if we have a new type of core QofClass (or QofObject
-- I keep forgetting the terms) that is basically just a container class.  It's
effectively a special QOF type that contains other QofClasses.  When you output
a "reference" to this container class you get back a tuple: <container name,
contained type, guid>.

This way you have one "special case" in QOF (for the Container class) and the
application can define the "allowed" contained types for each specified
container class.  This container class is NOT a first class object; it boils
down to two (or three?) SQL columns (type and guid, clearly) and a simple
embedded XML reference (type and guid).

Then you just need to treat this container class the same way you'd treat a
string ;)

> I've looked at changing QofObject a couple of times and each time I've found
> a better solution.
> 
> > So perhaps the right way to fix this is make a QofLimitedEntity type that
> > has a limit of the types of objects and have QoF treat the LimitedEntity
> as
> > a special type in the I/O routines?  Then we can recode GncOwner as a
> > QofLimitedEntity<Customer,Vendor,Employee> (to use a C++ term).
> 
> I'll have a think on that. It looks a lot like an enum actually.

Indeed.  Except it's a programatic enum instead of a counter enum.  You can
think of it sort of like a C++ template where the application defines the set
of contained object types for each container type and QOF can enforce that for
you.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available



More information about the gnucash-devel mailing list