Backend customisation and be->price_lookup
linux at codehelp.co.uk
Thu Sep 22 08:07:03 EDT 2005
As well as backend configuration options, there is an evident need to remove
GnuCash-specific backend handlers from QofBackend in a way that abstracts the
functionality and allows other applications to use their own customised
handlers in their backends.
e.g. The GnuCash version of QofBackend includes price_lookup which is
evidently unsuitable for a generic library like QOF which knows nothing of
prices. Equally, some other QOF application may want similar functionality -
although I've no idea what just now.
be->price_lookup is already highlighted as needing replacement:
/** XXX price_lookup should be removed during the redesign
* of the SQL backend... prices can now be queried using
* the generic query mechanism.
Until that happens, I propose to use backend_extensions - a new GHashTable -
to provide the link between the backend customised function and the
static const char* lookup_func = "GNCPriceLookupID";
void (*price_lookup) (QofBackend *, GNCPriceLookup *);
price_lookup = qof_backend_extension(lookup_func);
The hashtable will be populated by QofBackendProvider when it calls the init
function of the particular backend. This way, the number, type and IDstring
of all backend extensions are entirely determined by the backend in use.
Those routines that use the extensions simply attempt a lookup - using the
same string - and receive a NULL if the current backend does not support the
function with the IDstring requested.
This will be implemented in CashUtil initially before being incorporated into
the main QOF library sometime after QOF 0.6.0 is on full release (possibly in
Those backends that set price_lookup or export would stop using
be->price_lookup and instead register the extension in their
QofBackendProvider init function using:
void qof_backend_extension_add(char *IDstring, gpointer data);
where IDstring is the static char* that the application uses to locate the
function and data is a gpointer to the function itself.
Note that this does mean that the extension is only registered once - when the
backend GModule is first loaded, usually at application startup. Backends can
either use more than one extension for different circumstances or modify
their existing functions (and maybe prototypes) to use a status flag of some
be->price_lookup is only currently available within the GnuCash tree and will
be unusable once QOF is spun out as an external library, hence the new
Alternatively, can price_lookup be dropped and a generic (QofQuery) query used
Are there any implications for Finance::Quote?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20050922/59d56f87/attachment.bin
More information about the gnucash-devel