EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.simucomframework]

COVERAGE SUMMARY FOR SOURCE FILE [ResourceRegistry.java]

nameclass, %method, %block, %line, %
ResourceRegistry.java0%   (0/1)0%   (0/13)0%   (0/247)0%   (0/50)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceRegistry0%   (0/1)0%   (0/13)0%   (0/247)0%   (0/50)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
ResourceRegistry (SimuComModel): void 0%   (0/1)0%   (0/14)0%   (0/5)
activateAllActiveResources (): void 0%   (0/1)0%   (0/36)0%   (0/6)
addLinkingResourceContainer (SimulatedLinkingResourceContainer): void 0%   (0/1)0%   (0/20)0%   (0/3)
addResourceContainer (SimulatedResourceContainer): void 0%   (0/1)0%   (0/20)0%   (0/3)
containsResourceContainer (String): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
createLinkingResourceContainer (String): AbstractSimulatedResourceContainer 0%   (0/1)0%   (0/24)0%   (0/6)
createResourceContainer (String): AbstractSimulatedResourceContainer 0%   (0/1)0%   (0/21)0%   (0/6)
deactivateAllActiveResources (): void 0%   (0/1)0%   (0/36)0%   (0/6)
deactivateAllPassiveResources (): void 0%   (0/1)0%   (0/1)0%   (0/1)
getLinkingResourceContainers (): List 0%   (0/1)0%   (0/27)0%   (0/5)
getResourceContainer (String): AbstractSimulatedResourceContainer 0%   (0/1)0%   (0/16)0%   (0/2)
removeResourceContainerFromRegistry (String): AbstractSimulatedResourceContainer 0%   (0/1)0%   (0/19)0%   (0/5)

1package de.uka.ipd.sdq.simucomframework;
2 
3import java.util.ArrayList;
4import java.util.HashMap;
5import java.util.List;
6 
7import de.uka.ipd.sdq.simucomframework.model.SimuComModel;
8import de.uka.ipd.sdq.simucomframework.resources.AbstractScheduledResource;
9import de.uka.ipd.sdq.simucomframework.resources.AbstractSimulatedResourceContainer;
10import de.uka.ipd.sdq.simucomframework.resources.SimulatedLinkingResourceContainer;
11import de.uka.ipd.sdq.simucomframework.resources.SimulatedResourceContainer;
12 
13/**
14 * Central registry for all simulated resources. The central registry can
15 * be used to start and stop all resources simultaniously
16 * @author Steffen Becker
17 *
18 */
19public class ResourceRegistry {
20        // ResourceContainerID -> ResourceContainer Object
21        private HashMap<String, AbstractSimulatedResourceContainer> resourceContainerHash = new HashMap<String, AbstractSimulatedResourceContainer>();
22        
23        private SimuComModel myModel = null;
24 
25        public ResourceRegistry(SimuComModel model) {
26                this.myModel = model;
27        }
28 
29        /**
30         * Create and add a PCM ResourceContainer
31         * @param containerID PCM ID of the resource container to create
32         * @return The simulated resource container object
33         */
34        public AbstractSimulatedResourceContainer createResourceContainer(
35                        String containerID) {
36                if (!resourceContainerHash.containsKey(containerID)) {
37                        SimulatedResourceContainer container = new SimulatedResourceContainer(
38                                        myModel,
39                                        containerID);
40                        addResourceContainer(container);
41                }
42                return resourceContainerHash.get(containerID);
43        }
44        
45        /**
46         * Add a PCM ResourceContainer
47         * @param container the resource container to add
48         */
49        public void addResourceContainer(SimulatedResourceContainer container) {
50                assert(!resourceContainerHash.containsKey(container.getResourceContainerID()));
51                resourceContainerHash.put(container.getResourceContainerID(), container);
52        }
53 
54        /**
55         * Create a simulated PCM LinkingResource
56         * @param containerID PCM ID of the LinkingResource
57         * @return The resource container introduced for the linking resource. Note,
58         * this container is virtuall as it does not exist in the PCMs orginal
59         * model. However, it exists in the simulation to unify resource container
60         * and link resource behaviour.
61         */
62        public AbstractSimulatedResourceContainer createLinkingResourceContainer(
63                        String containerID) {
64                if (!resourceContainerHash.containsKey(containerID)) {
65                        SimulatedLinkingResourceContainer container = new SimulatedLinkingResourceContainer(
66                                        myModel,
67                                        containerID);
68                        resourceContainerHash.put(containerID, container);
69                }
70                return resourceContainerHash.get(containerID);
71        }
72        
73        /**
74         * Add a PCM LinkingResourceContainer
75         * @param container the linking resource container to add
76         */
77        public void addLinkingResourceContainer(SimulatedLinkingResourceContainer container) {
78                assert(!resourceContainerHash.containsKey(container.getResourceContainerID()));
79                resourceContainerHash.put(container.getResourceContainerID(), container);
80        }
81        
82        public List<SimulatedLinkingResourceContainer> getLinkingResourceContainers() {
83                List<SimulatedLinkingResourceContainer> resourceContainers = new ArrayList<SimulatedLinkingResourceContainer>();
84                for (AbstractSimulatedResourceContainer container : resourceContainerHash.values()) {
85                        if (container instanceof SimulatedLinkingResourceContainer) {
86                                resourceContainers.add((SimulatedLinkingResourceContainer)container);
87                        }
88                }
89                return resourceContainers;
90        }
91        
92        /**
93         * @param resourceContainerID ID of the container
94         * @return True if the given ID is known in the resource registry
95         */
96        public boolean containsResourceContainer(String resourceContainerID) {
97                return resourceContainerHash.containsKey(resourceContainerID);
98        }
99 
100        /**
101         * Retrieve the resource container with the given ID
102         * @param resourceContainerID ID of the container to retrieve. The container
103         * must exist in this registry
104         * @return The queried resource container
105         */
106        public AbstractSimulatedResourceContainer getResourceContainer(
107                        String resourceContainerID) {
108                assert containsResourceContainer(resourceContainerID);
109                return resourceContainerHash.get(resourceContainerID);
110        }
111        
112        /**
113         * Retrieve the resource container with the given ID
114         * @param resourceContainerID ID of the container to retrieve. The container
115         * must exist in this registry
116         * @return The queried resource container
117         */
118        public AbstractSimulatedResourceContainer removeResourceContainerFromRegistry(
119                        String resourceContainerID) {
120                AbstractSimulatedResourceContainer container = null;
121                if (containsResourceContainer(resourceContainerID)) {
122                        container = resourceContainerHash.get(resourceContainerID);
123                        resourceContainerHash.remove(resourceContainerID);
124                }
125                return container; 
126        }
127 
128        /**
129         * Start all simulated resources in the simulation framework 
130         */
131        public void activateAllActiveResources() {
132                ArrayList<AbstractScheduledResource> resources = new ArrayList<AbstractScheduledResource>();
133                for(AbstractSimulatedResourceContainer src : resourceContainerHash.values())
134                        resources.addAll(src.getActiveResources());
135                for (AbstractScheduledResource sar : resources) {
136                        sar.activateResource();
137                }
138        }
139 
140        /**
141         * Stop all resources in the simulation framework 
142         */
143        public void deactivateAllActiveResources() {
144                ArrayList<AbstractScheduledResource> resources = new ArrayList<AbstractScheduledResource>();
145                for(AbstractSimulatedResourceContainer src : resourceContainerHash.values())
146                        resources.addAll(src.getActiveResources());
147                for (AbstractScheduledResource sar : resources) {
148                        sar.deactivateResource();
149                }
150        }
151        
152        public void deactivateAllPassiveResources() {
153                // TODO Is it necessary to deactivate passive resources here or is this
154                // already done elsewhere?
155        }
156 
157}

[all classes][de.uka.ipd.sdq.simucomframework]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov