View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical;
2   
3   import org.opentrafficsim.base.parameters.ParameterException;
4   import org.opentrafficsim.base.parameters.Parameters;
5   
6   /**
7    * Interface for factories of model components, such as strategical planners, tactical planners and car-following models.
8    * <p>
9    * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
11   * </p>
12   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
13   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
14   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
15   */
16  public interface ModelComponentFactory
17  {
18      /**
19       * Returns parameters for the given component. These parameters should contain, and possibly overwrite, parameters from
20       * sub-components. A parameter factory at the highest level (strategical planner) may overwrite any parameter. This
21       * combination allows that for sub-components, default factories can be used, while the parameter factory only overwrites
22       * parameters different for specific GTU types. The default implementation returns all default parameter values declared at
23       * the class.<br>
24       * <br>
25       * Conventional use is:<br>
26       * 
27       * <pre>
28       * Parameters parameters = this.subComponent1Factory.getParameters();
29       * this.subComponent2Factory.getParameters().setAllIn(parameters);
30       * parameters.setDefaultParameters(componentClass);
31       * parameters.setDefaultParameters(staticUtilityClass);
32       * return parameters;
33       * </pre>
34       * 
35       * where all parameters used in {@code componentClass} are defined or forwarded in {@code componentClass}.<br>
36       * 
37       * <pre>
38       * // forwarded
39       * public static final ParameterTypeAcceleration A = ParameterTypes.A;
40       * 
41       * // defined
42       * public static final ParameterTypeDouble FACTOR = new ParameterTypeDouble("factor", "factor on response", 1.0);
43       * </pre>
44       * 
45       * The same holds for static utilities that are used. Parameters should be defined at the utility class, and parameters of
46       * used utilities should be included.<br>
47       * <br>
48       * @return Parameters; parameters for the given component
49       * @throws ParameterException on parameter exception
50       */
51      Parameters getParameters() throws ParameterException;
52  
53  }