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

  • From: Jeff McClintock <jeffmcc@xxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Tue, 08 Feb 2005 08:46:21 +1300


Re the dll Abstract Factory.

Cheers to Tim and Angus, here's a possible implementation.. please rip this to pieces ( constructively criticize )

Angus said:
The single entry point should return a master object which provides functions for, at a minimum:-
- Enumerating the plugin-classes this DLL can instantiate. Could be as simple as passing in an index, the enumerate function returns either a class-id, or null to mean "no more".
- Instantiating a specific plug-in (pass the class-identifier as an argument, returns an interface-pointer to the newly created instance)



let's call it:

class GMPI_Plugin_Factory
{
  void GetMetaData( int index, gmpi_descriptor *gd );
  GMPI_Plugin *Instantiate( int index );
};

..where gmpi_descriptor describes the plugin...

struct gmpi_descriptor
{
  char *unique_identifier;
  char *name;
  //etc
};

Notes: I've modified Tim's idea a little to separate metadata from instantiation. This is a nod to the external metadata camp, and at least makes it easy to switch to external metadata later, or for the plugin to read it from an external file if nesc.


..So the dll has a single exported function..

extern "C" {
__declspec (dllexport)

IGMPI_Plugin_Factory *GetPluginFactory(void)
{
  static GMPI_Plugin_Factory factory;
  return &factory;
}
}

Notes: factory is implemented as a Meyer's singleton. I've assumed we're using a COM-like technique whereby we can deal in C++ objects without worrying too much about the underlying plain C binary interface.

and finally,

GMPI_Plugin's 'interface' is defined as a pure abstract base class. This is all the host ever 'sees' to hide the internal details..

class IGMPI_Plugin
{
  virtual void placeholder1(void) = 0;
  virtual void placeholder2(void) = 0;
};

...and the 'real' concrete plugin base class that we base our plugins on..

class GMPI_Plugin : public IGMPI_Plugin
{
  virtual void placeholder1(void){};
  virtual void placeholder2(void){};
};

Notes: IGMPI_Plugin should probably include the standard 'COM stuff' too..

have at it...

Jeff


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