The Plug-in System

group PluginSystemGrp

This system provides the framework for retrieving plug-ins from custom built libraries.

To implement a plug-in:

  • Decide on the API to use, and include the appropriate header

  • Implement the getPlugins() function (of type FnGetPluginsFunc)

  • Make your getPlugins() return a FnPlugin structure with appropriate API identifiers from the headers

  • Implement the functions required by the API, and return them in the appropriate structure in your plug-in’s getSuite() function

  • Build

  • Copy (or symbolic-link) the library into the application’s custom plug-ins folder

  • Start the application, and check that your plug-in has loaded correctly

Defines

FNPLUGINSTATUS_DEFINED
FNPLUGINHOST_DEFINED
FNPLUGIN_DEFINED

Typedefs

typedef FnPluginStatus FnPlugStatus

Alias of FnPluginStatus.

typedef FnPlugin *(*FnGetPluginsFunc)(unsigned int *numPlugins)

Returns a list of plug-ins provided by a plug-in library.

 FnPlugin *getPlugins(unsigned int *numPlugins); 

This is the only externally-visible function that must be implemented by every plug-in library.

Parameters

numPlugins – Write the number of plug-ins provided by the library here. The pointer will not be NULL.

Returns

A pointer to an array of plug-in structures, or NULL if none are supported

Enums

enum FnPluginStatus

The return status of some of the Plug-in System functions.

Values:

enumerator FnPluginStatusOK
enumerator FnPluginStatusError
struct FnPluginHost
#include <FnPluginSystem.h>

The basic host information that will be provided to a plug-in by setHost().

Public Members

const void *(*getSuite)(const char *apiName, unsigned int apiVersion)

Returns a pointer to the host’s function suite for the given API.

Parameters
  • apiName – The name of the API that the host implements

  • apiVersion – The integer version of the API that the host implements

Returns

A pointer to the host’s function suite for the given API if successful, or NULL otherwise.

const char *name

The name of the host application.

const char *versionStr

A string description of the application version number (e.g. “1.4v1”)

unsigned int versionInt

An integer version number for easy comparison (e.g., “1.2” could be 12 or 102)

struct FnPlugin
#include <FnPluginSystem.h>

The basic plug-in information that must be returned from a call to getPlugins().

Public Members

const char *name

A descriptive name for the plug-in.

const char *apiName

The string name of the API supported by this plug-in.

unsigned int apiVersion

The integer version of the API supported by this plug-in.

unsigned int pluginVersionMajor

The major version of a plug-in changes when a new incompatible version is released.

unsigned int pluginVersionMinor

The minor version of a plug-in changes on small, but compatible, updates.

FnPluginStatus (*setHost)(FnPluginHost *host)

The host will call this on the plug-in to provide its details and check for acceptance.

Parameters

host – Basic information about the host, for identification and access to the host function suite

Returns

FnPluginStatusOK if the plug-in accepts the host, or FnPluginStatusError if not

const void *(*getSuite)()

The plug-in must implement this to return its suite of functions that implements the API it supports.

Returns

A pointer to a suite of functions in a structure, according to the API

void (*flush)()

The host will call this to clean up any plug-in information before unloading the library.