Plug-in Proxy Overview

Plug-in Proxy Overview — Overview of Gwyddion plug-ins and the plugin-proxy module

Plug-ins Overview

Plug-ins are external programs that can be executed by Gwyddion to either perform some operation on the data or to read or write data in a third-party file format.

Generally it is preferable to extend Gwyddion functionality by modules, because modules are dynamic libraries linked directly to Gwyddion at run-time allowing much more versatile interaction with the application, and they are also faster (for the same reason). For example, plug-ins generally cannot make use of existing Gwyddion data processing functions and cannot modify data in-place, a new window is always created for the result. Programming of modules is also no harder than programming of plug-ins, maybe it is even easier (assuming you know C).

They are however two reasons to use plug-ins:

  • Instability. A crash in a module is a crash in Gwyddion because modules, once loaded, become part of the application. When a plug-in fails, one gets garbage or nothing instead of data, but it does not affect the application.
  • Licensing. Since modules link with Gwyddion they are derived works of it and thus they have to be licensed under GNU General Public License, if they are to be distributed. The plug-in interface was on the other hand designed specifically to allow plug-ins to be independent works and thus not bound by GNU GPL (you are of course still encouraged to use GNU GPL for your plug-ins). The interface consists only of a small set of command line arguments and a very simple data file format used for data exchange.
  • Testing. While module unloading and reloading is theoretically possible, it is not implemented. Thus one has to quit and restart Gwyddion for changes in a module to take effect. Plug-ins are separate programs, so they are run in whatever state they currently are each time they are used.
  • Language issues. Gwyddion currently has only C API. If you already have your data processing routines written in FORTRAN, Java, Ruby, Delphi, or whatever, you may find easy to make a plug-in from them, while conversion to a module can require substantial changes and/or rewrite to C.

Plug-in Proxy

The capability to use plug-ins is not a built-in Gwyddion feature, instead it is provided a by a smart module called plug-in proxy. With the small exception there is a dedicated directory for plug-ins defined directly in Gwyddion, the plug-in proxy module is in no way privileged or otherwise special. It can be removed and/or other plug-in proxies can be added and happily coexist with the current one.

When the plug-in proxy module registeres self, it scans the plug-in directories, requests information from the plug-ins it finds and passes the information as its own features. Likewise when it is run to process some data it executes the appropriate plug-in to process it and passes the result back to Gwyddion. All plug-in features thus look as plug-in proxy features to Gwyddion, as you can see yourself in the Module Browser.

FIXME: More to be said.