aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 13:19:46 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 13:19:46 +0200
commitf134abd08ccfdb1ece39df4d4a0e422419bd2fed (patch)
tree98a52327ce000c707793e084eaf9bf50ca16f4d5
parent126a3c79516a6417181c3fe924084032d653b596 (diff)
Created In/output nodes
-rw-r--r--NodeInput.cpp26
-rw-r--r--NodeInput.h43
-rw-r--r--NodeOutput.cpp18
-rw-r--r--NodeOutput.h16
4 files changed, 103 insertions, 0 deletions
diff --git a/NodeInput.cpp b/NodeInput.cpp
new file mode 100644
index 0000000..046cd72
--- /dev/null
+++ b/NodeInput.cpp
@@ -0,0 +1,26 @@
+#include "NodeInput.h"
+
+NodeInput::NodeInput(const char * type) : Node(type) { }
+
+void NodeInput::compare() {
+ if (this->output == nullptr) return;
+
+ this->output->setLevel(this->level);
+}
+
+NodeInput::NodeInput(const NodeInput * prototype) : Node() { }
+
+NodeInput * NodeInput::clone() const {
+ return new NodeInput(this);
+}
+
+// INPUT_LOW
+NodeInputLow NodeInputLow::instance(NodeInputLow::type);
+NodeInputLow::NodeInputLow(const char * type) : NodeInput() { }
+
+// NodeInputLow::NodeInputLow(const NodeInputLow * prototype) : NodeInput() { }
+
+// // INPUT_HIGH
+// NodeInputHigh NodeInputHigh::instance(NodeInputHigh::type);
+// NodeInputHigh::NodeInputHigh(const char * type) : NodeInput(type) { }
+// NodeInputHigh::NodeInputHigh(const NodeInputHigh * prototype) : NodeInput() { }
diff --git a/NodeInput.h b/NodeInput.h
new file mode 100644
index 0000000..73ef6e1
--- /dev/null
+++ b/NodeInput.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "Node.h"
+
+class NodeInput : public Node {
+public:
+ NodeInput() = default;
+ NodeInput(const NodeInput * prototype);
+ ~NodeInput() = default;
+ virtual void compare();
+ virtual NodeInput * clone() const;
+
+private:
+ NodeInput(const char * type);
+
+ SignalLevel level = UNDEFINED;
+};
+
+// Input LOW and HIGH unicorns:
+
+class NodeInputLow : public NodeInput {
+public:
+ // NodeInputLow(const NodeInputLow * prototype);
+ // ~NodeInputLow() = default;
+ // virtual void compare();
+ // virtual NodeInputLow * clone() const;
+
+private:
+ NodeInputLow(const char * type);
+ constexpr static const char * type = "input_low";
+ static NodeInputLow instance;
+
+ SignalLevel level = LOW;
+};
+
+class NodeInputHigh : public NodeInput {
+private:
+ NodeInputHigh(const char * type);
+ constexpr static const char * type = "input_high";
+ static NodeInputHigh instance;
+
+ SignalLevel level = HIGH;
+};
diff --git a/NodeOutput.cpp b/NodeOutput.cpp
new file mode 100644
index 0000000..cff66c0
--- /dev/null
+++ b/NodeOutput.cpp
@@ -0,0 +1,18 @@
+#include "NodeOutput.h"
+#include <iostream>
+
+NodeOutput NodeOutput::instance(NodeOutput::type);
+
+NodeOutput::NodeOutput(const char * type) : Node(type) { }
+
+void NodeOutput::compare() {
+ if (this->inputs.size() > 0) {
+ std::cout << this->inputs[0]->getLevel() << std::endl;
+ }
+}
+
+NodeOutput::NodeOutput(const NodeOutput * prototype) : Node() { }
+
+NodeOutput * NodeOutput::clone() const {
+ return new NodeOutput(this);
+} \ No newline at end of file
diff --git a/NodeOutput.h b/NodeOutput.h
new file mode 100644
index 0000000..4e7f742
--- /dev/null
+++ b/NodeOutput.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "Node.h"
+
+class NodeOutput : public Node {
+public:
+ NodeOutput(const NodeOutput * prototype);
+ ~NodeOutput() = default;
+ virtual void compare();
+ virtual NodeOutput * clone() const;
+
+private:
+ NodeOutput(const char * type);
+ constexpr static const char * type = "probe";
+ static NodeOutput instance;
+};