Libdexterplugin Macros

Libdexterplugin Macros — Helper macros for defining Libdexter plugins

Synopsis

#include <dexterplugin.h>

#define             DEXTERPLUGIN_DEFINE_TYPE            (TN,
                                                         t_n,
                                                         T_P)
#define             DEXTERPLUGIN_DEFINE_TYPE_WITH_CODE  (TN,
                                                         t_n,
                                                         T_P,
                                                         _C_)
#define             DEXTERPLUGIN_DEFINE_TYPE_EXTENDED   (TypeName,
                                                         type_name,
                                                         TYPE_PARENT,
                                                         flags,
                                                         CODE)
#define             DEXTERPLUGIN_IMPLEMENT_INTERFACE    (TYPE_IFACE,
                                                         iface_init)

Description

Helper macros for defining plugin-based services. They are similar to the standard GObject macros found in gtype.h.

Example of how to use the DEXTERPLUGIN_DEFINE_TYPE_WITH_CODE() macro to define a plugin sampler service:

#include <dexterplugin.h>

...
/* -------------------------------------------------------------------------------------------------
  Define a sampler service type from the required abstract base type DEXTERPLUGIN_TYPE_SAMPLER_BASE, 
  implementing the required interface DEXTERPLUGIN_TYPE_ISAMPLER and initializing that interface 
  in plugin function your_plugin_service_isampler_init().
  -------------------------------------------------------------------------------------------------- */
DEXTERPLUGIN_DEFINE_TYPE_WITH_CODE (YourPluginService,
                                    your_plugin_service,
                                    DEXTERPLUGIN_TYPE_SAMPLER_BASE,
                                    DEXTERPLUGIN_IMPLEMENT_INTERFACE (DEXTERPLUGIN_TYPE_ISAMPLER,
                                                                      your_plugin_service_isampler_init));
...

Details

DEXTERPLUGIN_DEFINE_TYPE()

#define DEXTERPLUGIN_DEFINE_TYPE(TN, t_n, T_P) DEXTERPLUGIN_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})

Analog to G_DEFINE_TYPE() used to define object types for Libdexter plugins.

This macro differs from the standard macro in that it registers a dynamic, module-based type rather than a static type.

TN :

The name of the new type, in Camel case.

t_n :

The name of the new type, in lowercase, with words separated by '_'.

T_P :

The GType of the parent type.

DEXTERPLUGIN_DEFINE_TYPE_WITH_CODE()

#define DEXTERPLUGIN_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) DEXTERPLUGIN_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, _C_)

Analog to G_DEFINE_TYPE_WITH_CODE() used to define object types for Libdexter plugins.

This macro differs from the standard macro in that it registers a dynamic, module-based type rather than a static type.

TN :

The name of the new type, in Camel case.

t_n :

The name of the new type, in lowercase, with words separated by '_'.

T_P :

The GType of the parent type.

_C_ :

Custom code that gets inserted in the *_register_type() function.

DEXTERPLUGIN_DEFINE_TYPE_EXTENDED()

#define             DEXTERPLUGIN_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE)

Analog to G_DEFINE_TYPE_EXTENDED() used to define object types for Libdexter plugins.

This macro differs from the standard macro in that it registers a dynamic, module-based type rather than a static type.

DEXTERPLUGIN_DEFINE_TYPE_WITH_CODE (YourPluginService,
                                    your_plugin_service,
                                    DEXTERPLUGIN_TYPE_SAMPLER_BASE,
                                    DEXTERPLUGIN_IMPLEMENT_INTERFACE (DEXTERPLUGIN_TYPE_ISAMPLER,
                                                                      your_plugin_service_isampler_init));

expands to

static GType    your_plugin_service_type            = G_TYPE_INVALID;
static void     your_plugin_service_init              (YourPlugin      *self);
static void     your_plugin_service_class_init        (YourPluginClass *klass);
static gpointer your_plugin_service_parent_class    = NULL;
static void     your_plugin_service_class_intern_init (gpointer klass)
{
  your_plugin_service_parent_class = g_type_class_peek_parent (klass);
  your_plugin_service_class_init ((YourPluginServiceClass*) klass);
}

GType
your_plugin_serice_get_type (void)
{
  return your_plugin_service_type;
}

void
your_plugin_service_register_type (GTypeModule *module)
{
  GType dexterplugin_define_type_id;
  static const GTypeInfo dexterplugin_type_info = {
      sizeof (YourPluginServiceClass),
      NULL,
      NULL,
      (GClassInitFunc) your_plugin_service_class_intern_init,
      NULL,
      NULL,
      sizeof (YourPluginService),
      0,
      (GInstanceInitFunc) your_plugin_service_init,
      NULL
  };
  dexterplugin_define_type_id =
  g_type_module_register_type (module, DEXTERPLUGIN_TYPE_SAMPLER_BASE, "YourPluginService",
                               &dexterplugin_type_info, (GTypeFlags) 0);
  your_plugin_service_type = dexterplugin_define_type_id;
  { 
    static const GInterfaceInfo dexterplugin_implement_interface_info = {
       (GInterfaceInitFunc) your_plugin_service_isampler_init
    };
    g_type_module_add_interface (module, dexterplugin_define_type_id,
                                 DEXTERPLUGIN_TYPE_ISAMPLER, &dexterplugin_implement_interface_info);
  }
}

TypeName :

The name of the new type, in Camel case.

type_name :

The name of the new type, in lowercase, with words separated by '_'.

TYPE_PARENT :

The GType of the parent type.

flags :

flags for g_type_module_register_type().

CODE :

Custom code that gets inserted in the *_register_type() function.

DEXTERPLUGIN_IMPLEMENT_INTERFACE()

#define             DEXTERPLUGIN_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)

Analog to G_IMPLEMENT_INTERFACE() used to add an interface to Libdexter plugin types.

This macro differs from the standard macro in that it adds the interface to a dynamic, module-based type rather than a static type.

TYPE_IFACE :

The GType of the interface to add.

iface_init :

The interface init function.