TaPAS  0.2
Typedefs | Functions
genepi-loader.h File Reference

Plugin Loader. More...

Go to the source code of this file.

Typedefs

typedef struct genepi_plugin_st genepi_plugin
 The abstract type for a GENEPI plugin that implements sufficient functions to resolve Presburger formulas. More...
 

Functions

void genepi_loader_init (void)
 Initialize the plugin loader. More...
 
void genepi_loader_terminate (void)
 Release ressources allocated by the plugin loader. More...
 
const char * genepi_loader_get_default_directory (void)
 Returns the (default) GENEPI plugin are installed. More...
 
void genepi_loader_load_default_plugins (void)
 Request the loader to load all default GENEPI plugins. More...
 
genepi_plugingenepi_loader_get_plugin (const char *name)
 Load the plugin specified by name. More...
 
int genepi_loader_load_directory (const char *dirname)
 Load any plugin presents in the directory dirname. More...
 
char ** genepi_loader_get_plugins (int *psize)
 Returns the names of all currently loaded plugins. More...
 
const char * genepi_plugin_get_name (const genepi_plugin *plugin)
 Returns the nickname of the given plugin. More...
 

Detailed Description

Plugin Loader.

The GENEPI loader gathers functions used to dynamically load GENEPI plugins. A plugin is a piece of code implementing functionslisted into the file genepi-plugin.h. Since, at first, plugins were destinated to the FASTer tool (http://altarica.labri.fr/Tools/FASTer) a subset of these functions is mandatory in order to not crash the tool.

Before any use, the loader has to be initialized using the init function. This function has to be called prior to any module loading. Before the program termination you can use terminate to clean-up all ressources used by the loader and the loaded plugins.

The GENEPI package comes with a set of plugins. The installation of these plugins depends on the existence or not of external packages (e.g. MONA or PresTAF). If such package is present and the corresponding plugin is compiled then it is installed in some specific directory (this directory can be obtained using the function get_default_directory). These plugins are the called default plugins of the GENEPI library. They are not loaded at start-up by init; they have to be explicitly loaded using the load_default_plugins function.

External GENEPI plugin can be loaded between init and terminate calls. A plugin is loaded using the get_plugin function which returns an handler (genepi_plugin) to the plugin. This function is also used to retrieve the handler of an already loaded plugin (e.g. the default ones). The names of all loaded plugins can be obtained using the get_plugins function; each name returned by this function can be used in conjunction with get_plugin to retrieve the handler of a specific plugin.

Definition in file genepi-loader.h.

Typedef Documentation

typedef struct genepi_plugin_st genepi_plugin

The abstract type for a GENEPI plugin that implements sufficient functions to resolve Presburger formulas.

The structure genepi_plugin_st is defined by the plugin and no particular constraint is set on its size or content.

Definition at line 72 of file genepi-loader.h.

Function Documentation

const char* genepi_loader_get_default_directory ( void  )

Returns the (default) GENEPI plugin are installed.

The GENEPI library is packaged with some plugins (e.g Prestaf, Mona). These plugins are installed into the directory installation-prefix/lib/genepi. This function returns the path to this directory.

Returns
The path to the plugin directory
genepi_plugin* genepi_loader_get_plugin ( const char *  name)

Load the plugin specified by name.

First the function looks for name into its internal list of currently loaded plugins. If it finds a plugin with same name or filename then the function returns it. If the name is not found then the loader tries to dynamically load a module whose filename is name. If the file exists then the module is loaded using the LTDL library (the Libtool wrapper to dlopen).

If the module filename (i.e. name) is of the form some/path/somename.la then the somename becomes the nickname of the plugin that can be used as a prefix when looking for a function is the symbol table.

Once the module is loaded into memory, the function checks that mandatory functions are actually implemented by the module (e.g top() or linear_operation()); if it is not the case the module is considered as invalid and unloaded. The module is also unloaded if it implements the init() function and this one returns a nul value.

Parameters
namethe name or filename of the plugin.
Returns
a pointer to the selected plugin or NULL if it can not be found in existing ones or can not be loaded.
See Also
The Libtool project: http://www.gnu.org/software/libtool/.
The Programming Interface of GENEPI plugins: genepi-plugin.h.
char** genepi_loader_get_plugins ( int *  psize)

Returns the names of all currently loaded plugins.

Parameters
psizeis a pointer to an integer that receives the size of the result i.e. the number of loaded plugins.
Warning
the array and each one of its elements have to be freed.
Returns
a pointer to an array containing the names or filenames of the loaded plugins.
void genepi_loader_init ( void  )

Initialize the plugin loader.

This function initializes ressources required by the plugin loader of the GENEPI library. At this stage no plugin is dynamically loaded. Several calls to this function can done but only one initialization is actually realized.

See Also
genepi_loader_terminate, genepi_loader_load_default_plugins
void genepi_loader_load_default_plugins ( void  )

Request the loader to load all default GENEPI plugins.

This function is almost equivalent to the following code (except that it checks if the function has already been called) which requests the loader to load all default plugins.

int genepi_loader_load_directory ( const char *  dirname)

Load any plugin presents in the directory dirname.

This functions looks for Libtool modules (i.e files terminated with the .la extension) into the directory dirname. For each matching filename the loader applies genepi_loader_get_plugin ().

Parameters
dirnamethe path to the directory
Return values
a non-null integerif the dirname has been successfully opened and visited.
0if an error occurs.
void genepi_loader_terminate ( void  )

Release ressources allocated by the plugin loader.

This function releases any ressources allocated for loaded plugins. In particular the terminate() function is called on each plugin implementing it.

Since the loader tracks the number of calls to genepi_loader_init(), this function has to be called as many times than genepi_loader_init.

See Also
genepi_loader_init
const char* genepi_plugin_get_name ( const genepi_plugin plugin)

Returns the nickname of the given plugin.

If the plugin has been loaded from a Libtool module then this function returns the shortname associated by the LTDL library to this module.

Parameters
pluginthe considered plugin
Returns
the nickname of the plugin or NULL if the plugin has no nickname.
See Also
genepi_loader_get_plugin()