Re: Callbacks (Was: Some activity and a new LibOfx)
ryan p bobko <[email protected]>
| Newsgroups | gmane.comp.finance.libofx.devel |
|---|---|
| Organization | ostrich emulators |
| Message-ID | <[email protected]> |
All right, I've committed the changes. The changes are significant, so here's a brief introduction. The CallbackRegistry structure has been expanded to include a void pointer for each callback function. The ofx_prep_cb function has also been expanded to include arguments for setting that void *, but these arguments can be null if desired. When the callback is executed, the void * from the registry is sent as the second argument. This allows a user to pass arbitrary information to the recipient of the callback, as well as the ofx data that was previously sent. I also made the suggested changes below. I named the arguments XXX_data where XXX is status, security, et. al. I hope that's okay. ry On Sunday 18 January 2004 17:50, Benoit Grégoire wrote: > 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! -- In theory, there is no difference between theory and practice. In practice, there is. ------------------------------------------------------- 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