aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Circuit.cpp6
-rw-r--r--Circuit.h7
-rw-r--r--main.cpp12
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;
diff --git a/Circuit.h b/Circuit.h
index 1806293..0cc08c6 100644
--- a/Circuit.h
+++ b/Circuit.h
@@ -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 = {};
diff --git a/main.cpp b/main.cpp
index 01ddeb7..728155f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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;