Download A Generic Framework for Structure

Transcript
4.5. Transformation Interface
Transformation:
Void transformation( TypeA, List[TypeC], TypeB, TypeC)
Mapping:
A1
[C2, C3, C4]
B1
C1
Model Selection:
C1
B1
C2
C3
C4
A1
Figure 4.4.: Mapping and reordering Parameters
mechanism, depending on the underlying transformation framework. The handling
of special types, however, requires an appropriate handling to provide a transparent
use in the graphical editor. The particular amount and kind of special types also depends on the transformation framework that is used, but some of the most common
types are: collections, lists, maps, arrays, etc. The combination of the mapping of
simple and special types leads to the following rules for a mapping algorithm:
• The mapping algorithm has to ensure that the number of selected elements
matches the number of required parameters.
• The order of the parameter types and selected diagram elements must be transparent, i. e. if the transformation requires parameter types A and B, the user
is allowed to select the elements in arbitrary order, e. g. B, A.
• If a transformation contains a collection parameter, e. g. a list of elements, the
mapping must find the best match for the list, i. e. collect either all selected
elements of the matching type or select the first sequence of elements in the
current selection.
The mapping algorithm that has been developed for this thesis solves the list
mapping task by searching the first sequence of the list parameter type in the current selection, e. g. if the selection contains a single and a sequence of elements with
the same type, separated by a different type, the algorithm will select the last sequence, as shown in Figure 4.4. This allows the mixture of single elements and lists
with the same type in one transformation. Listing 4.1 shows the pseudocode of the
implemented parameter mapping algorithm.
Figure 4.5 shows an example of how the algoritm is used for ordering and mapping
diagram elements to transformation parameters. The transformation, as shown in
Listing 4.2, is performed on a single state element, a transition, and a list of target
states. The resulting model will comprise transitions between the source and the
target states with the same triggers and effects string as the selected transition.
37