From 4cb7ca42003c177e3acc80075d7594e555966106 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 18 Oct 2024 16:37:02 +0200 Subject: fix command design pattern --- docs/class-diag.puml | 55 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 21 deletions(-) (limited to 'docs') diff --git a/docs/class-diag.puml b/docs/class-diag.puml index a6fc1cf..56a334f 100644 --- a/docs/class-diag.puml +++ b/docs/class-diag.puml @@ -294,7 +294,6 @@ rectangle Group_Visualization as "Visualization" <> { + ev_mousemove(x, y); -- - draw_artists : bool <<+get>> <<+set>> - - cmd_base : const Command * } ViewController ..> View @@ -306,45 +305,59 @@ rectangle Group_Visualization as "Visualization" <> { ViewController .l> MouseCode } rectangle Group_Commands as "Commands" <> { - class Command { - # museum : Museum * <<+get&>> <<-set>> - # view : View * <<+get&>> <<-set>> - # controller : ViewController * <<+get&>> <<-set>> - -- - + Command(command : const Command *) - + Command(museum, view, controller) + interface Command { + + execute() } class ToggleMuseumPauseCommand { - + toggle() - + set(paused : bool) + + constructor(Museum &) + + constructor(Museum &, set : bool) + -- + toggle : bool + value : bool } class OpenFileGUICommand { - + execute() + + constructor(Museum &, View &) + -- + - museum : Museum & + - view : View & } class ToggleArtistVisibilityCommand { - + toggle() - + set(paused : bool) + + constructor(ViewController &) + -- + - controller : ViewController & } class LoadFilesCommand { - + execute(files) + + constructor(Museum &, files : vec) + + constructor(Museum &, argc, argv) + -- + - load_files() + - museum : Museum & + - files : vec } class StepTileCommand { - + execute(x, y) + + constructor(Canvas &, pair) + -- + - canvas : Canvas & + - x : unsigned int + - y : unsigned int + } + class TimeTravelCommand { + + constructor(Museum &, forwards : bool) + -- + - museum : Museum & + - forwards : bool } - Command <|-u- ToggleMuseumPauseCommand + Command <|-d- ToggleMuseumPauseCommand Command <|-u- OpenFileGUICommand Command <|-u- ToggleArtistVisibilityCommand - Command <|-u- StepTileCommand + Command <|-d- StepTileCommand Command <|-d- LoadFilesCommand + Command <|-d- TimeTravelCommand } } /' LAYOUT '/ -Command .[norank]> Museum -Command .[norank]> View -Command .[norank]> ViewController - Parser .l> FileReader MuseumDeserializer .l> Museum -- cgit v1.2.3