#include <limits.h>
#include "data.h"
#include "chromo.h"
This graph shows which files directly or indirectly include this file:
Data Structures | |
struct | modulehandler_t |
Structure describing a restriction handler. More... | |
struct | fitnessfunc_t |
Structure describing a fitness function. More... | |
struct | precalcfunc_t |
Structure describing a precalculate function. More... | |
struct | module_t |
Information about a module. More... | |
struct | modulelist_t |
Information about loaded modules. More... | |
struct | moduleoption_t |
Structure holding a module option. More... | |
Defines | |
#define | EVENT_TYPE "__EVENT__" |
Name of the special resource type used for event restrictions. | |
#define | ANY_TYPE "__ANY_TYPE__" |
Name of the special resource type used for resource restrictions that matches any resource type. | |
Typedefs | |
typedef moduleoption_t | moduleoption |
typedef modulelist_t | modulelist |
typedef module_t | module |
typedef precalcfunc_t | precalcfunc |
typedef modulehandler_t | modulehandler |
typedef fitnessfunc_t | fitnessfunc |
typedef int(*) | fitness_f (chromo **c, ext **e, slist **s) |
Pointer to modules fitness function. | |
typedef int(*) | handler_res_f (char *restriction, char *cont, resource *res) |
Pointer to module resource restriction handler. | |
typedef int(*) | handler_tup_f (char *restriction, char *cont, tupleinfo *tuple) |
Pointer to module tuple restriction handler. | |
typedef int(*) | init_f (moduleoption *opt) |
Pointer to module initialization function. | |
Functions | |
moduleoption * | option_new (moduleoption *opt, char *name, char *content) |
Inserts a new module option to the beginning of the moduleoption linked list. | |
moduleoption * | option_find (moduleoption *opt, char *name) |
Finds an option by name. | |
int | option_int (moduleoption *opt, char *name) |
Finds an integer option by name. | |
char * | option_str (moduleoption *opt, char *name) |
Finds a string option by name. | |
void | option_free (moduleoption *opt) |
Free a linked list of options. | |
char * | module_filename_combine (char *prefix, char *name) |
Combines the base module name with module path and extension. | |
module * | module_load (char *name, moduleoption *opt) |
Loads a module. After the module is loaded, module_init() function is called. | |
int | handler_res_call (resource *res, char *restriction, char *content) |
Call a resource restriction handler. | |
int | handler_tup_call (tupleinfo *tuple, char *restriction, char *content) |
Call a tuple restriction handler. | |
modulehandler * | handler_tup_new (char *restriction, handler_tup_f handler) |
Registers a new tuple restriction handler. | |
modulehandler * | handler_res_new (char *restype, char *restriction, handler_res_f handler) |
Registers a new resource restriction handler. | |
precalcfunc * | precalc_new (init_f func) |
Register a new precalc function. | |
int | precalc_call () |
Call all registered precalc functions. | |
fitnessfunc * | fitness_new (char *name, int weight, int man, fitness_f func) |
Registers a new fitness function. | |
int | fitness_request_chromo (fitnessfunc *fitness, char *restype) |
Request a chromosome to be passed to a fitness function. | |
int | fitness_request_ext (fitnessfunc *fitness, char *contype, char *vartype) |
Request an extension to be passed to a fitness function. | |
int | fitness_request_slist (fitnessfunc *fitness, char *vartype) |
Request a slist to be passed to a fitness function. | |
void | table_fitness (table *tab) |
Assign a fitness to a table by calling all fitness functions. | |
Variables | |
int | mod_fitnessnum |
Number of all registered fitness functions. | |
fitnessfunc * | mod_fitnessfunc |
Linked list of all registered fitness functions. | |
char * | mod_modulepath |
Path to fitness and export modules. |
Pointer to modules fitness function.
c | Array of pointers to requested chromosomes. | |
e | Array of pointers to requested extensions. | |
s | Array of pointers to requested slists. |
typedef int(*) handler_res_f(char *restriction, char *cont, resource *res) |
Pointer to module resource restriction handler.
restriction | Type of restriction. | |
cont | Content of restriction tag. | |
res | Resource for which restriction handler was called. |
typedef int(*) handler_tup_f(char *restriction, char *cont, tupleinfo *tuple) |
Pointer to module tuple restriction handler.
restriction | Type of restriction. | |
cont | Content of restriction tag. | |
tuple | Tuple for which restriction handler was called. |
typedef int(*) init_f(moduleoption *opt) |
Pointer to module initialization function.
opt | Pointer to the moduleoption structure with the options for the current module. |
fitnessfunc* fitness_new | ( | char * | name, | |
int | weight, | |||
int | man, | |||
fitness_f | func | |||
) |
Registers a new fitness function.
name | Description of this fitness function. | |
weight | Weight value for this function. | |
man | Set to 1 if this is a mandatory weight and 0 if not. | |
func | Pointer to the fitness function. |
int fitness_request_chromo | ( | fitnessfunc * | fitness, | |
char * | restype | |||
) |
Request a chromosome to be passed to a fitness function.
fitness | Pointer to the fitnessfunc structure. | |
restype | Resource type of the chromosome to be passed to the fitness function. |
int fitness_request_ext | ( | fitnessfunc * | fitness, | |
char * | contype, | |||
char * | vartype | |||
) |
Request an extension to be passed to a fitness function.
fitness | Pointer to the fitnessfunc structure. | |
contype | Name of the constant resource. | |
vartype | Name of the variable resource. |
int fitness_request_slist | ( | fitnessfunc * | fitness, | |
char * | vartype | |||
) |
Request a slist to be passed to a fitness function.
fitness | Pointer to the fitnessfunc structure. | |
vartype | Variable resource ID. fitness function. |
int handler_res_call | ( | resource * | res, | |
char * | restriction, | |||
char * | content | |||
) |
Call a resource restriction handler.
res | Pointer to the resource for this restriction. | |
restriction | Type of this restriction. | |
content | Content of this restriction. |
modulehandler* handler_res_new | ( | char * | restype, | |
char * | restriction, | |||
handler_res_f | handler | |||
) |
Registers a new resource restriction handler.
restype | Name of the resource type. If equal to NULL then handler will be registered for all resource types. | |
restriction | Type of the restriction. | |
handler | Pointer to the restriction handler function. |
int handler_tup_call | ( | tupleinfo * | tuple, | |
char * | restriction, | |||
char * | content | |||
) |
Call a tuple restriction handler.
tuple | Pointer to the tuple for this restriction. | |
restriction | Type of this restriction. | |
content | Content of this restriction. |
modulehandler* handler_tup_new | ( | char * | restriction, | |
handler_tup_f | handler | |||
) |
Registers a new tuple restriction handler.
restriction | Type of the restriction. | |
handler | Pointer to the restriction handler function. |
char* module_filename_combine | ( | char * | prefix, | |
char * | name | |||
) |
Combines the base module name with module path and extension.
If file name has no extension the default shared library extension for this system will be appended.
If file name has a ".so" extension this extension will be replaced with the default shared library extension to remain backward compatible.
name | File name of the module | |
prefix | Module prefix (for example "export_" for export modules) |
module* module_load | ( | char * | name, | |
moduleoption * | opt | |||
) |
Loads a module. After the module is loaded, module_init() function is called.
name | File name of the module (example: "timeplace"). | |
opt | Linked list of options for this module. |
moduleoption* option_find | ( | moduleoption * | opt, | |
char * | name | |||
) |
Finds an option by name.
If there many options with the same name in the linked list, you can find them all with the following loop:
moduleoption *result; // "list" is the pointer to the linked list to search result=option_find(list, "name"); while(result!=NULL) { // do something with "result" result=option_find(result->next, "name"); }
opt | Pointer to the first element in the linked list. | |
name | Name of the option to find. |
void option_free | ( | moduleoption * | opt | ) |
Free a linked list of options.
opt | Pointer to the first element in the linked list. |
int option_int | ( | moduleoption * | opt, | |
char * | name | |||
) |
Finds an integer option by name.
Note that if more than one option with the same name is defined then this function returns the value of the option that was added last to the linked list by option_new()
opt | Pointer to the first element in the linked list. | |
name | Name of the option to find. |
moduleoption* option_new | ( | moduleoption * | opt, | |
char * | name, | |||
char * | content | |||
) |
Inserts a new module option to the beginning of the moduleoption linked list.
opt | Pointer to the first element in the linked list (can be NULL). | |
name | Name of the option. | |
content | Content of the option. |
char* option_str | ( | moduleoption * | opt, | |
char * | name | |||
) |
Finds a string option by name.
Note that if more than one option with the same name is defined then this function returns the value of the option that was added last to the linked list by option_new()
opt | Pointer to the first element in the linked list. | |
name | Name of the option to find. |
int precalc_call | ( | ) |
Call all registered precalc functions.
precalcfunc* precalc_new | ( | init_f | func | ) |
Register a new precalc function.
func | Pointer to the precalc function. |
void table_fitness | ( | table * | tab | ) |
Assign a fitness to a table by calling all fitness functions.
tab | Pointer to the table to be fitnessd. |
char* mod_modulepath |
Path to fitness and export modules.
Defaults to the location where modules were installed by "make install".