diff options
-rw-r--r-- | Net.h | 7 | ||||
-rw-r--r-- | NodeFactory.cpp | 4 | ||||
-rw-r--r-- | NodeOutputVisitor.cpp | 2 | ||||
-rw-r--r-- | SignalLevel.cpp | 9 | ||||
-rw-r--r-- | SignalLevel.h | 14 |
5 files changed, 28 insertions, 8 deletions
@@ -1,12 +1,7 @@ #pragma once #include "Observer.h" - -enum SignalLevel { - LOW, - HIGH, - UNDEFINED -}; +#include "SignalLevel.h" class Net : public Subject { private: diff --git a/NodeFactory.cpp b/NodeFactory.cpp index c9d4f20..6105c2d 100644 --- a/NodeFactory.cpp +++ b/NodeFactory.cpp @@ -1,3 +1,4 @@ +#include <cassert> #include <locale> #include <ranges> #include <algorithm> @@ -22,7 +23,8 @@ void NodeFactory::assign(const char * _type, const Node * node) { string type = _type; type = normalize_type(type); - if (has_type(type)) return; // TODO: exception? + // ensure there is only one class that registers a type + assert(!has_type(type)); // printf("map[\"%s\"] = %p\n", type.c_str(), node); map[type] = node; diff --git a/NodeOutputVisitor.cpp b/NodeOutputVisitor.cpp index ca00fd4..e92224c 100644 --- a/NodeOutputVisitor.cpp +++ b/NodeOutputVisitor.cpp @@ -2,7 +2,7 @@ void NodeOutputVisitor::visit(Node & node) { } void NodeOutputVisitor::visit(NodeOutput & node) { - level = node.level(); // TODO: dit klopt niet + level = node.level(); output_node = true; } diff --git a/SignalLevel.cpp b/SignalLevel.cpp new file mode 100644 index 0000000..daba33c --- /dev/null +++ b/SignalLevel.cpp @@ -0,0 +1,9 @@ +#include "SignalLevel.h" + +std::string std::to_string(SignalLevel level) { + if (level == HIGH) return "HIGH"; + if (level == LOW) return "LOW"; + if (level == UNDEFINED) return "UNDEFINED"; + return "???"; +} + diff --git a/SignalLevel.h b/SignalLevel.h new file mode 100644 index 0000000..81c7ff8 --- /dev/null +++ b/SignalLevel.h @@ -0,0 +1,14 @@ +#pragma once + +#include <string> + +enum SignalLevel { + LOW, + HIGH, + UNDEFINED +}; + +namespace std { + std::string to_string(SignalLevel level); +} + |