[gmpi] Prototype Plugin Code

  • From: Jeff McClintock <jeffmcc@xxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Tue, 15 Feb 2005 14:13:35 +1300

Just one small point about COM (or whatever). COM is the low level below the C++. As a plugin developer, you will not be exposed to it.

For example, below is the actual Prototype plugin code.

To make your own plugin:
- Derive from class GIMPI_Plugin.
- Provide a function to create an instance of your plugin.
- Register your plugin with the factory (that's the bit inside "namespace").

There are no other files to edit. You do not edit the factory class at all. You do not deal directly with COM. Very clean.

--------------header----------
#include "plugin.h"

class Prototype_Plugin : public GMPI_Plugin
{
public:
/* create function */
static GMPI_RESULT GMPI_STDCALL CreateInstance( GMPI_GUID *id, void **object );


        /* test function */
        virtual GMPI_RESULT GMPI_STDCALL Placeholder1( int32_t);
};

--------------cpp-------------

#include "test_plugin.h"
#include "factory.h"

/* Plugin unique ID */
/* IID vs URI undecided. For now using GUID */

static const GMPI_GUID IID_GMPI_Prototype_DSP =
{ 0x5cc85cad, 0xdc0c, 0x42c2, { 0x80, 0xfd, 0xdc, 0x3a, 0xdb, 0xc7, 0x6, 0x41 } };


/* register plugin ID and creation function with factory */
namespace
{
GMPI_RESULT r = Factory()->RegisterPlugin( &IID_GMPI_Prototype_DSP, Prototype_Plugin::CreateInstance );
}


/* instantiate a new plugin, return it's interface to the host */
GMPI_RESULT Prototype_Plugin::CreateInstance( GMPI_GUID *id, void **object)
{
    Prototype_Plugin *plugin = new Prototype_Plugin();
    if (plugin == 0)
    {
        return GMPI_FAIL;// E_OUTOFMEMORY;
    }

    return plugin->QueryInterface(id , object);
}

GMPI_RESULT Prototype_Plugin::Placeholder1( int32_t)
{
    return GMPI_SUCCESS;
}


---------------------------------------------------------------------- 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: