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-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
11   * <p>
12   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 11 dec. 2017 <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   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
16   */
17  public interface ModelComponentFactory
18  {
19      /**
20       * Returns parameters for the given component. These parameters should contain, and possibly overwrite, parameters from
21       * sub-components. A parameter factory at the highest level (strategical planner) may overwrite any parameter. This
22       * combination allows that for sub-components, default factories can be used, while the parameter factory only overwrites
23       * parameters different for specific GTU types. The default implementation returns all default parameter values declared at
24       * the class.<br>
25       * <br>
26       * Conventional use is:<br>
27       * 
28       * <pre>
29       * Parameters parameters = this.subComponent1Factory.getParameters();
30       * this.subComponent2Factory.getParameters().setAllIn(parameters);
31       * parameters.setDefaultParameters(componentClass);
32       * parameters.setDefaultParameters(staticUtilityClass);
33       * return parameters;
34       * </pre>
35       * 
36       * where all parameters used in {@code componentClass} are defined or forwarded in {@code componentClass}.<br>
37       * 
38       * <pre>
39       * // forwarded
40       * public static final ParameterTypeAcceleration A = ParameterTypes.A;
41       * 
42       * // defined
43       * public static final ParameterTypeDouble FACTOR = new ParameterTypeDouble("factor", "factor on response", 1.0);
44       * </pre>
45       * 
46       * The same holds for static utilities that are used. Parameters should be defined at the utility class, and parameters of
47       * used utilities should be included.<br>
48       * <br>
49       * @return Parameters; parameters for the given component
50       * @throws ParameterException on parameter exception
51       */
52      Parameters getParameters() throws ParameterException;
53  
54  }