[QOF-devel] Outline of new qofevent support

Derek Atkins warlord at MIT.EDU
Tue Feb 21 00:07:56 EST 2006


Actually, I just thought of something..  I'd like to have events that
have both subject AND object..  Right now we just have a Subject +
Verb (QofEntity + QofEventId).  I'd like to add an object, too, so we
could have an event Subject + Verb + Object (QofEntity + QofEventId +
gpointer).   The generator and consumer of the QofEventId need to
agree on what the object of the event is.

Use case:  In GnuCash I want to emit an event when a new Split is added
or removed from an Account.  Therefore I'd like to emit the tuple:

   <Account*,Add_Split,Split*>  or
   <Account*,Del_Split,Split*>

Unfortunately I cannot do that in the current QofEvent framework.
Could we add a second set of APIs that parallel the existing set
that let me pass an extra object back to the event handler?

I'd propose:

  typedef void (*QofEventHandlerWithArg)(QofEntity*, QofEventId, gpointer);
  void qof_event_add_handler_with_arg(QofEventHandlerWithArg);
  void qof_event_del_handler_with_arg(QofEventHandlerWithArg);
  void qof_event_with_arg(QofEntity*, QofEventId, gpointer);

I admit this would be a LOT easier if QOF were based on gobject and we
used g_signal...  Mea Culpa.

What do you think?

-derek

Neil Williams <linux at codehelp.co.uk> writes:

> On Monday 20 February 2006 3:42 pm, Neil Williams wrote:
>
> Update:
>
>> 3. A new handler prototype is added: QofEventHandler:
>> typedef void(* QofEventHandler)(QofEntity *ent, QofEventNameConst
>> event_type, gpointer user_data) where QofEventNameConst is a const gchar*.
> Modified:
> typedef void (*QofEventHandler) (QofEntity *ent,  QofEventId event_type,
>  gpointer user_data); where typedef gint QofEventId;
>
> This makes for easier comparisons.
>
>> Although the added names will be available via a foreach,
>
> (removed the iteration - not needed)
>
>> 4. New events are added as simple strings using void
>> qof_event_add_name ( QofEventNameConst new_event_name ) at any time prior
>> to generating an event using that name.
>
> (removed need for pre-registration)
>
>> Testing continues and then I'll make a QOF 0.6.2 release.
>
> continuing....

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list