From 760520d490ef9a382aee9b0338ba289b1538974b Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:30:24 +0200 Subject: Renamed class Gate -> Node --- Gate.cpp | 47 ----------------------------------------------- Gate.h | 32 -------------------------------- Node.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ Node.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 Gate.cpp delete mode 100644 Gate.h create mode 100644 Node.cpp create mode 100644 Node.h diff --git a/Gate.cpp b/Gate.cpp deleted file mode 100644 index 0724b44..0000000 --- a/Gate.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Gate.h" - -#include - -Gate::Gate(){} -Gate::~Gate(){} -void Gate::addInput(Net* net){ - net->attach(this); -} -void Gate::setOutput(Net* net){ - this->output = net; -} - -void Gate::update(){ - std::cout << "updated" << std::endl; - this->compare(); -} - -/*/ Concrete Gates: /*/ - -void GateAnd::compare(){ - SignalLevel new_out = HIGH; - - // TODO fix segfault somewhere below - // for (int i = 0; i < this->inputs.size(); i++){ - // switch (this->inputs[i]->getLevel()){ - // case LOW: - // new_out = LOW; - // break; - // case HIGH: - // continue; - // break; - // case UNDEFINED: - // default: - // new_out = UNDEFINED; - // exit; - // break; - // } - // } - - // if (this->output->getLevel() == new_out){ - // /* do nothing */ - // } else { - // this->output->setLevel(new_out); - // } - -} diff --git a/Gate.h b/Gate.h deleted file mode 100644 index 3f34b7a..0000000 --- a/Gate.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include -#include - -#include "Observer.h" -#include "Net.h" - - - -class Gate: Observer { - protected: - std::string label; - std::string type; - - std::vector inputs; - Net* output; - - public: - Gate(/* args */); - virtual ~Gate(); - void update(); - virtual void addInput(Net*); - virtual void setOutput(Net*); - virtual void compare() = 0; -}; - -class GateAnd: public Gate { - public: - GateAnd(){}; - ~GateAnd(){}; - void compare(); -}; diff --git a/Node.cpp b/Node.cpp new file mode 100644 index 0000000..d351af1 --- /dev/null +++ b/Node.cpp @@ -0,0 +1,47 @@ +#include "Node.h" + +#include + +Node::Node(){} +Node::~Node(){} +void Node::addInput(Net* net){ + net->attach(this); +} +void Node::setOutput(Net* net){ + this->output = net; +} + +void Node::update(){ + std::cout << "updated" << std::endl; + this->compare(); +} + +/*/ Concrete Nodes: /*/ + +void GateAnd::compare(){ + SignalLevel new_out = HIGH; + + // TODO fix segfault somewhere below + // for (int i = 0; i < this->inputs.size(); i++){ + // switch (this->inputs[i]->getLevel()){ + // case LOW: + // new_out = LOW; + // break; + // case HIGH: + // continue; + // break; + // case UNDEFINED: + // default: + // new_out = UNDEFINED; + // exit; + // break; + // } + // } + + // if (this->output->getLevel() == new_out){ + // /* do nothing */ + // } else { + // this->output->setLevel(new_out); + // } + +} diff --git a/Node.h b/Node.h new file mode 100644 index 0000000..f1845a9 --- /dev/null +++ b/Node.h @@ -0,0 +1,32 @@ +#pragma once +#include +#include + +#include "Observer.h" +#include "Net.h" + + + +class Node: Observer { + protected: + std::string label; + std::string type; + + std::vector inputs; + Net* output; + + public: + Node(/* args */); + virtual ~Node(); + void update(); + virtual void addInput(Net*); + virtual void setOutput(Net*); + virtual void compare() = 0; +}; + +class GateAnd: public Node { + public: + GateAnd(){}; + ~GateAnd(){}; + void compare(); +}; -- cgit v1.2.3