From bc02054d56118110a36aea72d21f9d5e73d07d1f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 22 Oct 2024 14:00:41 +0200 Subject: refactor file reading factory --- docs/class-diag.puml | 69 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 27 deletions(-) (limited to 'docs') diff --git a/docs/class-diag.puml b/docs/class-diag.puml index 8058e0a..6c38d9c 100644 --- a/docs/class-diag.puml +++ b/docs/class-diag.puml @@ -18,29 +18,31 @@ exception Exception { } rectangle Group_FileReading as "File reading" <> { - class FileReaderFactory <> { - + open(url) : FileReader& + class FileReaderFactory <> { + + create(url : const string &) : uniq } interface FileReader { - + read() : string + # FileReader(url : const string &) + + ~FileReader() + -- + # open() + + read() : const string + close() -- - # open(string url) - # clone() : FileReader* <> + # url : const string } class LocalFileReader { - - instance : LocalFileReader <> + + ~LocalFileReader() } class HTTPFileReader { - - instance : HTTPFileReader <> } package CPR { } - FileReader <|.u. LocalFileReader - FileReader <|.u. HTTPFileReader + FileReader <|.d. LocalFileReader + FileReader <|.d. HTTPFileReader - FileReader .l> FileReaderFactory - FileReader <. FileReaderFactory + FileReaderFactory -u-> LocalFileReader + FileReaderFactory -u-> HTTPFileReader HTTPFileReader -l> CPR @@ -59,20 +61,21 @@ rectangle Group_ParsingDeserialization as "Parsing & deserialization" <> + heuristic(FileReader &) : unsigned int <> } - Parser .> ParserFactory - Parser <. ParserFactory - - class CSVParser class XMLParser class TXTParser + class CSVParser package pugixml { } - CSVParser ..|> Parser - TXTParser ..|> Parser - XMLParser ..|> Parser + Parser <|.d. XMLParser + Parser <|.d. TXTParser + Parser <|.d. CSVParser + + ParserFactory -u-> XMLParser + ParserFactory -u-> TXTParser + ParserFactory -u-> CSVParser - XMLParser -> pugixml + XMLParser -r> pugixml class MuseumDeserializer { + MuseumDeserializer(Museum &) @@ -135,6 +138,7 @@ rectangle Group_Model as "Model" <> { - worker : thread * - work() } + together { class Canvas { + Canvas(Museum &) -- @@ -148,6 +152,10 @@ rectangle Group_Model as "Model" <> { - tiles : vector - museum : Museum & } + struct CanvasData { + + rows : unsigned int + + columns : unsigned int + } class People { + People(Museum &) -- @@ -159,6 +167,8 @@ rectangle Group_Model as "Model" <> { - artist_count : size_t - museum : Museum & } + } + together { class Tile { + data : TileData + color : Color @@ -190,11 +200,9 @@ rectangle Group_Model as "Model" <> { + vx : float + vy : float } - struct CanvasData { - + rows : unsigned int - + columns : unsigned int } + together { struct Color { red : unsigned int green : unsigned int @@ -204,7 +212,9 @@ rectangle Group_Model as "Model" <> { + get_color(string) : Color <> + register_color(string, Color) <> } + } + together { interface TileBehavior { + step(Artist *) + update(Tile &) @@ -214,13 +224,13 @@ rectangle Group_Model as "Model" <> { # interactions : unsigned int # museum : Museum & } - class TileBehaviorFactory { + TileBehaviorFactory(Museum &) + create(string) : uniq -- - museum : Museum & } + } together { class NullTileBehavior { @@ -243,8 +253,15 @@ rectangle Group_Model as "Model" <> { -- - last_interactions : unsigned int } + + NullTileBehavior -d[hidden]- StepTileBehavior + StepTileBehavior -d[hidden]- DeleteArtistTileBehavior + DeleteArtistTileBehavior -d[hidden]- SetNeighborTileBehavior + SetNeighborTileBehavior -d[hidden]- CreateArtistTileBehavior } + Canvas -l[hidden] People + Museum --> People Museum --> Canvas @@ -258,7 +275,7 @@ rectangle Group_Model as "Model" <> { Tile --> "state" Color Tile .[norank].> TileColorFactory - TileColorFactory .> Color + TileColorFactory -> Color TileBehavior <|.. NullTileBehavior TileBehavior <|.. StepTileBehavior @@ -275,9 +292,6 @@ rectangle Group_Model as "Model" <> { Tile --> "state" TileBehavior Tile .[norank].> TileBehaviorFactory - TileBehaviorFactory .l> TileBehavior - TileBehaviorFactory <. TileBehavior - ' LAYOUT Artist -r[hidden] Tile } @@ -378,6 +392,7 @@ rectangle Group_Commands as "Commands" <> { } /' LAYOUT '/ Parser .l> FileReader +' Parser -l> FileReaderFactory MuseumDeserializer .l> Museum Museum --> PathfindingContext -- cgit v1.2.3