1 package org.opentrafficsim.core.gtu;
2
3 import org.opentrafficsim.core.network.Link;
4 import org.opentrafficsim.core.network.OTSNetwork;
5
6 /**
7 * <p>
8 * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
9 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
10 * </p>
11 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
12 * initial version Nov 13, 2015 <br>
13 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
14 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
15 */
16 public abstract class AbstractLinkBasedGTU extends AbstractGTU
17 {
18 /** */
19 private static final long serialVersionUID = 20151114L;
20
21 /** The network in which this GTU is (initially) registered. */
22 private OTSNetwork network;
23
24 /**
25 * @param id String; the id of the GTU
26 * @param gtuType GTUType; the type of GTU, e.g. TruckType, CarType, BusType
27 * @param network OTSNetwork; the network in which this GTU is (initially) registered
28 * @throws GTUException when the construction of the original waiting path fails
29 */
30 @SuppressWarnings("checkstyle:parameternumber")
31 public AbstractLinkBasedGTU(final String id, final GTUType gtuType, final OTSNetwork network) throws GTUException
32 {
33 super(id, gtuType, network.getSimulator(), network);
34 this.network = network;
35 }
36
37 /**
38 * @return the network in which the GTU is registered
39 */
40 public final OTSNetwork getNetwork()
41 {
42 return this.network;
43 }
44
45 /**
46 * @param network OTSNetwork; change the network this GTU is registered in
47 */
48 public final void setNetwork(final OTSNetwork network)
49 {
50 this.network = network;
51 }
52
53 /*
54 * Return the link on which the given position of the GTU currently is. Returns <b>null</b> if the GTU is not on a link with
55 * this position.
56 * @param referencePosition the position type (FRONT, BACK, etc.) for which we want to know the link
57 * @return Link; the link on which the position of the GTU currently is
58 */
59 // TODO public abstract Link getLink(final RelativePosition.TYPE referencePosition);
60
61 /**
62 * Return the link on which the REFERENCE position of the GTU currently is on. Returns <b>null</b> if the GTU is not on a
63 * link with its reference position.
64 * @return Link; the link on which the REFERENCE position of the GTU currently is on
65 */
66 public abstract Link getLink();
67 }