blob: 1740ae4481e7a652b38fc8bf1e6efc59c0096a08 [file] [log] [blame]
Zakir Meer9f251f52018-06-17 16:21:31 +02001package templates
2
3import com.inchron.realtime.root.RootFactory
4import com.inchron.realtime.root.model.Model
5import com.inchron.realtime.root.model.ModelFactory
6import com.inchron.realtime.root.model.memory.MemoryFactory
7import com.inchron.realtime.root.model.stimulation.StimulationFactory
8import org.eclipse.app4mc.amalthea.model.Amalthea
9import org.eclipse.app4mc.amalthea.model.AmaltheaFactory
10import org.eclipse.app4mc.transformation.extensions.base.templates.AbstractTransformer
11import org.eclipse.emf.ecore.EObject
12
13class AbstractAmaltheaInchronTransformer extends AbstractTransformer{
14
15 public var Model inchronModel;
16
17 public var Amalthea amaltheaModel
18
19 /*- Factory initiaization */
20 public val inchronRootFactory = RootFactory.eINSTANCE
21
22 public val inchronModelFactory = ModelFactory.eINSTANCE
23
24 public val inchronmemoryFactory = MemoryFactory.eINSTANCE
25
26 public val inchronStimulationFactory = StimulationFactory.eINSTANCE
27
28
29 public val amaltheaFactory = AmaltheaFactory.eINSTANCE
30
31 public def OSTransformer getOSTransformerInstance(){
32 return customObjsStore.getInstance(OSTransformer)
33 }
34
35 public def HWTransformer getHWTransformerInstance(){
36 return customObjsStore.getInstance(HWTransformer)
37 }
38
39 public def SWTransformer getSWTransformerInstance(){
40 return customObjsStore.getInstance(SWTransformer)
41 }
42
43
44 public def StimuliTransformer getStimuliTransformerInstance(){
45 return customObjsStore.getInstance(StimuliTransformer)
46 }
47
48 public def static <T> T getParentContainer(EObject eObject, Class<T> cl)
49 {
50 var EObject result = null;
51 if (eObject != null)
52 {
53 for (var EObject parent = eObject.eContainer(); parent != null; parent = parent.eContainer())
54 {
55
56 if(cl.isAssignableFrom(parent.getClass())){
57 return parent as T;
58 }
59
60 }
61 }
62 return result as T;
63 }
64}