WaypointModel.java 5.09 KB
Newer Older
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
/*
 * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
 *
 * This file is part of PeerfactSim.KOM.
 * 
 * PeerfactSim.KOM is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * PeerfactSim.KOM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with PeerfactSim.KOM.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package de.tud.kom.p2psim.api.topology.waypoints;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import de.tud.kom.p2psim.api.topology.obstacles.ObstacleModel;
import de.tud.kom.p2psim.api.util.geo.maps.Map;
29
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.Tuple;

public interface WaypointModel {

	/**
	 * Sets the current world dimensions which can be used by the
	 * waypoint model to correctly position the waypoints.
	 * 
	 * @param worldDimensions
	 */
	public abstract void setWorldDimensions(PositionVector worldDimensions);

	/**
	 * Returns all waypoints as a set.
	 * 
	 * @return
	 */
	public abstract Collection<Waypoint> getWaypoints();
	
	/**
	 * Returns all waypoints of type "type"
	 * 
	 * @param type
	 * @return
	 */
	public abstract Collection<Waypoint> getWaypoints(Class type);
	
	/**
	 * Returns the closest waypoint to the given position.
	 * 
	 * @param position
	 * @return
	 */
	public abstract Waypoint getClosestWaypoint(PositionVector position);
	
	/**
	 * Returns the closest waypoint of a specific type to the current position.
	 * 
	 * @param position
	 * @param type
	 * @return
	 */
	public abstract Waypoint getClosestWaypoint(PositionVector position, Class type);
	
	/**
	 * Returns a list of Tuple<Waypoint, Path> that are connected to the given waypoint.
	 * 
	 * @param waypoint
	 * @return
	 */
	public abstract List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint);
	
	/**
	 * Returns a list of Tuple<Waypoint, Path> of a specific type that are connected to the given waypoint.
	 * 
	 * @param waypoint
	 * @param type
	 * @return
	 */
	public abstract List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint, Class type);

	/**
	 * Returns all paths that are part of the waypoint model.
	 * 
	 * @return
	 */
	public abstract Set<Path> getPaths();
	
	/**
	 * Returns the shortest path between the two given waypoints.
	 * 
	 * @param start
	 * @param end
	 * @return
	 */
	public abstract List<Path> getShortestPath(Waypoint start, Waypoint end);

	/**
	 * Returns the total number of waypoints.
	 * 
	 * @return
	 */
	public abstract int getNumberOfWaypoints();
	
	/**
	 * Return the total number of waypoints of a specific type.
	 * 
	 * @param type
	 * @return
	 */
	public abstract int getNumberOfWaypoints(Class type);

	public abstract void addListener(WaypointModelListener listener);

	public abstract void removeListener(WaypointModelListener listener);

	/**
	 * Starts the waypoint generation process. After this method has
	 * been called all waypoints should be placed.
	 */
	public abstract void generateWaypoints();
	
	/**
	 * Sets the obstacle model an may be called before or after the
	 * call to generateWaypoints, depending on the configuration.
	 * 
	 * Should the waypoint model support the placement of waypoints with
	 * regard to the obstacles it should print a warning if the obstacle
	 * model hasn't been called beforethe generation has been started.
	 * 
	 * @param model
	 */
	public abstract void setObstacleModel(ObstacleModel model);

	/**
	 * Sets the strong waypoint strategy that should be used to generate the
	 * strong waypoints.
	 * 
	 * @param strongWaypointStrategy
	 */
	/*
	public abstract void setStrongWaypointStrategy(StrongWaypointStrategy strongWaypointStrategy);
	 */
	public DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> getGraph();

	/**
	 * Indicates if this model is scaled to the required world coordinates.
	 * 
	 * @return
	 */
	public boolean isScaled();
	
	/**
	 * Returns the metric dimensions of the underlying map. This dimensions may
	 * differ from the used world dimensions and can be used for scaling.
	 * 
	 * @return
	 */
	public abstract PositionVector getMetricDimensions();

	/**
	 * Returns the scaling factor if {@link isScaled} is true
	 * otherwise it should return 1.0
	 * 
	 * @return
	 */
	public abstract double getScaleFactor();

	public abstract Map getMap();

	public abstract void addWaypoint(Waypoint waypoint);
}