Class Recorder
java.lang.Object
fr.istic.aco.editor.core.Recorder
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
indicates if the engine is currently recordingboolean
indicates if the engine is currently replayingvoid
replay()
void
save
(CommandOriginator command) Saves the current state of a command to the command history if recording is active.void
setIsRecording
(Boolean isRecording) enable or disable the function recordingvoid
setIsReplaying
(Boolean isReplaying) enable or disable the function replayingvoid
start()
Clears the command history to ensure a fresh recording session.void
stop()
Sets the recording state to false.
-
Constructor Details
-
Recorder
public Recorder()
-
-
Method Details
-
getCommandHistory
-
setIsRecording
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
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
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 executedIllegalArgumentException
- if replaying or recording are active
-