Re: [AD] Allegro 5 new config routines, alpha 1

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On vie, feb 08, 2002 at 10:41:00 -0000, Vincent Penquerc'h wrote:
> > > - i would add a pointer type (would obviously not be read/written
> > >   from/to disk, but done at run time by the user).
> > 
> > Are you thinking what I think you're thinking?  With it, We wouldn't
> > need to support multiple userdata fields in structures: simply use the
> > address of the structure in the key, e.g. "/myapp/0xbeefcafe/prop". A
> > userdata field in BITMAPs would still be good (maybe to cache the key
> > name?), but most other structures can probably do without.
> 
> More or less. I saw this as an opportunity to offer the user a simple
> hash table API, the only problem being that the actual hashing might
> need users to supply their own hash function, as hashing pointers
> might not be optimal (and you couldn't hash to the same value different
> pointers pointing to semantically equal objects). Could be used for
> this extra field, but for anything else that might require hashes.

Maybe a ID field. So we could use:

enum { ID_MYVAR1, ID_MYVAR2 };

void my_hook(AL_CONST char *name, int id)
{
  switch (id) {
    ...
  }
}

main()
{
  al_set_bool("dir/myvar1", TRUE);
  al_set_bool("dir/myvar2", FALSE);
  al_set_varid("dir/myvar1", ID_MYVAR1);
  al_set_varid("dir/myvar1", ID_MYVAR2);
  al_set_read_hook("dir", my_hook);
}

-- 
David A. Capello
dacap@xxxxxxxxxx
http://www.davidcapello.com.ar



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/