diff options
-rw-r--r-- | Circuit.cpp | 6 | ||||
-rw-r--r-- | Circuit.h | 7 | ||||
-rw-r--r-- | main.cpp | 12 |
3 files changed, 16 insertions, 9 deletions
diff --git a/Circuit.cpp b/Circuit.cpp index 7da9384..23f49a6 100644 --- a/Circuit.cpp +++ b/Circuit.cpp @@ -35,6 +35,12 @@ void Circuit::new_net(string src, vector<string> dests) { node->setOutput(net); } +void Circuit::sim() { + for (auto & node : nodes) { + node.second->sim(); + } +} + Node * Circuit::find_node(string label) { auto map_index = this->nodes.find(label); if (map_index == nodes.end()) return nullptr; @@ -16,9 +16,10 @@ public: virtual ~Circuit(); public: - void create(string label, vector<string> nodes); - void new_node(string label, string type); - void new_net(string src, vector<string> dests); + virtual void create(string label, vector<string> nodes); + virtual void new_node(string label, string type); + virtual void new_net(string src, vector<string> dests); + virtual void sim(); private: std::map<string, Node *> nodes = {}; @@ -24,12 +24,12 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - // try { - // circuit.run(); - // } catch (exception& e) { - // cout << "Circuit error: " << e.what() << endl; - // return EXIT_FAILURE; - // } + try { + circuit.sim(); + } catch (CircuitException& e) { + cout << "Circuit error: " << e.what() << endl; + return EXIT_FAILURE; + } // cout << "Circuit output: " << circuit.getOutput() << endl; |