aboutsummaryrefslogtreecommitdiff
path: root/docs/class-diag.puml
blob: 0da5b0fc4975b532ef2456a947eeb6e342ef590a (plain)
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
@startuml

' TODO:
' - state snapshots (memento)
' - send commands from GUI
' - TileAppearance should have some kind of tile type -> color registry
' - everything added by the algorithms
' - artist collision behavior (both edges and artist-artist)

!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 FileReader <<Factory>> {
		+open(url) : FileStrategy&
	}
	interface FileStrategy {
		+ read() : string
		+ close()
		--
		# open(string url)
		# clone() : FileStrategy* <<const>>
	}
	class LocalFile {
		- instance : LocalFile <<static>>
	}
	class HTTPFile {
		- instance : HTTPFile <<static>>
	}
	package CPR {
		class Response <<irrelevant>>
		class Url <<irrelevant>>
	}

	FileStrategy <|.. LocalFile
	FileStrategy <|.. HTTPFile

	FileStrategy <. FileReader
	FileStrategy .> FileReader

	HTTPFile --> CPR.Response
	CPR.Response - CPR.Url
}

rectangle Group_ParsingDeserialization as "Parsing & deserialization" <<group>> {
	class Parser {
		+ parse(File, Deserializer) <<static>>
		+ register_strategy(ParserStrategy) <<static>>
	}
	interface ParserStrategy  {
		+ parse(File, Deserializer) <<static>>
		+ heuristic(File) : unsigned int <<static>>
	}

	ParserStrategy .> Parser
	ParserStrategy <. Parser

	class CSVParser
	class XMLParser
	class TXTParser

	CSVParser ..|> ParserStrategy
	TXTParser ..|> ParserStrategy
	XMLParser ..|> ParserStrategy

	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>)
	}

	CSVParser -up-> Deserializer
	XMLParser -up-> Deserializer
	TXTParser -up-> Deserializer

	' ParserStrategy ..> Deserializer
}

rectangle Group_Model as "Model" <<group>> {
	class Canvas {
		+ get_tile(x, y)
		+ set_tile(x, y, TileData)
		- data : CanvasData
		- tiles : Tile[]
	}
	class People {
		+ add_artist(uniq<ArtistData>)
		- artists : Artist[]
	}
	class Museum {
		- people : People
		- canvas : Canvas
	}
	class Tile {
		+ data : TileData
	}
	struct TileData {
		+ type : string
	}
	class Artist {
		+ update()
		--
		- data : ArtistData
	}
	struct ArtistData {
		+ x : float
		+ y : float
		+ vx : float
		+ vy : float
	}
	struct CanvasData {
		+ rows : unsigned int
		+ columns : unsigned int
	}
	rectangle Group_Tile_Appearance as "Tile appearance" <<group>> {
		struct Color {
			red : unsigned int
			green : unsigned int
			blue : unsigned int
		}
		class TileAppearance {
			+ get_color(string) : Color <<static>>
			+ register_color(string, Color) <<static>>
		}

		Tile --> Color

		Color <.. TileAppearance
	}
	rectangle Group_Tile_Behavior as "Tile behavior" <<group>> {
		interface TileBehaviorStrategy

		class TileBehavior

		together {
			class NullTileBehavior

			class GrayTileBehavior
			class RedTileBehavior
			class BlueTileBehavior
			class YellowTileBehavior

			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

		Tile --> "state" TileBehavior

		TileBehavior .> TileBehaviorStrategy
		TileBehavior <. TileBehaviorStrategy
	}

	Museum --> People
	Museum --> Canvas

	Canvas --> Tile
	People --> Artist

	Tile   --> TileData
	Artist --> ArtistData

	Canvas -> CanvasData

	' LAYOUT
	Artist -r[hidden] Tile
}

rectangle "Visualization" <<group>> {
	struct Rectangle {
		x : unsigned int
		y : unsigned int
		width : unsigned int
		height : unsigned int
	}

	package SDL2 { }
	class View {
	}
	class ViewController {
		+ update()
	}

	ViewController --> View
	View --> SDL2
}

' PeopleDeserializer <... People
' CanvasDeserializer <... Canvas
' Deserializer       <... Museum

ParserStrategy ..> FileStrategy
' Museum .> Deserializer : friend
Deserializer .> Museum

@enduml