Skip to content
Snippets Groups Projects
Commit 846e5a2e authored by Jesper's avatar Jesper
Browse files

Make TrackElement.monitoringSensors() a collection attribute

Includes latest JastAdd2 version which has improved collection
attribute dependency handling.
parent ff631d60
No related branches found
No related tags found
No related merge requests found
No preview for this file type
import java.util.HashSet;
aspect TreeNavigation {
// collections of things
......@@ -214,29 +216,25 @@ aspect TreeNavigation {
return getTarget().asSwitch();
}
syn Collection<Sensor> TrackElement.monitoringSensors() {
return getRoot().monitoringSensorsMap().get(this.id());
}
coll ArrayList<Sensor> TrackElement.monitoringSensors() [new ArrayList()] with add;
syn Map<Integer,Set<Sensor>> RailwayContainer.monitoringSensorsMap() {
Map<Integer,Set<Sensor>> sensorMap = new java.util.HashMap<Integer,Set<Sensor>>();
Sensor contributes this
to TrackElement.monitoringSensors()
for each monitoredElements();
// fill the keys
for (Region region: getRegionList()) {
for (TrackElement trackElement: region.getTrackElementList()) {
sensorMap.put(trackElement.id(), new java.util.HashSet());
}
}
RailwayContainer contributes {
// Explicitly traverses regions, skips routes.
getRegionList().collectContributions();
} to TrackElement.monitoringSensors();
// update the values
for (Sensor sensor : sensors()) {
for (Ref teRef : sensor.getMonitoredElementList()) {
sensorMap.get(teRef.getValue()).add(sensor);
}
}
Region contributes {
// Explicitly traverses sensors, skips elements.
getSensorList().collectContributions();
} to TrackElement.monitoringSensors();
return sensorMap;
}
Sensor contributes {
// Stop at sensor, only contains refs.
} to TrackElement.monitoringSensors();
syn Collection<Route> Sensor.requiringRoutes() {
return getRoot().requiringRoutesMap().get(this.id());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment