From 3f375a193d0f10a8121d568a745a7903c075c568 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 15 Oct 2024 15:36:00 +0200 Subject: update class diagram + add empty time travel command --- docs/class-diag.puml | 250 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 163 insertions(+), 87 deletions(-) (limited to 'docs') diff --git a/docs/class-diag.puml b/docs/class-diag.puml index 8526346..a502503 100644 --- a/docs/class-diag.puml +++ b/docs/class-diag.puml @@ -17,6 +17,7 @@ exception Exception { # va_format(va_list args, const char* fmt) } +together { /' LAYOUT '/ rectangle Group_FileReading as "File reading" <> { class FileReader <> { +open(url) : FileStrategy& @@ -34,10 +35,7 @@ rectangle Group_FileReading as "File reading" <> { class HTTPFile { - instance : HTTPFile <> } - package CPR { - class Response <> - class Url <> - } + package CPR { } FileStrategy <|.. LocalFile FileStrategy <|.. HTTPFile @@ -45,17 +43,21 @@ rectangle Group_FileReading as "File reading" <> { FileStrategy <. FileReader FileStrategy .> FileReader - HTTPFile --> CPR.Response - CPR.Response - CPR.Url + HTTPFile -> CPR + + ' LAYOUT + LocalFile -r[hidden] HTTPFile } rectangle Group_ParsingDeserialization as "Parsing & deserialization" <> { class Parser { - + parse(File, Deserializer) <> - + register_strategy(ParserStrategy) <> + + parse(FileStrategy &, Deserializer &) <> + + register_strategy(ParserStrategy *) <> + -- + - get_collection() : ParserCollection <> } interface ParserStrategy { - + parse(File, Deserializer) <> - + heuristic(File) : unsigned int <> + + parse(FileStrategy &, Deserializer &) <> + + heuristic(FileStrategy &) : unsigned int <> } ParserStrategy .> Parser @@ -65,45 +67,76 @@ rectangle Group_ParsingDeserialization as "Parsing & deserialization" <> class XMLParser class TXTParser + package pugixml { } + CSVParser ..|> ParserStrategy TXTParser ..|> ParserStrategy XMLParser ..|> ParserStrategy + XMLParser -> pugixml + class Deserializer { - + set_target(Museum &) - + add_artist(uniq) - + set_rows(unsigned int) - + set_cols(unsigned int) - + add_type(string, Color, unsigned int) - + add_tile(unsigned int x, unsigned int y, uniq) + + Deserializer(Museum &) + -- + + set_canvas(CanvasData) + + set_tile(TileData) + + add_artist(ArtistData) + + add_type(type : string, Color, weight : unsigned int) } CSVParser -up-> Deserializer XMLParser -up-> Deserializer TXTParser -up-> Deserializer - ' ParserStrategy ..> Deserializer + ' LAYOUT + CSVParser -r[hidden] TXTParser + TXTParser -r[hidden] XMLParser } +} /' LAYOUT '/ +together { /' LAYOUT '/ rectangle Group_Model as "Model" <> { + class Museum { + + people : People + + canvas : Canvas + -- + + update() + -- + - paused : bool <<+get>> <<+set>> + - tick : unsigned long long + -- + - working : bool + - worker : thread * + - work() + } class Canvas { - + get_tile(x, y) - + set_tile(x, y, TileData) - - data : CanvasData - - tiles : Tile[] + + Canvas(Museum &) + -- + + get_tile(x, y) : Tile & + + set_tile(TileData) + -- + + update() + + data : CanvasData + + set_data(CanvasData) + -- + - tiles : vector + - museum : Museum & } class People { - + add_artist(uniq) - - artists : Artist[] - } - class Museum { - - people : People - - canvas : Canvas + + People(Museum &) + -- + + add_artist(ArtistData) + + remove_artist(Artist &) + + get_artists() : forward_list + -- + - artists : forward_list } class Tile { + data : TileData } struct TileData { + + x : unsigned int + + y : unsigned int + type : string } class Artist { @@ -135,7 +168,6 @@ rectangle Group_Model as "Model" <> { ' LAYOUT Artist -r[hidden] Tile } - rectangle Group_TileAppearance as "Tile appearance" <> { struct Color { red : unsigned int @@ -152,36 +184,104 @@ rectangle Group_TileAppearance as "Tile appearance" <> { Color <.. TileAppearance } rectangle Group_TileBehavior as "Tile behavior" <> { - interface TileBehaviorStrategy + interface TileBehaviorStrategy { + + step(Artist *) + + update(Tile &) + + clone(Museum &) : uniq + -- + # TileBehaviorStrategy(type : string) + # TileBehaviorStrategy() + -- + # interactions : unsigned int + # museum : Museum * + } - class TileBehavior + class TileBehavior { + + get_strategy(string) : TileBehaviorStrategy & <> + + register_strategy(string, TileBehaviorStrategy *) <> + -- + - get_collection() : TileBehaviorCollection & <> + } together { - class NullTileBehavior - - class GrayTileBehavior - class RedTileBehavior - class BlueTileBehavior - class YellowTileBehavior - + class NullTileBehavior { + - type = "" <> + } + class GrayTileBehavior { + - type = "G" : <> + } + class RedTileBehavior { + - type = "R" : <> + } + class BlueTileBehavior { + - type = "B" : <> + -- + - update_neighbor(here : Tile &, dx, dy) + - dx : int + - dy : int + } + class YellowTileBehavior { + - type = "Y" : <> + -- + - last_interactions : unsigned int + } + + ' LAYOUT + TileBehavior -d[hidden]- NullTileBehavior NullTileBehavior -d[hidden]- GrayTileBehavior GrayTileBehavior -d[hidden]- RedTileBehavior RedTileBehavior -d[hidden]- BlueTileBehavior BlueTileBehavior -d[hidden]- YellowTileBehavior } - TileBehaviorStrategy <|.. NullTileBehavior - TileBehaviorStrategy <|.. GrayTileBehavior - TileBehaviorStrategy <|.. RedTileBehavior - TileBehaviorStrategy <|.. BlueTileBehavior - TileBehaviorStrategy <|.. YellowTileBehavior + TileBehaviorStrategy <|.[norank]. NullTileBehavior + TileBehaviorStrategy <|.[norank]. GrayTileBehavior + TileBehaviorStrategy <|.[norank]. RedTileBehavior + TileBehaviorStrategy <|.[norank]. BlueTileBehavior + TileBehaviorStrategy <|.[norank]. YellowTileBehavior Tile --> "state" TileBehavior TileBehavior .l> TileBehaviorStrategy TileBehavior <. TileBehaviorStrategy } +} /' LAYOUT '/ +together { /' LAYOUT '/ +rectangle Group_Commands as "Commands" <> { + class Command { + # museum : Museum& + # view : View& + # controller : ViewController& + -- + + Command(command : const Command *) + + Command(museum, view, controller) + } + + class MuseumPauseCommand { + + toggle() + + set(paused : bool) + } + class OpenFileGUICommand { + + execute() + } + class ArtistVisibilityCommand { + + toggle() + + set(paused : bool) + } + class LoadFilesCommand { + + execute(files) + } + class TileDecayCommand { + + execute(x, y) + } + + Command <|-u- MuseumPauseCommand + Command <|-u- OpenFileGUICommand + Command <|-u- ArtistVisibilityCommand + Command <|-u- TileDecayCommand + Command <|-d- LoadFilesCommand +} rectangle Group_Visualization as "Visualization" <> { struct Rectangle { x : unsigned int @@ -192,8 +292,18 @@ rectangle Group_Visualization as "Visualization" <> { enum Scancode { } - package SDL2 { } + package SDL3 { } class View { + + window_size(width, height) + + dialog_file(callback : fn(files : vec, data), data) + + draw_rect(Rectangle, Color) + -- + - window : SDL_Window * + - renderer : SDL_Renderer * + -- + + open : bool + - worker : thread * + - work() } class ViewController { + update() @@ -201,62 +311,28 @@ rectangle Group_Visualization as "Visualization" <> { ViewController ..> View ViewController <-- View - View -> SDL2 -} - -rectangle Group_Commands as "Commands" <> { - class Command { - #museum : Museum& - #view : View& - #controller : ViewController& - +Command(museum, view, controller) - +Command(command : const Command *) - } - - class MuseumPauseCommand { - +toggle() - +set(paused : bool) - } - class OpenFileGUICommand { - +execute() - } - class ArtistVisibilityCommand { - +toggle() - +set(paused : bool) - } - - Command <|-u- MuseumPauseCommand - Command <|-u- OpenFileGUICommand - Command <|-u- ArtistVisibilityCommand - - Command .d..> Museum - Command ...d[norank]> View - Command ...d[norank]> ViewController + View -> SDL3 } +} /' LAYOUT '/ -' PeopleDeserializer <... People -' CanvasDeserializer <... Canvas -' Deserializer <... Museum +Command .[norank]> Museum +Command .[norank]> View +Command .[norank]> ViewController ParserStrategy ..> FileStrategy -' Museum .> Deserializer : friend Deserializer .> Museum ViewController -[norank]> Command -main --> Museum -main --[norank]> Deserializer -main --[norank]> View -' DETAIL: main ..[norank]> FileReader -' DETAIL: main ..[norank]> Parser +main -d-> Museum +main -u-> LoadFilesCommand +main -[norank]> Deserializer +main -[norank]> View ' LAYOUT -Group_ParsingDeserialization -d[hidden] Group_FileReading Group_TileBehavior -r[hidden] Group_TileAppearance Group_Model -r[hidden] Group_ParsingDeserialization -Group_Model -l[hidden] main -' Group_Model -d[hidden] Group_TileBehavior -' Group_Model -d[hidden] Group_TileAppearance +Group_Commands -r[hidden] Group_Visualization @enduml -- cgit v1.2.3