[gmpi] Re: low level API - Abstract Factory summary

  • From: David Olofson <david@xxxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Fri, 11 Feb 2005 01:58:54 +0100

Then there's this variant, which simply doesn't bother with the 
'struct <something>' part at all;

typedef struct
{
        struct IGMPI_PluginVtbl *Vtbl;
} IGMPI_Plugin;


As I understand it, this should be legal for the same reason that you 
can generate an "instance" of some type without giving the type a 
name, as in

        struct {
                int x;
                int y;
        } position;

The typedef syntax essentially shifts things one step, so you define a 
type where you'd normally generate an instance.


Either way, I've been using it for quite some time on various 
platforms with various compilers - even an old Borland compiler for 
DOS - without problems. :-)


Anyway, full version:
-----------------------------------------------------------
/*
 * GMPI_Plugin interface
 */

typedef struct
{
        /* IUnknown methods */
#ifdef MACOSX
        /* Part of COM binary standard on Mac */
        void *_reserved;
#endif
        GMPI_RESULT (*QueryInterface)(IGMPI_Plugin *,
                        GMPI_GUID *, void **);
        int32_t (*AddRef)(IGMPI_Plugin *);
        int32_t (*Release)(IGMPI_Plugin *);

        /* IGMPI_Plugin methods */
        int32_t (*Placeholder1)(IGMPI_Plugin *, int32_t);
        int32_t (*Placeholder2)(IGMPI_Plugin *, int32_t *);
} IGMPI_PluginVtable;

typedef struct
{
        IGMPI_PluginVtable *Vtable;
} IGMPI_Plugin;
-----------------------------------------------------------


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---

----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: