The problem with events, object types, and Entity storage

Derek Atkins warlord at MIT.EDU
Mon May 19 15:10:52 CDT 2003


The whole event subsystem is poorly done.  A brief description of
one particular problem:

Events are associated with GUIDs -- you create an event based just on
the GUID and event type.  An EntityTable maps GUIDs to objects and
object-types.  The EntityTable resides in a gnc-book.  When processing
an event, the component manager needs to look up the GUID in the
EntityTable to determine what _type_ it is (because the event doesn't
have that information).

Assuming you made it this far in the explanation, let's take it one
step further.  You signal an object's destruction by generating a
DESTROY event for the object's GUID.  This works fine for most object,
but what if the object is a book?  The EntityTable storing the book's
guid no longer exists, so there is no way to signal its destruction.

Also, if you have objects in different books then you cannot get event
notification on some subset.

So, my proposal is this: 

- in the short term -- modify the event subsystem to pass around
  an object type in addition to the GUID.  So, instead of an event
  being <GUID,event_type>, it would be <GUID,obj_type,event_type>.
  This should solve the immediate problem.

In the longer term, I'd like to:

- move the EntityTable from the Book into the Session, and make sure
  we pass around either a Book*, Session*, or some object from which
  we can divine the book or session.

- restructure the EntityTable a bit to hopefully improve a little
  speed for common operations.

- Change all the event interfaces to all take a session (maybe with a
  helper to take a book as well).  This way we can specify the session
  in which we want to handle events.

The assumption here is that a Book* only maps to a single Session*
(although multiple Session*'s could theoretically have the same data
store open at once).  There is no reverse assumption -- a Session*
could have multiple Book* objects.

What do people think?

-derek

-- 
       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