Iterators enables the direct expression of the repeated application of the same process body. It specifies the control flow so that the output of the previous instance of the process can be the input of the next one.
The iterator is not an abstract process but rather a constructor of the Transmorpher language. It cannot be refined. The iterator can take several input and output channels and a channels attribute which allows users to specify the data flow within the iterator: output is copied to the channels channels so that it can be compared with the next output.
The repeat element introduces the use of an iteration in a process body. Its structure is the following:
The bibliography example does not use iterators, so here is a simple example.
The iterators allows a variable to be iterated over a particular domain. Each domain has a particular way to be iterated and hence a particular iterator.
The iterator element introduces the use of a variable which will be iterated over a particular structure. It must contain a name, a type and other type-specific parameters that will specify its behavior.
Transmorpher provides several built-in iterators:
References to contributed iterators can be found here
Iterators implements the fr.fluxmedia.transmorpher.TProcessFactory.TIterator interface which extends Enumeration. They must provide the implementations of methods init(Parameters), hasMoreElements() and nextElement().
Because, the iterators runs the same process several times, it is necessary to know what happens with the flows in the channels. The channels within an iterator are special channels (called feedback) which allows the output to be reused as input. For instance,
The repeat processing is thus the following:
MMerge and MDispatch obey the same behavior as that of mergers and dispatchers. However, they differ on their position in Transmorpher: they are exclusively used at the interface between an iteration and the rest of the process. They have exactly one input and one output channels.
They enables input from an outer channel to feed each iteration and output from each iteration to feed an outer channel.
MMerge concatenates the output of each iteration on its output channel. MDispatch generates its complete input at each iteration.
NOTE: they have not been implemented yet. The idea is that they will behave exactly like merge and dispatch (and thus inherit all their defined types). They just have to fake the multiple in/output by each output iteration.
Next chapter: Queries