Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 46f38af15d7bd8ded8bc95ea5dcd4001989882a2 (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
/*******************************************************************************
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.dctools

import java.util.Map
import org.eclipse.etrice.core.fsm.fSM.ModelComponent
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import com.google.inject.Inject
import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician

class GenModelAccess {
	
	private ExtendedFsmGenBuilderFactory fsmGenBuilderFactory
	
	Map<ModelComponent, GraphContainer> cache = newHashMap
	
	@Inject
	new(ExtendedFsmGenBuilderFactory fsmGenBuilderFactory) {
		this.fsmGenBuilderFactory = fsmGenBuilderFactory
	}
	
	def public clearCache() {
		cache.clear
	}
	
	def public GraphContainer get(ModelComponent mc) {
		if(!cache.containsKey(mc)) {
			val builder = fsmGenBuilderFactory.create(new NullDiagnostician)
			val gc = builder.createTransformedModel(mc)
			builder.withCommonData(gc)
			cache.put(mc, gc)
		}
		
		return cache.get(mc)
	}
}

Back to the top