@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 +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 +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 +result() : string -nets : vector +create(string label, vector nodes) : void +new_net(string src, vector 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