Previous: Output record, Up: Outputs
In this section, we explain how you can write new outputs in Mozart/Oz. You may also choose to do post-processing using another programming language, building on one of the XML output functors.
In order to write an output in Mozart/Oz, you need to provide two things:
You write the output definition in the IL, and add it to the list of
output definitions bound to the Oz variable Outputs
at the top of
the functor Outputs/Outputs.oz
.
Here is an example output definition of the output output.dag
:
elem(tag: outputdef id: elem(tag: constant data: 'output.dag') 'functor': elem(tag: constant data: 'Dag'))
The value of the id
feature is an IL constant denoting the unique
output identifier. The value of the 'functor'
feature is an IL constant
denoting the filename of the Oz functor implementing the output (modulo
the suffix .ozf
).
In order to integrate the output definition into the XDK, you need to
add the identifier of the new output to the XML file
Outputs/outputs.xml
. Here, for each new output, you add a line
like the following for the Dag output:
<outputDef id="output.Dag"/>
This step is necessary because XML language grammar files contain only output chooses and uses, but not output definitions. Therefore, the output identifiers of the chosen/used outputs are only referred to but not defined in XML language grammar files, which leads to errors running an XML validator on them.
You write the output functor as an Oz functor exporting two procedures:
Open: DIDA I OutputRec -> U
(open the output for dimension DIDA
)
Close: DIDA -> U
(close all windows opened by this output for dimension DIDA
)
Open
has three arguments:
DIDA
is a dimension identifier
denoting the output dimension
I
is an Oz integer denoting the number of the
solution
OutputRec
is the output record providing the
decoded information contained in the solution
Close
has one argument:
DIDA
is a dimension identifier
denoting the output dimension
The output functor has to reside in Outputs/Lib
. Its file name must
match the value of the 'functor'
feature in the output definition,
i.e. for Dag
, it must be Dag.oz
.
In order to integrate the output definition into the XDK, you need to
add the output functor to the ozmake
makefile in
Outputs/Lib
(Outputs/Lib/makefile.oz
).
The functor Outputs/Lib/Helpers.oz
exports the procedure
CheckCycles: DIDA NodeOLs -> U
. CheckCycles
checks
whether a graph has a cycle. It has two arguments:
DIDA
: a dimension identifier of the dimension which shall be checked
NodeOLs
: a list of node records in the OL, denoting a solution.
The procedure assumes that the graph principle (or the graph1
principle) is used on dimension DIDA
.