From b8d946a4f14f7e32df9f3ddc325931283b771d8e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 25 Oct 2024 18:47:14 +0200 Subject: update class diagram & readme --- docs/class-diag.puml | 96 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 34 deletions(-) (limited to 'docs/class-diag.puml') diff --git a/docs/class-diag.puml b/docs/class-diag.puml index f695ed3..30e4a71 100644 --- a/docs/class-diag.puml +++ b/docs/class-diag.puml @@ -210,6 +210,7 @@ rectangle Group_Pathfinding as "Pathfinding" <> { PathfindingContext -> Pathfinder } rectangle Group_Model as "Model" <> { + together { class Museum { + people : People + canvas : Canvas @@ -218,16 +219,31 @@ rectangle Group_Model as "Model" <> { -- + paused : bool + update() + - tick_interval = 15ms <> + -- + skip_forward() + skip_backward() + - jump : int -- - - jump : unsigned long + - snapshot_ticks = 50 <> + - history : stack> + - save_snapshot() : vec + - restore_snapshot(const vec &) -- - working : bool - worker : thread * - work() } + interface Memento { + } + } together { + class CanvasDataMemento { + - data : CanvasData + } + class TileDataMemento { + - data : TileData + } class Canvas { + Canvas(Museum &) -- @@ -240,6 +256,9 @@ rectangle Group_Model as "Model" <> { -- + tile_color : TileColorFactory + tile_behavior : TileBehaviorFactory + -- + + save() : vec + + restore(const vec &) -- - tiles : vector - museum : Museum & @@ -248,6 +267,11 @@ rectangle Group_Model as "Model" <> { + rows : unsigned int + columns : unsigned int } + } + together { + class ArtistDataMemento { + - data : ArtistData + } class People { + People(Museum &) + update(tick : bool) @@ -255,14 +279,29 @@ rectangle Group_Model as "Model" <> { + add_artist(ArtistData) + remove_artist(Artist &) + get_artists() : forward_list + -- + + save() : vec + + restore(const vec &) -- - artists : forward_list - artist_count : size_t - museum : Museum & } - interface Memento { + class Artist { + + update(tick : bool) + + step : bool + + color : Color + + data : ArtistData + -- + - data : ArtistData + - museum : Museum & + } + struct ArtistData { + + x : float + + y : float + + vx : float + + vy : float } - People -r[hidden] Canvas } together { class Tile { @@ -281,40 +320,25 @@ rectangle Group_Model as "Model" <> { + y : unsigned int + type : string } - class Artist { - + update(tick : bool) - + step : bool - + color : Color - + data : ArtistData - -- - - data : ArtistData - - museum : Museum & - } - struct ArtistData { - + x : float - + y : float - + vx : float - + vy : float } + together { class TileColorFactory <> { + get_color(string) : Color <> + register_color(string, Color) <> } - class TileBehaviorFactory <> { - + TileBehaviorFactory(Museum &) - + create(string) : uniq - -- - - museum : Museum & - } - } - struct Color { red : unsigned int green : unsigned int blue : unsigned int } - + } together { + class TileBehaviorFactory <> { + + TileBehaviorFactory(Museum &) + + create(string) : uniq + -- + - museum : Museum & + } interface TileBehavior { + step(Artist *) + update(Tile &) @@ -329,19 +353,19 @@ rectangle Group_Model as "Model" <> { - type = "" <> } class StepTileBehavior { - - type = "G" : <> + - type = "G" <> } class DeleteArtistTileBehavior { - - type = "R" : <> + - type = "R" <> } class SetNeighborTileBehavior { - - type = "B" : <> + - type = "B" <> -- - dx : int - dy : int } class CreateArtistTileBehavior { - - type = "Y" : <> + - type = "Y" <> -- - last_interactions : unsigned int } @@ -362,7 +386,7 @@ rectangle Group_Model as "Model" <> { Canvas --> TileBehaviorFactory People --> Artist - Tile -> TileData + Tile --> TileData Artist -l> ArtistData Canvas -> CanvasData @@ -386,9 +410,13 @@ rectangle Group_Model as "Model" <> { Tile --> "state" TileBehavior Tile .[norank].> TileBehaviorFactory - Memento <|.[norank]. TileData - Memento <|.[norank]. ArtistData - Memento <|.[norank]. CanvasData + Memento <|.. TileDataMemento + Memento <|.. ArtistDataMemento + Memento <|.. CanvasDataMemento + Museum -[norank]-> Memento + People -[norank]-> ArtistDataMemento + Canvas -[norank]-> CanvasDataMemento + Canvas -[norank]-> TileDataMemento ' LAYOUT Artist -r[hidden] Tile -- cgit v1.2.3