1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
@startuml
!include style.ipuml
' !include hide-groups.ipuml
' !include hide-details.ipuml
class main as "main()"
hide main circle
hide main members
exception Exception {
+ Exception(const char* fmt, ...)
+ what() : const char*
--
# error : char*
# va_format(va_list args, const char* fmt)
}
rectangle Group_FileReading as "File reading" <<group>> {
class FileReaderFactory <<Factory>> {
+ open(url) : FileReader&
}
interface FileReader {
+ read() : string
+ close()
--
# open(string url)
# clone() : FileReader* <<const>>
}
class LocalFileReader {
- instance : LocalFileReader <<static>>
}
class HTTPFileReader {
- instance : HTTPFileReader <<static>>
}
package CPR { }
FileReader <|.u. LocalFileReader
FileReader <|.u. HTTPFileReader
FileReader .l> FileReaderFactory
FileReader <. FileReaderFactory
HTTPFileReader -l> CPR
' LAYOUT
HTTPFileReader -r[hidden] LocalFileReader
}
rectangle Group_ParsingDeserialization as "Parsing & deserialization" <<group>> {
class ParserFactory {
+ parse(FileReader &, MuseumDeserializer &) <<static>>
+ register_strategy(Parser *) <<static>>
--
- get_collection() : ParserCollection <<static>>
}
interface Parser {
+ parse(FileReader &, MuseumDeserializer &) <<static>>
+ heuristic(FileReader &) : unsigned int <<static>>
}
Parser .> ParserFactory
Parser <. ParserFactory
class CSVParser
class XMLParser
class TXTParser
package pugixml { }
CSVParser ..|> Parser
TXTParser ..|> Parser
XMLParser ..|> Parser
XMLParser -> pugixml
class MuseumDeserializer {
+ MuseumDeserializer(Museum &)
--
+ set_canvas(CanvasData)
+ set_tile(TileData)
+ add_artist(ArtistData)
+ add_type(type : string, Color, weight : unsigned int)
}
CSVParser -up-> MuseumDeserializer
XMLParser -up-> MuseumDeserializer
TXTParser -up-> MuseumDeserializer
' LAYOUT
CSVParser -r[hidden] TXTParser
TXTParser -r[hidden] XMLParser
}
rectangle Group_Algorithms as "Algorithms" <<group>> {
class PathfindingContext {
+ PathfindingContext(Museum &)
}
class CollisionContext {
+ CollisionContext(Museum &)
}
}
rectangle Group_Model as "Model" <<group>> {
class Museum {
+ people : People
+ canvas : Canvas
--
+ update()
--
- paused : bool <<+get>> <<+set>>
- jump : unsigned long
--
- working : bool
- worker : thread *
- work()
}
class Canvas {
+ Canvas(Museum &)
--
+ get_tile(x, y) : Tile &
+ set_tile(TileData)
--
+ update()
+ data : CanvasData
+ set_data(CanvasData)
--
- tiles : vector<Tile *>
- museum : Museum &
}
class People {
+ People(Museum &)
--
+ add_artist(ArtistData)
+ remove_artist(Artist &)
+ get_artists() : forward_list<Artist *>
--
- artists : forward_list<Artist *>
- artist_count : size_t
- museum : Museum &
}
class Tile {
+ data : TileData
+ color : Color
+ behavior : uniq<TileBehavior>
+ set_data(TileData &)
+ set_type(type : const string &)
+ update()
+ get_neighbor(dx, dy) : Tile *
--
- museum : Museum &
}
struct TileData {
+ x : unsigned int
+ y : unsigned int
+ type : string
}
class Artist {
+ update()
+ step : bool
+ color : Color
+ data : ArtistData
--
- data : ArtistData
- museum : Museum &
}
struct ArtistData {
+ x : float
+ y : float
+ vx : float
+ vy : float
}
struct CanvasData {
+ rows : unsigned int
+ columns : unsigned int
}
struct Color {
red : unsigned int
green : unsigned int
blue : unsigned int
}
class TileColorFactory <<singleton>> {
+ get_color(string) : Color <<static>>
+ register_color(string, Color) <<static>>
}
interface TileBehavior {
+ step(Artist *)
+ update(Tile &)
--
# TileBehavior(Museum &)
--
# interactions : unsigned int
# museum : Museum &
}
class TileBehaviorFactory {
+ TileBehaviorFactory(Museum &)
+ create(string) : uniq<TileBehavior>
--
- museum : Museum &
}
together {
class NullTileBehavior {
- type = "" <<static constexpr>>
}
class StepTileBehavior {
- type = "G" : <<static constexpr>>
}
class DeleteArtistTileBehavior {
- type = "R" : <<static constexpr>>
}
class SetNeighborTileBehavior {
- type = "B" : <<static constexpr>>
--
- dx : int
- dy : int
}
class CreateArtistTileBehavior {
- type = "Y" : <<static constexpr>>
--
- last_interactions : unsigned int
}
}
Museum --> People
Museum --> Canvas
Canvas --> Tile
People --> Artist
Tile -> TileData
Artist -l> ArtistData
Canvas -> CanvasData
Tile --> "state" Color
Tile .[norank].> TileColorFactory
TileColorFactory .> Color
TileBehavior <|.. NullTileBehavior
TileBehavior <|.. StepTileBehavior
TileBehavior <|.. DeleteArtistTileBehavior
TileBehavior <|.. SetNeighborTileBehavior
TileBehavior <|.. CreateArtistTileBehavior
TileBehaviorFactory --> NullTileBehavior
TileBehaviorFactory --> StepTileBehavior
TileBehaviorFactory --> DeleteArtistTileBehavior
TileBehaviorFactory --> SetNeighborTileBehavior
TileBehaviorFactory --> CreateArtistTileBehavior
Tile --> "state" TileBehavior
Tile .[norank].> TileBehaviorFactory
TileBehaviorFactory .l> TileBehavior
TileBehaviorFactory <. TileBehavior
' LAYOUT
Artist -r[hidden] Tile
}
together { /' LAYOUT '/
rectangle Group_Visualization as "Visualization" <<group>> {
struct Rectangle {
x : unsigned int
y : unsigned int
width : unsigned int
height : unsigned int
}
enum MouseCode { }
enum KeyboardCode { }
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()
+ ev_keydown(KeyboardCode);
+ ev_mousedown(MouseCode);
+ ev_mousemove(x, y);
--
- draw_artists : bool <<+get>> <<+set>>
}
ViewController ..> View
ViewController <-- View
View --> SDL3
View .l> Rectangle
ViewController .l> KeyboardCode
ViewController .l> MouseCode
}
rectangle Group_Commands as "Commands" <<group>> {
interface Command {
+ execute()
}
class ToggleMuseumPauseCommand {
+ constructor(Museum &)
+ constructor(Museum &, set : bool)
--
toggle : bool
value : bool
}
class OpenFileGUICommand {
+ constructor(Museum &, View &)
--
- museum : Museum &
- view : View &
}
class ToggleArtistVisibilityCommand {
+ constructor(ViewController &)
--
- controller : ViewController &
}
class LoadFilesCommand {
+ constructor(Museum &, files : vec<string>)
+ constructor(Museum &, argc, argv)
--
- load_files()
- museum : Museum &
- files : vec<string>
}
class StepTileCommand {
+ constructor(Canvas &, pair<x, y>)
--
- canvas : Canvas &
- x : unsigned int
- y : unsigned int
}
class TimeTravelCommand {
+ constructor(Museum &, forwards : bool)
--
- museum : Museum &
- forwards : bool
}
Command <|-d- ToggleMuseumPauseCommand
Command <|-u- OpenFileGUICommand
Command <|-u- ToggleArtistVisibilityCommand
Command <|-d- StepTileCommand
Command <|-d- LoadFilesCommand
Command <|-d- TimeTravelCommand
}
} /' LAYOUT '/
Parser .l> FileReader
MuseumDeserializer .l> Museum
Museum --> PathfindingContext
Museum --> CollisionContext
ViewController -[norank]> Command
main -d-> Museum
main -u-> LoadFilesCommand
' main -[norank]> MuseumDeserializer
main -[norank]> View
main .r> Exception
@enduml
|