Callbacks (Was: Some activity and a new LibOfx)

Benoit Grégoire <[email protected]>
Newsgroups gmane.comp.finance.libofx.devel
Message-ID <[email protected]>
On Sunday 18 January 2004 10:35, ryan p bobko wrote:
> Hi Everyone,
> I'm not sure what the procedure is for applying patches, so I thought I'd
> give a quick heads-up on the work I've been doing on the library before
> committing anything. I've included a patch in this email that extends the
> callback registry a bit, but it also changes the prototypes of the various
> callback functions.

As there is no CVS commit mailing list (anyone know how to set one up an 
sourceforge?), the "procedure" is to write good Changelog entries (not just 
in CVS, in the ChangeLog file also) and to send a email here if the change is 
significant.  A pach isn't needed unless the focus of your message if for 
people to review the changes.

> Quick background: I'm a C++ developer, and I'd like to be able to use
> libOFX in a class I've built with as little reliance on global variables as
> possible. I just want to be able to assign arbitrary callbacks to the
> events that get thrown.
>
> To accomplish this, I added the callback registry, but that really only got
> me halfway there. I also need to be able to specify the instance of my
> object that can handle the callback, so I added a void * for each function
> pointer in the registry, and changed the prototypes of the functions to
> accept a void * in addition to the Ofx data structure they each receive. I
> changed the ofx_container_* files to pass the void * from the registry to
> the callback as the first argument. This way, not only can the callbacks
> handle data, they can use it to change particular structures/classes/other
> functions.
>
> If there are no objections, I'd like to commit these changes. I'm open to
> other ideas on accomplishing my goal, too.

Your approach is correct, we definitely need a void * pointer to be passed to 
the callback for it to be usefull.  However I do have a few stylistic 
nitpicks:

1- As the parameter is "optionnal" (can be NULL), I think it should be the 
last parameter, not the first.  But that's not very important.
2- You named it o (presumably for object).  That's inacurate and not very 
descriptive.  Is suggest naming it user_data (like in gnome), as it could be 
a pointer to anything (a structure, a function, an object, a GUI element, 
whatever).
3- Please pass NULL, not 0 when it isn't used.

Again, thanks for your work!
-- 
Benoit Grégoire, http://step.polymtl.ca/~bock/


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.