00001
00024 #ifndef INPUT_H_
00025 #define INPUT_H_
00026
00027 #include <string>
00028 #include <cassert>
00029
00030 #include "BaseOneInputGate.h"
00031 #include "LogicFunctions.h"
00032 #include "OneInputGate.h"
00033
00034
00035 class Input: public OneInputGate {
00036
00037 public:
00045 Input(size_t id, const std::string& outputName, const std::string& inputName)
00046 : OneInputGate (id, BUF(), outputName, inputName, 0l)
00047 {}
00048
00049
00050 Input (const Input & that)
00051 : OneInputGate (that) {}
00052
00053
00054 virtual Input* clone () const {
00055 return new Input (*this);
00056 }
00057
00058 virtual const std::string getGateName() const {
00059 return "Input";
00060 }
00061
00062 protected:
00063
00067 virtual LogicVal evalOutput() const {
00068 return this->BaseOneInputGate::inputVal;
00069 }
00070
00076 virtual void execEvent(Graph& graph, GNode& myNode, const EventTy& event) {
00077
00078 if (event.getType () == EventTy::NULL_EVENT) {
00079
00080
00081 OneInputGate::execEvent(graph, myNode, event);
00082
00083 } else {
00084
00085 const LogicUpdate& lu = (LogicUpdate) event.getAction ();
00086 if (this->BaseOneInputGate::outputName == lu.getNetName()) {
00087 this->BaseOneInputGate::inputVal = lu.getNetVal();
00088
00089 this->BaseOneInputGate::outputVal = this->BaseOneInputGate::inputVal;
00090
00091 LogicUpdate drvFanout(this->BaseOneInputGate::outputName, this->BaseOneInputGate::outputVal);
00092
00093 sendEventsToFanout(graph, myNode, event, EventTy::REGULAR_EVENT, drvFanout);
00094 } else {
00095 LogicGate::netNameMismatch(lu);
00096 }
00097
00098 }
00099
00100 }
00101
00102 };
00103 #endif