[AD] object oriented AL_SYSTEM

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


How would a base structure like below look?

struct AL_SYSTEM_DRIVER
{
   ...variables + methods
};

struct AL_SYSTEM
{
   AL_SYSTEM_DRIVER *driver;
   ... variables
};

... for each driver XXX
struct AL_SYSTEM_XXX
{
   AL_SYSTEM *system;
   ... variables
}

They would all be internal and no members accessed by the user.

The first struct would be just like the current SYSTEM_DRIVER - i.e. the
"interface" or "vtable". We didn't decide yet what features we want from
that (there's still
http://awiki.tomasu.org/bin/view/Main/ProposedVTables ).

The second struct would be an object to hold all the system specific
global variables, e.g. things like the detected CPU capabilities and
whatever else is now in global variables floating around.

The last struct would be a driver specific version of AL_SYSTEM, which
could be cast to it. It would be created somewhere in al_init, something
like:

AL_SYSTEM *_al_create_system(AL_SYSTEM_DRIVER *driver)
{
   system = driver->create_system(driver);
   ... initialize platform independent stuff in system
   return system;
}

And driver->create_system might be:

AL_SYSTEM *_al_create_system_x11(AL_SYSTEM_DRIVER *driver)
{
   AL_SYSTEM_X11 *system = _AL_MALLOC(sizeof *system);
   ... initialize driver specific stuff in system
   return (AL_SYSTEM *)system;
}

The advantage I see in it is that we don't need internal global
variables floating around so much. Especially under X11, the _xwin
struct could go into the created AL_SYSTEM_X11 object.

-- 
Elias Pschernig





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