Class CLOController

Object
CLOController

public class CLOController extends Object
Encapsulates command line option setup, preprocessing, and parsing for EvoLudo.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Cached command-line string that should be applied when parsing.
    final CLOption
    Command line option to set the delay between subsequent updates.
    final CLOption
    Command line option to print help message for available command line options.
    final CLOption
    Command line option to set the type of model (see ModelType).
    final CLOption
    Command line option to set module.
    final CLOption
    Command line option to request that the EvoLudo model immediately starts running after loading.
    final CLOption
    Command line option to set seed of random number generator.
    final CLOption
    Command line option to set the color for trajectories.
    final CLOption
    Command line option to set verbosity level of logging.
    private final EvoLudo
    Owning EvoLudo engine coordinating models and modules.
    final String[]
    Replacement command line option for serious parsing failures to display help screen.
    private final CLOParser
    Parser used to manage all registered command-line options.
    private boolean
    Flag indicating whether the CLI string needs to be reparsed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a controller bound to the supplied engine.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Register an additional source of command-line options.
    void
    addModuleKey(String key, String title)
    Notify controller that available module keys changed.
    void
    Register all built-in CLOs with the supplied parser.
    private boolean
    Check whether the --help option was provided.
    Return the cached command-line string awaiting parsing.
    Build a help string summarizing all available options for the active module and model.
    Return the underlying parser used to register CLOs.
    Get the raw command-line string currently stored in the parser.
    Return the cached command-line string split on option boundaries.
    private String[]
    handleModelOption(String[] cloarray, boolean helpRequested)
    Process the --model option, constraining choices based on the selected module.
    private String[]
    handleModuleOption(String[] cloarray, boolean helpRequested)
    Process the --module option (loading modules early if needed).
    private String[]
    Process the --verbose option and update logger state.
    int
    Parse the cached command-line string.
    int
    parseCLO(String[] cloarray)
    Parse the provided command-line arguments.
    int
    Parse arguments after preprocessing (quoting, substitutions) has completed.
    preprocessCLO(String[] cloarray)
    Apply preprocessing to the command-line arguments (module/model resolution, helper options).
    boolean
    Check whether this controller (or its providers) supplies the given option.
    void
    Remove a previously registered provider.
    void
    Request that the command-line string be reparsed before the next run.
    void
    Update the cached command-line string to be parsed.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • engine

      private final EvoLudo engine
      Owning EvoLudo engine coordinating models and modules.
    • parser

      private final CLOParser parser
      Parser used to manage all registered command-line options.
    • reparseCLO

      private boolean reparseCLO
      Flag indicating whether the CLI string needs to be reparsed.
    • clo

      private String clo
      Cached command-line string that should be applied when parsing.
    • cloModule

      public final CLOption cloModule
      Command line option to set module.
    • cloModel

      public final CLOption cloModel
      Command line option to set the type of model (see ModelType).
    • cloSeed

      public final CLOption cloSeed
      Command line option to set seed of random number generator.
    • cloRun

      public final CLOption cloRun
      Command line option to request that the EvoLudo model immediately starts running after loading.
    • cloDelay

      public final CLOption cloDelay
      Command line option to set the delay between subsequent updates.
    • cloTrajectoryColor

      public final CLOption cloTrajectoryColor
      Command line option to set the color for trajectories. For example, this affects the display in S3 or Phase2D.
    • cloVerbose

      public final CLOption cloVerbose
      Command line option to set verbosity level of logging.
    • cloHelp

      public final CLOption cloHelp
      Command line option to print help message for available command line options.
    • helpCLO

      public final String[] helpCLO
      Replacement command line option for serious parsing failures to display help screen.
  • Constructor Details

    • CLOController

      public CLOController(EvoLudo evo)
      Create a controller bound to the supplied engine.
      Parameters:
      evo - owning EvoLudo instance
  • Method Details

    • getParser

      public CLOParser getParser()
      Return the underlying parser used to register CLOs.
      Returns:
      the underlying parser used to register CLOs
    • getParserCLO

      public String getParserCLO()
      Get the raw command-line string currently stored in the parser.
      Returns:
      the raw command-line string currently stored in the parser
    • providesCLO

      public boolean providesCLO(String name)
      Check whether this controller (or its providers) supplies the given option.
      Parameters:
      name - option name
      Returns:
      true if provided
    • addCLOProvider

      public void addCLOProvider(CLOProvider provider)
      Register an additional source of command-line options.
      Parameters:
      provider - provider to add
    • removeCLOProvider

      public void removeCLOProvider(CLOProvider provider)
      Remove a previously registered provider.
      Parameters:
      provider - provider to remove
    • requestParseCLO

      public void requestParseCLO()
      Request that the command-line string be reparsed before the next run.
    • getCLO

      public String getCLO()
      Return the cached command-line string awaiting parsing.
      Returns:
      cached command-line string
    • setCLO

      public void setCLO(String clo)
      Update the cached command-line string to be parsed.
      Parameters:
      clo - command-line input
    • getSplitCLO

      public String[] getSplitCLO()
      Return the cached command-line string split on option boundaries.
      Returns:
      cached command-line string split on option boundaries
    • parseCLO

      public int parseCLO()
      Parse the cached command-line string.
      Returns:
      parser exit status
    • parseCLO

      public int parseCLO(String[] cloarray)
      Parse the provided command-line arguments.
      Parameters:
      cloarray - arguments to parse
      Returns:
      parser exit status
    • parsePreprocessedCLO

      public int parsePreprocessedCLO(String[] cloarray)
      Parse arguments after preprocessing (quoting, substitutions) has completed.
      Parameters:
      cloarray - processed arguments
      Returns:
      parser exit status
    • preprocessCLO

      public String[] preprocessCLO(String[] cloarray)
      Apply preprocessing to the command-line arguments (module/model resolution, helper options).
      Parameters:
      cloarray - raw arguments
      Returns:
      processed arguments ready for parsing
    • containsHelpOption

      private boolean containsHelpOption(String[] cloarray)
      Check whether the --help option was provided.
      Parameters:
      cloarray - arguments to inspect
      Returns:
      true if help was requested
    • handleModuleOption

      private String[] handleModuleOption(String[] cloarray, boolean helpRequested)
      Process the --module option (loading modules early if needed).
      Parameters:
      cloarray - arguments to inspect
      helpRequested - whether help has been requested already
      Returns:
      updated argument array
    • handleModelOption

      private String[] handleModelOption(String[] cloarray, boolean helpRequested)
      Process the --model option, constraining choices based on the selected module.
      Parameters:
      cloarray - arguments to inspect
      helpRequested - whether help has been requested already
      Returns:
      updated argument array
    • handleVerboseOption

      private String[] handleVerboseOption(String[] cloarray)
      Process the --verbose option and update logger state.
      Parameters:
      cloarray - arguments to inspect
      Returns:
      updated argument array
    • getCLOHelp

      public String getCLOHelp()
      Build a help string summarizing all available options for the active module and model.
      Returns:
      formatted help text
    • collectCLO

      public void collectCLO(CLOParser prsr)
      Register all built-in CLOs with the supplied parser.
      Parameters:
      prsr - parser to populate
    • addModuleKey

      public void addModuleKey(String key, String title)
      Notify controller that available module keys changed.
      Parameters:
      key - module key
      title - module title