QOF Book Merge design issues

Christian Stimming stimming at tuhh.de
Sun Dec 5 14:41:46 EST 2004


Neil,

Just a quick remark in between -- please please please follow Derek's advice 
and do NOT keep your data in static storage!

Am Sonntag, 5. Dezember 2004 17:06 schrieb Derek Atkins:
> >> You really need to have a "merge context" that gets created when you
> >> initialize the merge process and contains all the state of the merge.
> >
> > Can that be global or does it have to be passed to and fro with every
> > single function? Do I have to return a qof_book_mergeData* from Init,
> > pass it to qof_book_mergeUpdateResult and redefine the entire
> > qof_book_mergeRuleForeachCB callback then pass mergeData back to Commit?
>
> It needs to be passed to and fro with every function.  So, yes, that's
> what you need to do.  

Absolutely. I totally agree with Derek here. If you have some context in your 
operation, you should absolutely keep it in a separate structure, of which a 
pointer will need to be passed to and from with every function. That's how 
things work in C. 

In e.g. C++, you would hold your functions inside an object, which internally 
means just that -- every function gets passed the "this" pointer, which is 
the structure that keeps the context. 

This way, there is no internal problem if at any point in the future someone 
wants to use your code for multiple parallel application sessions, just as 
Derek pointed out.

Christian



More information about the gnucash-devel mailing list