View Javadoc

1   package cz.cuni.amis.pogamut.base.agent.navigation.impl;
2   
3   import java.util.List;
4   
5   import cz.cuni.amis.pogamut.base.agent.navigation.IPathFuture;
6   import cz.cuni.amis.pogamut.base.component.IComponent;
7   import cz.cuni.amis.pogamut.base.component.bus.IComponentBus;
8   import cz.cuni.amis.pogamut.base.utils.future.ComponentFuture;
9   
10  /**
11   * Simple implementation of the {@link IPathFuture} interface that assumes the computation to be 
12   * dependent on some {@link IComponent}s. Therefore the path future retrieval method ({@link PathFuture#get()} and 
13   * {@link PathFuture#get(long, java.util.concurrent.TimeUnit)}) will fail if one of these components fails.
14   * 
15   * @author Jimmy
16   *
17   * @param <PATH_ELEMENT>
18   */
19  public class PathFuture<PATH_ELEMENT> extends ComponentFuture<List<PATH_ELEMENT>> implements IPathFuture<PATH_ELEMENT> {
20  
21  	private PATH_ELEMENT pathFrom;
22  	private PATH_ELEMENT pathTo;
23  
24  	/**
25  	 * Initialize the path future as independent on any {@link IComponent}.
26  	 * 
27  	 * @param pathFrom
28  	 * @param pathTo
29  	 */
30  	public PathFuture(PATH_ELEMENT pathFrom, PATH_ELEMENT pathTo) {
31  		super(null);
32  		this.pathFrom = pathFrom;
33  		this.pathTo = pathTo;
34  	}
35  
36  	
37  	/**
38  	 * Initialize the path future as dependent on 'dependants'. If one of the component the path computation depends
39  	 * on fails - the path future will report exception upon getting the path result.
40  	 * <p><p>
41  	 * See {@link ComponentFuture#ComponentFuture(IComponentBus, IComponent...)} for more details about 'bus' and 'dependants'
42  	 * parameters.
43  	 * 
44  	 * @param pathFrom
45  	 * @param pathTo
46  	 * @param bus
47  	 * @param depends
48  	 */
49  	public PathFuture(PATH_ELEMENT pathFrom, PATH_ELEMENT pathTo, IComponentBus bus, IComponent... dependants) {
50  		super(bus, dependants);
51  		this.pathFrom = pathFrom;
52  		this.pathTo = pathTo;
53  	}
54  
55  	@Override
56  	public PATH_ELEMENT getPathFrom() {
57  		return pathFrom;
58  	}
59  
60  	@Override
61  	public PATH_ELEMENT getPathTo() {
62  		return pathTo;
63  	}
64  
65  }