TaPAS
0.2
|
Specification of Plugin Prototypes. More...
Go to the source code of this file.
Macros | |
#define | GENEPI_PLUGIN_FUNC(_f) GENEPI_PLUGIN_PREFIX (_LTX_ ## _f) |
Macro used to prefix function symbols. More... | |
Typedefs | |
typedef struct genepi_plugin_impl_st | genepi_plugin_impl |
Abstraction of a GENEPI plugin instance. | |
typedef struct genepi_set_impl_st | genepi_set_impl |
Abstraction of a GENEPI set. More... | |
Functions | |
genepi_plugin_impl * | genepi_plugin_init (genepi_plugconf *conf) |
Initializes the plugin. More... | |
void | genepi_plugin_terminate (genepi_plugin_impl *plugin) |
Releases ressources allocated by the plugin. More... | |
int | genepi_plugin_autotest (genepi_plugin_impl *plugin) |
Self-test. More... | |
genepi_solver_type | genepi_plugin_get_solver_type (genepi_plugin_impl *plugin) |
Returns the domain of variables used by the solver. More... | |
genepi_set_impl * | genepi_plugin_add_reference (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Adds a new reference to the set X. More... | |
void | genepi_plugin_del_reference (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Removes a reference to the set X. More... | |
genepi_set_impl * | genepi_plugin_top (genepi_plugin_impl *plugin, int n) |
Computes the complete relation of arity n. More... | |
genepi_set_impl * | genepi_plugin_top_N (genepi_plugin_impl *plugin, int n) |
Computes the complete relation of arity n restricted to positive or null integers. More... | |
genepi_set_impl * | genepi_plugin_top_Z (genepi_plugin_impl *plugin, int n) |
Computes the complete relation of arity n restricted integers. More... | |
genepi_set_impl * | genepi_plugin_top_P (genepi_plugin_impl *plugin, int n) |
Computes the complete relation of arity n restricted to positive or null reals. More... | |
genepi_set_impl * | genepi_plugin_top_R (genepi_plugin_impl *plugin, int n) |
Computes the complete relation of arity n restricted to reals. More... | |
genepi_set_impl * | genepi_plugin_bot (genepi_plugin_impl *plugin, int n) |
Computes the empty relation of arity n. More... | |
genepi_set_impl * | genepi_plugin_linear_operation (genepi_plugin_impl *plugin, const int *alpha, int alpha_size, genepi_comparator op, int c) |
Computes the set of solutions of a linear operation. More... | |
genepi_set_impl * | genepi_plugin_set_union (genepi_plugin_impl *plugin, genepi_set_impl *X1, genepi_set_impl *X2) |
Computes the union of two relations. More... | |
genepi_set_impl * | genepi_plugin_set_intersection (genepi_plugin_impl *plugin, genepi_set_impl *X1, genepi_set_impl *X2) |
Computes the intersection of two relations. More... | |
genepi_set_impl * | genepi_plugin_set_complement (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Computes the complement of the set X. More... | |
genepi_set_impl * | genepi_plugin_project (genepi_plugin_impl *plugin, genepi_set_impl *X, const int *selection, int size) |
Projects a relation on a subset of its columns. More... | |
genepi_set_impl * | genepi_plugin_invproject (genepi_plugin_impl *plugin, genepi_set_impl *X, const int *selection, int size) |
Adds columns to the relation X. More... | |
genepi_set_impl * | genepi_plugin_apply (genepi_plugin_impl *plugin, genepi_set_impl *R, genepi_set_impl *A) |
Computes post (R, A) More... | |
genepi_set_impl * | genepi_plugin_applyinv (genepi_plugin_impl *plugin, genepi_set_impl *R, genepi_set_impl *A) |
Computes pre (R, A) More... | |
int | genepi_plugin_compare (genepi_plugin_impl *plugin, genepi_set_impl *X1, genepi_comparator op, genepi_set_impl *X2) |
Checks inclusion relation between X1 and X2. More... | |
int | genepi_plugin_is_empty (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Checks the emptiness of X. More... | |
int | genepi_plugin_is_full (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Checks is X is the complete relation. More... | |
int | genepi_plugin_is_finite (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Checks if the set is finite. More... | |
int | genepi_plugin_depend_on (genepi_plugin_impl *plugin, genepi_set_impl *X, const int *sel, int selsize) |
Checks if the relation X depends on a subset of its column. More... | |
void | genepi_plugin_get_solutions (genepi_plugin_impl *plugin, genepi_set_impl *X, int ***psolutions, int *psize, int max) |
Computes an explicit representation of X. More... | |
void | genepi_plugin_display_all_solutions (genepi_plugin_impl *plugin, genepi_set_impl *X, FILE *output, const char *const *varnames) |
Displays all elements of X. More... | |
void | genepi_plugin_display_data_structure (genepi_plugin_impl *plugin, genepi_set_impl *X, FILE *output) |
Displays the data structure used to encode X. More... | |
int | genepi_plugin_get_width (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Arity of X. More... | |
int | genepi_plugin_get_data_structure_size (genepi_plugin_impl *plugin, genepi_set_impl *X) |
The size allocated to X. More... | |
int | genepi_plugin_is_solution (genepi_plugin_impl *plugin, genepi_set_impl *X, const int *v, int v_size, int vden) |
Checks if v/vden belongs to X. More... | |
int | genepi_plugin_get_one_solution (genepi_plugin_impl *plugin, genepi_set_impl *X, int *x, int x_size) |
Gets one element in X. More... | |
unsigned int | genepi_plugin_cache_hash (genepi_plugin_impl *plugin, genepi_set_impl *X) |
Computes an hash value for X. More... | |
int | genepi_plugin_cache_equal (genepi_plugin_impl *plugin, genepi_set_impl *X1, genepi_set_impl *X2) |
Checks that two sets are equal in the cache. More... | |
int | genepi_plugin_write_set (genepi_plugin_impl *plugin, FILE *output, genepi_set_impl *set) |
Dump the set X onto the output stream. More... | |
int | genepi_plugin_read_set (genepi_plugin_impl *plugin, FILE *input, genepi_set_impl **pset) |
Load on the input stream a serialized set. More... | |
int | genepi_plugin_preorder (genepi_plugin_impl *plugin, genepi_set_impl *X1, genepi_set_impl *X2) |
Evaluate the pre-order over sets. More... | |
Specification of Plugin Prototypes.
This header file declares prototypes of functions that a plugin have to implement. Each prototype is declared using a macro GENEPI_PLUGIN_FUNC() whose aim is to prefix each function name with the name of the plugin. GENEPI Plugin implementors must use this macro to define or to call the functions of their plugin.
genepi_plugin_ ## f i.e. it adds the prefix genepi_plugin
to the given symbol f
by . Thus, in this documentation, any function name of the form genepi_plugin
some_name has to be understood (and use) as GENEPI_PLUGIN_FUNC(some_name).
The plugins are loaded (cf. genepi-loader.h) using the LTDL library and the name of the generated .la
file is used by the plugin loader. The name of the file is the (nick)name of the module that has to be used to prefix plugin exported functions (see GENEPI_PLUGIN_FUNC()). The template plugin is distributed with a configure.ac
file and a Makefile.am
which can be helpful to build the plugin; the subdirectory m4
contains a useful M4 macro for checking the existence of the GENEPI library on the system and to locate the directory where plugins are installed.
Definition in file genepi-plugin.h.
#define GENEPI_PLUGIN_FUNC | ( | _f | ) | GENEPI_PLUGIN_PREFIX (_LTX_ ## _f) |
Macro used to prefix function symbols.
This macro-function is used to prefix each declaration of a plugin's function by the name of the plugin. Indeed the actual symbol name of an implemented function follows the form plugin name_LTX_
function name. For example, if the plugin will be used under the name myplugin
then the function implementing the initialization of the plugin will be actually called myplugin_LTX_init
.
GENEPI_PLUGIN_FUNC() macro uses another macro called GENEPI_PLUGIN_PREFIX(_f) which is defined by the developper of the plugin. This macro has to prefix the symbol specified by its argument _f with the name of the plugin. The following lines present the code defining this macro in the template plugin distributed with GENEPI:
In order to use the expect symbol name, the developper of a GENEPI plugin has to use the GENEPI_PLUGIN_FUNC() to write the prototype of its function. For example, the get_solver_type function of the template plugin is defined this way:
Definition at line 96 of file genepi-plugin.h.
typedef struct genepi_set_impl_st genepi_set_impl |
Abstraction of a GENEPI set.
This is an abstraction of the implementation of the encoding of a Presburger definable set. GENEPI uses it via pointers and no constraint exists on the underlying data structure contained into a genepi_set_impl (except that it must permits the implementation of function manipulating specified by the API).
Definition at line 112 of file genepi-plugin.h.
genepi_set_impl* genepi_plugin_add_reference | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Adds a new reference to the set X.
This function is called to indicate the plugin that the set X is referenced another time.
X | a non null pointer to a set |
Definition at line 100 of file template-plugin.c.
genepi_set_impl* genepi_plugin_apply | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | R, | ||
genepi_set_impl * | A | ||
) |
Computes post (R, A)
This function applies the relation R to the set A. If n is the width of A, the function assumes that 2*n is the width of R. The function computes the set of vectors defined by:
Note the interleaving of primed and not primed variables and also note that the primed variable precedes its non-primed version.
R | the transition relation |
A | the relation on which R is applied. |
post(R,A)
Definition at line 245 of file template-plugin.c.
genepi_set_impl* genepi_plugin_applyinv | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | R, | ||
genepi_set_impl * | A | ||
) |
Computes pre (R, A)
This function is similar to apply but instead of computing the image of A by the relation R, it computes the set whose image is A by R. Formally, the function computes the set:
Note the interleaving of primed and not primed variables and also note that the primed variable precedes its non-primed version.
R | the transition relation; |
A | the image by R of the computed relation. |
pre(R,A)
Definition at line 256 of file template-plugin.c.
int genepi_plugin_autotest | ( | genepi_plugin_impl * | plugin | ) |
Self-test.
This function is called on-demand by GENEPI clients to execute tests validating the plugin.
Definition at line 81 of file template-plugin.c.
genepi_set_impl* genepi_plugin_bot | ( | genepi_plugin_impl * | plugin, |
int | n | ||
) |
Computes the empty relation of arity n.
n | the arity of the computed relation |
Definition at line 172 of file template-plugin.c.
int genepi_plugin_cache_equal | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X1, | ||
genepi_set_impl * | X2 | ||
) |
Checks that two sets are equal in the cache.
X1 | first operand of the comparison |
X2 | second operand of the comparison |
Definition at line 403 of file template-plugin.c.
unsigned int genepi_plugin_cache_hash | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Computes an hash value for X.
X | the considered set |
Definition at line 393 of file template-plugin.c.
int genepi_plugin_compare | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X1, | ||
genepi_comparator | op, | ||
genepi_set_impl * | X2 | ||
) |
Checks inclusion relation between X1 and X2.
According to op the function returns a non null value if X1 and X2 satisfy X1 op X2 where op is interpreted on sets.
X1 | first operand of the comparison |
op | predicate over X1 and X2 to test |
X2 | second operand of the comparison |
Definition at line 266 of file template-plugin.c.
void genepi_plugin_del_reference | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Removes a reference to the set X.
This indicates the plugin that a reference has to be removed to X. GENEPI assumes that X is valid while its number of references is positive. When the number of references falls to zero the plugin should release or collect ressources allocated to X.
X | a non null pointer to a set |
Definition at line 112 of file template-plugin.c.
int genepi_plugin_depend_on | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
const int * | sel, | ||
int | selsize | ||
) |
Checks if the relation X depends on a subset of its column.
X is said to be dependent of columns (where is such that ) if the projection of X these columns is not the complete relation of arity n.
X | the relation on which we check dependency. |
sel | an array of Booleans identifying the columns on which the dependency is checked. |
selsize | the number of cells in sel. |
Definition at line 306 of file template-plugin.c.
void genepi_plugin_display_all_solutions | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
FILE * | output, | ||
const char *const * | varnames | ||
) |
Displays all elements of X.
This function displays all elements of X even if X is infinite. The representation used to display X is not specified.
X | the set to display |
output | the stream on which the result is displayed |
varnames | the names labelling the column of the relation; the size of this array must be equal to the arity of the relation. |
Definition at line 328 of file template-plugin.c.
void genepi_plugin_display_data_structure | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
FILE * | output | ||
) |
Displays the data structure used to encode X.
X | the set to display |
output | the stream on which the result is displayed |
Definition at line 339 of file template-plugin.c.
int genepi_plugin_get_data_structure_size | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
The size allocated to X.
This function returns the internal size allocated to the set X. The semantics of the integer returned by this function is not specified but must be consistent with size of the underlying data structure; it can be a number of nodes in a graph or the number of characters in a string conversion of the data structure.
X | the considered relation |
Definition at line 359 of file template-plugin.c.
int genepi_plugin_get_one_solution | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
int * | x, | ||
int | x_size | ||
) |
Gets one element in X.
This function fills the vector x with an element of X. If the components of x are not integers then components are set to the same denominator d which is return by the function. The way the function selects x is not specified.
X | the considered relation |
x | the vector receiving the element of X |
x_size | the size of x |
0 | if X is empty. |
the | common denominator of the solution x |
Definition at line 382 of file template-plugin.c.
void genepi_plugin_get_solutions | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
int *** | psolutions, | ||
int * | psize, | ||
int | max | ||
) |
Computes an explicit representation of X.
This function computes an array of vectors representing elements of the set X. Each vector is an array of integers allocated by the function. If X is an infinite set then max parameter is used to indicate the maximal number of vectors to return. The way the function choose the vectors is not specifed.
The vectors are returned via the psolutions parameter and the number of vectors is set into the variable pointed by psize.
If the max if negative then all the solutions are returned; in this case the function can guess that X is finite.
X | the set X |
psolutions | the address where the vectors are stored |
psize | the address of the integer receiving the number of solution |
max | the maximal number of solutions. |
Definition at line 317 of file template-plugin.c.
genepi_solver_type genepi_plugin_get_solver_type | ( | genepi_plugin_impl * | plugin | ) |
Returns the domain of variables used by the solver.
If this function is not implemented GENEPI assumes that the solver works on positive or null integers.
Definition at line 90 of file template-plugin.c.
int genepi_plugin_get_width | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Arity of X.
This function returns the arity or width of the given X
X | the considered relation |
Definition at line 349 of file template-plugin.c.
genepi_plugin_impl* genepi_plugin_init | ( | genepi_plugconf * | conf | ) |
Initializes the plugin.
This function is called just after the plugin is loaded. It has to initialize ressources of the plugin. If the initialization fail the loader unload the plugin.
This function is ignored if not implemented.
Definition at line 57 of file template-plugin.c.
genepi_set_impl* genepi_plugin_invproject | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
const int * | selection, | ||
int | size | ||
) |
Adds columns to the relation X.
This function add columns to X according to the array of Booleans selection. The arity of the resulting relation is size and the relation itself is defined by:
where n is the arity of X, and for .
X | the relation where new columns are added |
selection | the specification of new columns |
size | number of column in the result. |
Definition at line 234 of file template-plugin.c.
int genepi_plugin_is_empty | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Checks the emptiness of X.
This function checks if the set represented by X is empty or not.
X | the checked relation |
Definition at line 276 of file template-plugin.c.
int genepi_plugin_is_finite | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Checks if the set is finite.
X | the checked relation |
Definition at line 296 of file template-plugin.c.
int genepi_plugin_is_full | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Checks is X is the complete relation.
This function checks if the set represented by X is the complete relation of arity GENEPI_PLUGIN_FUNC (get_width) (X).
X | the checked relation |
Definition at line 286 of file template-plugin.c.
int genepi_plugin_is_solution | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
const int * | v, | ||
int | v_size, | ||
int | vden | ||
) |
Checks if v/vden belongs to X.
X | the considered relation |
v | the vector whose belonging is tested. |
v_size | the size of v |
vden | the denominator of v |
Definition at line 370 of file template-plugin.c.
genepi_set_impl* genepi_plugin_linear_operation | ( | genepi_plugin_impl * | plugin, |
const int * | alpha, | ||
int | alpha_size, | ||
genepi_comparator | op, | ||
int | c | ||
) |
Computes the set of solutions of a linear operation.
According to the value of op this function returns the set of solutions of the linear operation:
with op interpreted on integers.
alpha | the array of coefficient of the linear operation |
alpha_size | the number of coefficients |
c | the constant term of the operation |
op | the identifier of the operation |
Definition at line 181 of file template-plugin.c.
int genepi_plugin_preorder | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X1, | ||
genepi_set_impl * | X2 | ||
) |
Evaluate the pre-order over sets.
This function implements the pre-order relation such that for all sets , and :
X1 | first operand |
X2 | second operand |
Definition at line 436 of file template-plugin.c.
genepi_set_impl* genepi_plugin_project | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X, | ||
const int * | selection, | ||
int | size | ||
) |
Projects a relation on a subset of its columns.
This function computes the projection of X on the columns selected by the array of Booleans selection. The function computes:
where and for . The function may assumed that the arity of X is equal or greater than size.
X | the relation to project |
selection | the selection of columns of X which must be kept by the projection. |
size | the number of Booleans in selection. |
Definition at line 223 of file template-plugin.c.
int genepi_plugin_read_set | ( | genepi_plugin_impl * | plugin, |
FILE * | input, | ||
genepi_set_impl ** | pset | ||
) |
Load on the input stream a serialized set.
This function is used to reload a set serialized with the genepi_plugin_write_set write function. The loaded set is putted in *pset. The function returns the number of bytes actually readed. If a negative or null value is returned an error has occurred and the returned value has to be interpreted as genepi_io_error.
input | the stream where the set is loaded |
pset | a pointer to the variable receiving the loaded set. |
read_set function.
Definition at line 425 of file template-plugin.c.
References GENEPI_RW_ERR_IO.
genepi_set_impl* genepi_plugin_set_complement | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X | ||
) |
Computes the complement of the set X.
This function computes the completement of X in the domain of variables i.e. either or .
X | the set to complement. |
Definition at line 213 of file template-plugin.c.
genepi_set_impl* genepi_plugin_set_intersection | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X1, | ||
genepi_set_impl * | X2 | ||
) |
Computes the intersection of two relations.
This function has to compute where relations are assumed to be of same arity.
X1 | the first operand of the intersection |
X2 | the second operand of the intersection |
Definition at line 203 of file template-plugin.c.
genepi_set_impl* genepi_plugin_set_union | ( | genepi_plugin_impl * | plugin, |
genepi_set_impl * | X1, | ||
genepi_set_impl * | X2 | ||
) |
Computes the union of two relations.
This function has to compute where relations are assumed to be of same arity.
X1 | the first operand of the union |
X2 | the second operand of the union |
Definition at line 192 of file template-plugin.c.
void genepi_plugin_terminate | ( | genepi_plugin_impl * | plugin | ) |
Releases ressources allocated by the plugin.
This function destroys the ressources allocated by the module since its initilization.
This function has to handle the case multi-initialization of the plugin.
This function is ignored if not implemented.
Definition at line 70 of file template-plugin.c.
genepi_set_impl* genepi_plugin_top | ( | genepi_plugin_impl * | plugin, |
int | n | ||
) |
Computes the complete relation of arity n.
This function has to return the complete relation of arity n. Depending on the type of solver variables the result is either , , or .
n | the arity of the computed relation |
Definition at line 126 of file template-plugin.c.
genepi_set_impl* genepi_plugin_top_N | ( | genepi_plugin_impl * | plugin, |
int | n | ||
) |
Computes the complete relation of arity n restricted to positive or null integers.
This function has to return the complete relation of arity n over positive or null integers .
n | the arity of the computed relation |
Definition at line 135 of file template-plugin.c.
genepi_set_impl* genepi_plugin_top_P | ( | genepi_plugin_impl * | plugin, |
int | n | ||
) |
Computes the complete relation of arity n restricted to positive or null reals.
n | the arity of the computed relation |
Definition at line 154 of file template-plugin.c.
genepi_set_impl* genepi_plugin_top_R | ( | genepi_plugin_impl * | plugin, |
int | n | ||
) |
Computes the complete relation of arity n restricted to reals.
n | the arity of the computed relation |
Definition at line 164 of file template-plugin.c.
genepi_set_impl* genepi_plugin_top_Z | ( | genepi_plugin_impl * | plugin, |
int | n | ||
) |
Computes the complete relation of arity n restricted integers.
n | the arity of the computed relation |
Definition at line 144 of file template-plugin.c.
int genepi_plugin_write_set | ( | genepi_plugin_impl * | plugin, |
FILE * | output, | ||
genepi_set_impl * | set | ||
) |
Dump the set X onto the output stream.
This function can be used to serialize a set oX nto an output stream. The function returns the number of bytes actually written on the stream. If the result is negative or null then an error has occured and the returned has to be interpreted as a genepi_io_error.
output | the stream where data are written. |
set | the dumped GENEPI set |
Definition at line 414 of file template-plugin.c.
References GENEPI_RW_ERR_IO.