Re: [AD] Custom packfiles

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


Peter Wang wrote:
I don't see how it cuts down on duplicate code. Say you're going to write a wrapper like:

   PACKFILE *load_wad_object(const char *filename, int index);

That is, of course, assuming there is that extra wrapper. There are times where it'd be better not to throw an extra wrapper around on top of Allegro, which itself is a wrapper, so the programmer would be calling pack_fopen_vtable(...) directly.

I personally am not fond of making a wrapper around Allegro routines, because Allegro routines are, themselves, wrappers. Unless you plan on supporting more than one method on top of the function in question (which is not always the best thing to do), there's no reason to abstract more than Allegro already abstracts.

Besides that, even if the vtable contains fp_fopen and fp_fclose methods, there's nothing forcing the user to make use of them.. they can just leave them NULL. However it will leave the option open for those that want to take advantage of it.

i.e. with my style pack_fopen_vtable() is only called after the rest of the opening process is complete.

I don't know. I just think if a function is going to open something, it itself should open it.. not have it "pre-opened".

> You don't have to stuff input
> arguments into a struct just to get it through to pf_fopen.

You wouldn't have to even if pf_open and pf_close existed, either (as I said, the user doesn't *have* to use it). I just think it's a nice way to organize things.




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