View Javadoc
1   package org.opentrafficsim.core.perception;
2   
3   import java.util.Optional;
4   import java.util.Set;
5   
6   import org.djutils.base.Identifiable;
7   import org.opentrafficsim.core.gtu.Gtu;
8   
9   /**
10   * The Model package guarantees that objects that are used in an OTS study such as GTUs are retrievable. In a spatial model, for
11   * instance, objects need to be able to find each other. The model interface guarantees access to a number of important objects
12   * in the study.
13   * <p>
14   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
19   */
20  public interface PerceivableContext extends Identifiable
21  {
22      /**
23       * Get a descriptive Id of the perceivable context (e.g., useful for debugging purposes).
24       * @return the id of the context
25       */
26      @Override
27      String getId();
28  
29      /**
30       * Get an overview of the GTUs in the model. The set returned is a defensive copy.
31       * @return a set of GTUs as registered in the current model.
32       */
33      Set<Gtu> getGTUs();
34  
35      /**
36       * Get a GTU in the model.
37       * @param gtuId the id of the GTU
38       * @return a GTU as registered in the current model, empty when the id could not be found.
39       */
40      Optional<Gtu> getGTU(String gtuId);
41  
42      /**
43       * Add a GTU to the network.
44       * @param gtu the GTU to add
45       */
46      void addGTU(Gtu gtu);
47  
48      /**
49       * Remove a GTU from the network.
50       * @param gtu the GTU to remove
51       */
52      void removeGTU(Gtu gtu);
53  
54      /**
55       * Test whether a GTU is registered in the network.
56       * @param gtu the GTU to search for
57       * @return whether the network contains this GTU
58       */
59      boolean containsGTU(Gtu gtu);
60  
61      /**
62       * Test whether a GTU ID is registered in the network.
63       * @param gtuId the GTU ID to search for
64       * @return whether the network contains a GTU with this ID
65       */
66      boolean containsGtuId(String gtuId);
67  
68  }