aboutsummaryrefslogtreecommitdiff
path: root/docs/class-diag.puml
blob: b32b9bf8bd2a94001dd62a5a1d7529eec701ee68 (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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
@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)
	+~Node()
	#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()
	+~Net()
	-level : SignalLevel
	+getLevel() : SignalLevel
	+setLevel(SignalLevel) : void
}

class Subject {
	+size() : int
	-observers : std::vector<Observer*>
	+attach(Observer* obs) : void
	+detach(Observer*) : void
	+notify() : void
}

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

class GateAnd {
	-GateAnd(const GateAnd* prototype)
	+GateAnd()
	+~GateAnd()
	+clone() : GateAnd*
	#level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static GateAnd
}

class GateNand {
	-level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static GateNand
}

class GateNor {
	-level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static GateNor
}

class GateNot {
	+GateNot()
	+GateNot(const GateNot* prototype)
	+~GateNot()
	+clone() : GateNot*
	-level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static GateNot
}

class GateOr {
	+GateOr()
	+GateOr(const GateOr* prototype)
	+~GateOr()
	+clone() : GateOr*
	#level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static GateOr
}

class GateXor {

}

class NodeInput {
	+NodeInput()
	+~NodeInput()
}


enum SignalLevel {
  LOW
	HIGH
	UNDEFINED
}

class NodeInputLow {
	-NodeInputLow(const NodeInputLow*)
	+clone() : NodeInputLow*
	#level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static NodeInputLow
}

class NodeInputHigh {
	-NodeInputHigh(const NodeInputHigh*)
	+clone() : NodeInputHigh*
	#level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static NodeInputHigh
}

class NodeOutput {
	-NodeOutput(const char* type)
	+NodeOutput()
	+NodeOutput(const NodeOutput* prototype)
	+~NodeOutput()
	+clone() : NodeOutput*
	-input : SignalLevel
	+level() : SignalLevel
	-{static} type : constexpr static const char*
	-{static} instance : static NodeOutput
	+accept(NodeVisitor& visitor) : void
	-init() : void
	+setOutput(Net*) : void
	+sim() : void
}

class NodeOutputVisitor {
	+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()
	+~Exception()
	#error : char*
	+what() : char*
	#va_format(va_list args, const char* fmt) : void
}

exception CircuitException {
	+CircuitException(const char* fmt, ...)
}

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

class Parser {
	+Parser()
	+Parser(Circuit& circuit)
	+~Parser()
	-circuit : Circuit*
	-operator<<(Parser& parser, istream s) : istream&
	-operator>>(istream s, Parser& parser) : istream&
	+{static} filter(char* input) : size_t
	+parse(string input) : void
	+parse(istream input) : void
	+set_circuit(Circuit& circuit) : void
}

class NodeFactory {
	+NodeFactory()
	+~NodeFactory()
	+{static} create(string type) : Node*
	-{static} find_type(string type) : Node*
	-{static} get_map() : NodeFactoryMap&
	+{static} has_type(const char* type) : bool
	+{static} has_type(string type) : bool
	-{static} normalize_type(string type) : string
	-{static} assign(const char* type, const Node* node) : void
}

class Circuit {
	+Circuit()
	+~Circuit()
	-find_node(string label) : Node*
	-nodes : std::map<string, Node*>
	+result() : string
	-nets : vector<Net*>
	+create(string label, vector<string> nodes) : void
	+new_net(string src, vector<string> dests) : void
	+new_node(string label, string type) : void
	+sim() : void
}

main --* Parser
main --* Circuit
main -- CircuitException
main -- ParserException
NodeOutputVisitor --|> NodeVisitor
NodeVisitor <- Node
NodeVisitor <- NodeOutput
NodeOutputVisitor <-left 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 <|-- Net
Observer <|-[dashed]- Node
Node -> "owner" Net
Observer "*" - Subject
Exception <|-- CircuitException
Exception <|-- ParserException
Parser -[dashed]> Circuit
ParserException - Parser
CircuitException -left Circuit
NodeFactory -[dashed]> Node
NodeFactory <-[dashed]- Node
Circuit ---> Net
Circuit ---> Node

@enduml