Class Recorder

java.lang.Object
fr.istic.aco.editor.core.Recorder

public class Recorder extends Object
The Recorder class is responsible for recording, saving, and replaying commands. It stores a history of commands and their corresponding mementos. This allows for re-executing the same sequence of commands in the future.
  • Constructor Details

    • Recorder

      public Recorder()
  • Method Details

    • getCommandHistory

      public List<Pair<CommandOriginator,Memento>> getCommandHistory()
    • setIsRecording

      public void setIsRecording(Boolean isRecording)
      enable or disable the function recording
      Parameters:
      isRecording -
    • getIsRecording

      public boolean getIsRecording()
      indicates if the engine is currently recording
      Returns:
      true if recording is active, false otherwise.
    • setIsReplaying

      public void setIsReplaying(Boolean isReplaying)
      enable or disable the function replaying
      Parameters:
      isReplaying -
    • getIsReplaying

      public boolean getIsReplaying()
      indicates if the engine is currently replaying
      Returns:
      true if recording is active, false otherwise.
    • start

      public void start()
      Clears the command history to ensure a fresh recording session. Sets the recording state to true.
    • stop

      public void stop()
      Sets the recording state to false.
    • save

      public void save(CommandOriginator command)
      Saves the current state of a command to the command history if recording is active. Checks if the system is in recording mode. Creates a pair containing the command as an id and its associated memento. Adds the pair to the command history for future replay operations.
      Parameters:
      command - The CommandOriginator object whose state needs to be saved.
    • replay

      public void replay()
      Throws:
      IllegalStateException - if the History is empty replays all the commands of the command History. each command is executed after setting its corresponding memento. sets replaying at false after all commands have been executed
      IllegalArgumentException - if replaying or recording are active