1 | package de.uka.ipd.sdq.prototype.framework.strategies; |
2 | |
3 | import java.util.HashMap; |
4 | |
5 | import de.uka.ipd.sdq.measurement.strategies.activeresource.DegreeOfAccuracyEnum; |
6 | import de.uka.ipd.sdq.measurement.strategies.activeresource.IDemandStrategy; |
7 | import de.uka.ipd.sdq.measurement.strategies.activeresource.ResourceTypeEnum; |
8 | import de.uka.ipd.sdq.measurement.strategies.activeresource.cpu.FibonacciDemand; |
9 | |
10 | public class StrategiesRegistry { |
11 | |
12 | private HashMap<ResourceTypeEnum,IDemandStrategy> strategiesHash = new HashMap<ResourceTypeEnum, IDemandStrategy>(); |
13 | private static StrategiesRegistry singletonInstance = new StrategiesRegistry(); |
14 | |
15 | private StrategiesRegistry() { |
16 | IDemandStrategy strat = new FibonacciDemand(); |
17 | //TODO: inject the real processing rate |
18 | strat.initializeStrategy(DegreeOfAccuracyEnum.MEDIUM,1); |
19 | registerStrategyFor(ResourceTypeEnum.CPU, strat); |
20 | |
21 | } |
22 | |
23 | public static StrategiesRegistry singleton() { |
24 | return singletonInstance; |
25 | } |
26 | |
27 | public void registerStrategyFor(ResourceTypeEnum resourceType, IDemandStrategy strategy){ |
28 | strategiesHash.put(resourceType, strategy); |
29 | } |
30 | |
31 | public IDemandStrategy getStrategyFor(ResourceTypeEnum resource) { |
32 | assert strategiesHash.containsKey(resource); |
33 | |
34 | return strategiesHash.get(resource); |
35 | } |
36 | } |