Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 98562e9398b33f519260cd35884c592248d29310 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2007,2008 Tata Consultancy Services and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     TCS - initial implementation for ModelMorf
 *     E.D.Willink - alignment with evolved specification
 *     E.D.Willink - rename / comment
 *******************************************************************************/
--import listMM : '../../../../../../../../../org.eclipse.qvtd.xtext.qvtcore.tests/src/org/eclipse/qvtd/xtext/qvtcore/tests/forward2reverse/DoublyLinkedList.ecore#/'; 
import listMM : 'DoublyLinkedList.ecore#/'; 

/**
 * Transform a hierarchical StateMachine into a flat StateMachine.
 */
package org::eclipse::qvtd::xtext::qvtrelation2::tests::forward2reverse {
	transformation Forward2Reverse(forward:listMM, reverse:listMM)
	{
		/**
		 *  Map each hierarchical StateMachine to a flat StateMachine
		 */
		top relation list2list {
			domain forward forwardList : DoublyLinkedList {
				name = listName : String{}
			};	   
			enforce domain reverse reverseList : DoublyLinkedList {
				name = listName
			};
			where {
				listHead2listHead(forwardList, reverseList);
			}
		}
		relation listHead2listHead {
			domain forward forwardList : DoublyLinkedList {
				headElement = forwardHead : Element{}
			};	   
			enforce domain reverse reverseList : DoublyLinkedList {
				headElement = reverseHead : Element{}
			};
			when {
				element2element(forwardHead, reverseHead);
			}
		}
	
		/**
		 *  Map each Leaf State to a Flat State in the corresponding StateMachine.
		 */
		top relation element2element {
			domain forward forwardElement : Element {
				list = forwardList : DoublyLinkedList{},
				name = elementName : String{},
				target = forwardTarget : Element{}
			};
			enforce domain reverse reverseElement : Element {
				list = reverseList : DoublyLinkedList{},
				name = elementName,
				source = reverseSource : Element{}
			};	
			when {
				list2list(forwardList, reverseList);
				element2element(forwardTarget, reverseSource);
			}
		}
	}
}

Back to the top