Re-working GNCId: removing GNCIdType enum

Derek Atkins warlord@MIT.EDU
24 Nov 2001 19:19:23 -0500


Dave Peticolas <dave@krondo.com> writes:

> With extendable types, switch statements would have to
> mostly go away, since they imply a fixed number of types.
> I think we would use hash tables instead, which at least
> gives you only about one strcmp.
> 
> 
> > Instead, I think I just want to use a guint32 and let modules
> > choose their own (unique) type-value (as opposed to their
> > own unique type-string).
> >=20
> > Do you have a preference of strings vs. integers?
> 
> I think we should either have strings or dynamically-assigned
> integers like the gtk type system uses. Statically-assigned
> integers are not so nice, unless they are mechanically assigned
> like an enum. Personally, I prefer strings.

Ok, strings it is, then.  Do you have a proposal for how to
handle the various 	switch (type_id) { }   cases throughout
the code?  In particular, there are major switches in:

app-utils/gnc-component-manager.c
backend/postgres/events.c
backend/postgres/gncquery.c
engine/Query.c
gnome/top-level.c

Not to mention a bunch of equality tests elsewhere that will
need to be "fixed".

If you have a proposal for how to handle these "switch" statements
I'd greatly appreciate the input.  I'm not sure how a hashtable
helps in these cases.

-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@MIT.EDU                        PGP key available