diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-15 15:36:00 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-15 15:36:00 +0200 |
commit | 3f375a193d0f10a8121d568a745a7903c075c568 (patch) | |
tree | 90f8d85249172bd314145104a15ff3c3601170ba /docs | |
parent | 6319b7c8bf1689c990f8849c76e1871bcea9584d (diff) |
update class diagram + add empty time travel command
Diffstat (limited to 'docs')
-rw-r--r-- | docs/class-diag.puml | 250 |
1 files changed, 163 insertions, 87 deletions
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" <<group>> { class FileReader <<Factory>> { +open(url) : FileStrategy& @@ -34,10 +35,7 @@ rectangle Group_FileReading as "File reading" <<group>> { class HTTPFile { - instance : HTTPFile <<static>> } - package CPR { - class Response <<irrelevant>> - class Url <<irrelevant>> - } + package CPR { } FileStrategy <|.. LocalFile FileStrategy <|.. HTTPFile @@ -45,17 +43,21 @@ rectangle Group_FileReading as "File reading" <<group>> { FileStrategy <. FileReader FileStrategy .> FileReader - HTTPFile --> CPR.Response - CPR.Response - CPR.Url + HTTPFile -> CPR + + ' LAYOUT + LocalFile -r[hidden] HTTPFile } rectangle Group_ParsingDeserialization as "Parsing & deserialization" <<group>> { class Parser { - + parse(File, Deserializer) <<static>> - + register_strategy(ParserStrategy) <<static>> + + parse(FileStrategy &, Deserializer &) <<static>> + + register_strategy(ParserStrategy *) <<static>> + -- + - get_collection() : ParserCollection <<static>> } interface ParserStrategy { - + parse(File, Deserializer) <<static>> - + heuristic(File) : unsigned int <<static>> + + parse(FileStrategy &, Deserializer &) <<static>> + + heuristic(FileStrategy &) : unsigned int <<static>> } ParserStrategy .> Parser @@ -65,45 +67,76 @@ rectangle Group_ParsingDeserialization as "Parsing & deserialization" <<group>> class XMLParser class TXTParser + package pugixml { } + CSVParser ..|> ParserStrategy TXTParser ..|> ParserStrategy XMLParser ..|> ParserStrategy + XMLParser -> pugixml + class Deserializer { - + set_target(Museum &) - + add_artist(uniq<ArtistData>) - + set_rows(unsigned int) - + set_cols(unsigned int) - + add_type(string, Color, unsigned int) - + add_tile(unsigned int x, unsigned int y, uniq<TileData>) + + 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" <<group>> { + 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<Tile *> + - museum : Museum & } class People { - + add_artist(uniq<ArtistData>) - - artists : Artist[] - } - class Museum { - - people : People - - canvas : Canvas + + People(Museum &) + -- + + add_artist(ArtistData) + + remove_artist(Artist &) + + get_artists() : forward_list<Artist *> + -- + - artists : forward_list<Artist> } 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" <<group>> { ' LAYOUT Artist -r[hidden] Tile } - rectangle Group_TileAppearance as "Tile appearance" <<group>> { struct Color { red : unsigned int @@ -152,36 +184,104 @@ rectangle Group_TileAppearance as "Tile appearance" <<group>> { Color <.. TileAppearance } rectangle Group_TileBehavior as "Tile behavior" <<group>> { - interface TileBehaviorStrategy + interface TileBehaviorStrategy { + + step(Artist *) + + update(Tile &) + + clone(Museum &) : uniq<TileBehaviorStrategy> + -- + # TileBehaviorStrategy(type : string) + # TileBehaviorStrategy() + -- + # interactions : unsigned int + # museum : Museum * + } - class TileBehavior + class TileBehavior { + + get_strategy(string) : TileBehaviorStrategy & <<static>> + + register_strategy(string, TileBehaviorStrategy *) <<static>> + -- + - get_collection() : TileBehaviorCollection & <<static>> + } together { - class NullTileBehavior - - class GrayTileBehavior - class RedTileBehavior - class BlueTileBehavior - class YellowTileBehavior - + class NullTileBehavior { + - type = "" <<static constexpr>> + } + class GrayTileBehavior { + - type = "G" : <<static constexpr>> + } + class RedTileBehavior { + - type = "R" : <<static constexpr>> + } + class BlueTileBehavior { + - type = "B" : <<static constexpr>> + -- + - update_neighbor(here : Tile &, dx, dy) + - dx : int + - dy : int + } + class YellowTileBehavior { + - type = "Y" : <<static constexpr>> + -- + - 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" <<group>> { + 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" <<group>> { struct Rectangle { x : unsigned int @@ -192,8 +292,18 @@ rectangle Group_Visualization as "Visualization" <<group>> { enum Scancode { } - package SDL2 { } + package SDL3 { } class View { + + window_size(width, height) + + dialog_file(callback : fn(files : vec<string>, 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" <<group>> { ViewController ..> View ViewController <-- View - View -> SDL2 -} - -rectangle Group_Commands as "Commands" <<group>> { - 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 |