The export module interface is very simple compared to fitness modules. Each export module must contain only one function, called export_function(). Its single purpose is to convert the data stored in the kernel data structures into a stream of characters and store it into one or more files.
Each time user runs tablix2_output with the proper command line arguments, the utility loads the requested export module, parses the XML file and initializes kernel data structures and calls the export_function().
The prototype for export_function() can be found in output.h:
typedef int (*export_f)(table *tab, moduleoption *opt, char *filename);
tab is a pointer to the table structure. This structure describes the timetable that should be exported - it contains pointers to the chromosome structures.
opt is a pointer to the linked list of module options. Module options are passed to the tablix2_output utility with the -s argument in the following form:
-s option1=value,option2=value,...
You can access this linked list in the same way as in fitness modules using functions option_int(), option_str() and option_find().
The final argument filename is a string holding the name of the file to be written. The tablix2_output utility simply passes this file name from its command line to the export function. The utility itself does not care if the export function actually writes anything to this file. For example, if the export function needs to write more than one file, it can use this argument as the name of the directory to put the files in. filename could also contain the location in a database where the timetable data should be inserted.
Note:
filenamecan be equal toNULL. The export function should treat that condition as a request to write on the standard output. If this is not possible (i.e. more than one file needs to be written) then the export function should return an error.
The export_function() should return 0 on success and -1 on error. Functions error(), info() and debug() can be used to report various warnings and errors back to the user.