gwymoduleloader

gwymoduleloader — Basic module loader interface

Synopsis




#define     GWY_MODULE_ABI_VERSION
#define     GWY_MODULE_QUERY                (mod_info)
struct      GwyModuleInfo;
gboolean    (*GwyModuleRegisterFunc)        (const gchar *name);
GwyModuleInfo* (*GwyModuleQueryFunc)        (void);
void        gwy_module_register_modules     (const gchar **paths);
GwyModuleInfo* gwy_module_lookup            (const gchar *name);
void        gwy_module_set_register_callback
                                            (void (*callback) (const gchar *fullname));

Description

Details

GWY_MODULE_ABI_VERSION

#define GWY_MODULE_ABI_VERSION 0

Gwyddion module ABI version.

To be filled as abi_version in GwyModuleInfo.


GWY_MODULE_QUERY()

#define     GWY_MODULE_QUERY(mod_info)

The declaration of module info query (the ONLY exported symbol from a module).

This macro does The Right Thing necessary to export module info in a way Gwyddion understands it. Put GWY_MODULE_QUERY with the module info (GwyModuleInfo) of your module as its argument on a line (with NO semicolon after).

mod_info : The GwyModuleInfo structure to return as module info.

struct GwyModuleInfo

struct GwyModuleInfo {

    guint32 abi_version;
    GwyModuleRegisterFunc register_func;
    const gchar *name;
    const gchar *blurb;
    const gchar *author;
    const gchar *version;
    const gchar *copyright;
    const gchar *date;
};

Module information returned by GWY_MODULE_QUERY().

guint32 abi_version Gwyddion module ABI version, should be always GWY_MODULE_ABI_VERSION.
GwyModuleRegisterFunc register_func Module registration function (the function run by Gwyddion module system, actually registering particular module features).
const gchar *name An unique module name.
const gchar *blurb Some module description.
const gchar *author Module author(s).
const gchar *version Module version.
const gchar *copyright Who has copyright on this module.
const gchar *date Date (year).

GwyModuleRegisterFunc ()

gboolean    (*GwyModuleRegisterFunc)        (const gchar *name);

Module registration function type.

It actually runs particular featrue registration functions, like gwy_module_register_file_func() and gwy_module_register_process_func().

name : An unique module name.
Returns : Whether the registration succeeded. When it returns FALSE, the module and its features are unloaded (FIXME: maybe. Currenly only module is unloaded, features are NOT unregistered, this can lead to all kinds of disasters).

GwyModuleQueryFunc ()

GwyModuleInfo* (*GwyModuleQueryFunc)        (void);

Module query function type.

The module query function should be simply declared as GWY_MODULE_QUERY(mod_info), where mod_info is module info struct for the module.

Returns : The module info struct.

gwy_module_register_modules ()

void        gwy_module_register_modules     (const gchar **paths);

Register all modules in given directories.

Can be called several times (on different directories).

paths : A NULL delimited list of directory names.

gwy_module_lookup ()

GwyModuleInfo* gwy_module_lookup            (const gchar *name);

Returns information about one module.

name : A module name.
Returns : The module info, of NULL if not found. It must be considered constant and never modified or freed.

gwy_module_set_register_callback ()

void        gwy_module_set_register_callback
                                            (void (*callback) (const gchar *fullname));

Sets function registration callback.

Note this is very rudimentary and only one callback can exist at a time.

callback : A callback function called when a function is registered with full (prefixed) function name.