QofSetterFunc
Neil Williams
linux at codehelp.co.uk
Sun Jul 25 05:29:05 EDT 2004
On Sunday 25 July 2004 12:23, Linas Vepstas wrote:
> On Sat, Jul 24, 2004 at 07:48:57PM +0100, Neil Williams was heard to remark:
> > I see that most qof_class_register calls set a NULL in place of the
> > possible QofSetterFunc. I couldn't find a single (QofSetterFunc) with a
> > grep of src/ but maybe that's just me.
> :) its a place holder, haven't gotten around to filling it in.
> > Or just that nobody had a
> > use for them, yet?
> Yes.
> > Can I change each qof_class_register section to use appropriate Set
> > functions, where they exist?
> Yes.
OK. There are, naturally, some QofAccessFunc routines that are simply not
suitable for a corresponding QofSetterFunc - ones that rely on calculated
balances etc.
Are your SQL needs going to be similar to the merge:
1. I don't want to compare or set fields that are calculated from other
objects, like account balances - that would corrupt the data. I'll compare /
set the actual transactions that create the total, not the total itself.
2. Same with other parameters that make no sense to set explicitly, like
qof_instance_get_book, that would be set by conventional methods (like
creating and initialising a new account using standard routines).
e.g. for Account:
gboolean xaccAccountRegister (void)
{
static QofParam params[] = {
{ ACCOUNT_NAME_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetName,
(QofSetterFunc) xaccAccountSetName },
{ ACCOUNT_CODE_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetCode,
(QofSetterFunc) xaccAccountSetCode },
{ ACCOUNT_DESCRIPTION_, QOF_TYPE_STRING,
(QofAccessFunc)xaccAccountGetDescription, (QofSetterFunc)
xaccAccountSetDescription },
{ ACCOUNT_NOTES_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetNotes,
(QofSetterFunc) xaccAccountSetNotes },
{ ACCOUNT_PRESENT_, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccAccountGetPresentBalance, NULL },
{ ACCOUNT_BALANCE_, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccAccountGetBalance, NULL },
{ ACCOUNT_CLEARED_, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccAccountGetClearedBalance, NULL },
{ ACCOUNT_RECONCILED_, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccAccountGetReconciledBalance, NULL },
{ ACCOUNT_FUTURE_MINIMUM_, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccAccountGetProjectedMinimumBalance, NULL },
{ ACCOUNT_TAX_RELATED, QOF_TYPE_BOOLEAN,
(QofAccessFunc)xaccAccountGetTaxRelated, (QofSetterFunc)
xaccAccountSetTaxRelated },
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book,
NULL },
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid,
NULL },
{ ACCOUNT_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots,
NULL },
{ NULL },
};
(might need to look at that QOF_TYPE_KVP again, maybe experiment with
kvp_frame_copy.)
This would lead to a useful check:
If param_setfcn is NULL, ignore the param_getfcn for the comparison rules.
Is that too simple.
(expected answer, Yes.)
:-))
This would allow the merge to remain generic to any new registered classes.
I'll be posting a 'makepatch' patch to cover the most obvious QofSetterFunc
functions later today.
> > (If they don't, I'll cross that bridge when I get to it!)
>
> Heh.
>
> I've converted most things to use QofEntity; I was planing on converting
> most things to actually use QofInstance (so that they would all have a
> common setter for the KVP tree, and some other common items.) Prices
> stick out like a sore thumb, and would need a major overhaul. There
> are other odds-n-ends, such as currencies.
I know, that's a problem in the merge - haven't figured that out yet.
> Since my whiz-bang SQL backend requires the setters, I was holding off
> till then ...
As we'll both be using the same setter functions, I'm hoping our needs are
similar?
> --linas
--
Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/
http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20040725/bfae4a22/attachment.bin
More information about the gnucash-devel
mailing list