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

!theme plain
skinparam linetype ortho
skinparam classAttributeIconSize 0

class main {
	main(int argc, char** argv) : int
	open_input(int argc, char** argv) : istream*
}
hide main circle

class Node { /' (also ConcreteObserver) '/
	Node()
	#Node(const char* type)
	#output : Net*
	{abstract} clone() : Node*
	{abstract} level() : SignalLevel
	#max_inputs : int
	#min_inputs : int
	#inputs : vector<Net*>
	accept(NodeVisitor& visitor) : void
	addInput(Net*) : void
	setOutput(Net*) : void
	sim() : void
	update() : void
}

class Net { /' (also ConcreteSubject) '/
	Net()
	getLevel() : SignalLevel
	setLevel(SignalLevel) : void
}

class Subject {
	size() : int
	attach(Observer* obs) : void
	detach(Observer*) : void
	notify() : void
}

interface Observer {
	{abstract} update() : void
}

class GateAnd {
	clone() : GateAnd*
	level() : SignalLevel
}

class GateNand {
	clone() : GateNand*
	level() : SignalLevel
}

class GateNor {
	clone() : GateNor*
	level() : SignalLevel
}

class GateNot {
	clone() : GateNot*
	level() : SignalLevel
}

class GateOr {
	clone() : GateOr*
	level() : SignalLevel
}

class GateXor {
	clone() : GateXor*
	level() : SignalLevel
}

class NodeInput {
	NodeInput()
}


enum SignalLevel {
  LOW
	HIGH
	UNDEFINED
}

class NodeInputLow {
	clone() : NodeInputLow*
	level() : SignalLevel
}

class NodeInputHigh {
	clone() : NodeInputHigh*
	level() : SignalLevel
}

class NodeOutput {
	NodeOutput()
	clone() : NodeOutput*
	level() : SignalLevel
	accept(NodeVisitor& visitor) : void
	setOutput(Net*) : void
	sim() : void
}

class NodeOutputVisitor {
	NodeOutputVisitor()
	level : SignalLevel
	output_node : bool
	visit(Node& node) : void
	visit(NodeOutput& node) : void
}

interface NodeVisitor {
	{abstract} visit(NodeOutput& node) : void
	{abstract} visit(Node& node) : void
}

exception Exception {
	Exception(const char* fmt, ...)
	#Exception()
	#error : char*
	what() : char*
	#va_format(va_list args, const char* fmt) : void
}

exception CircuitException {
	CircuitException(const char* fmt, ...)
	node : Node*
}

exception ParserException {
	ParserException(const char* fmt, ...)
}

class NodeException {
	NodeException(Node* node, const char* fmt)
}

class Parser {
	Parser()
	Parser(Circuit& circuit)
	{static} filter(char* input) : size_t
	parse(string input) : void
	parse(istream input) : void
	set_circuit(Circuit& circuit) : void
}

class NodeFactory {
	NodeFactory()
	{static} create(string type) : Node*
	{static} has_type(const char* type) : bool
	{static} has_type(string type) : bool
}

class Circuit {
	Circuit()
	result() : string
	create(string label, vector<string> nodes) : void
	new_net(string src, vector<string> dests) : void
	new_node(string label, string type) : void
	sim() : void
}

class LoopDetection {
	LoopDetection()
	add_connection(string src, const vector<string>& dests) : void
}

main --* Parser
main --* Circuit
main -- CircuitException
main -- ParserException
NodeOutputVisitor --|> NodeVisitor
NodeVisitor <-[dashed] Node
NodeVisitor <-[dashed] NodeOutput
NodeOutputVisitor <--up Circuit
LoopDetection <-- Circuit
Net -- SignalLevel
Node -- SignalLevel
GateAnd <|-- GateNand
GateOr <|-- GateNor
Node <|--- GateAnd
Node <|--- GateNot
Node <|--- GateOr
Node <|--- GateXor
Node <|--- NodeOutput
Node <|--- NodeInput
NodeInput <|-- NodeInputLow
NodeInput <|-- NodeInputHigh
Subject <|--down Net
Observer <|-[dashed]down-Node
Observer -right Subject
Node -right> Net
Exception <|-- CircuitException
Exception <|-- ParserException
CircuitException <|-- NodeException
Parser -[dashed]> Circuit
ParserException - Parser
CircuitException -left Circuit
NodeException -left- Node
NodeFactory -[dashed]> Node
NodeFactory <-[dashed]- Node
Circuit ---> Net
Circuit ---> Node

@enduml