00001 00024 #ifndef _BASE_ONE_INPUT_GATE_H_ 00025 #define _BASE_ONE_INPUT_GATE_H_ 00026 00027 #include <string> 00028 #include <sstream> 00029 00030 #include "comDefs.h" 00031 #include "logicDefs.h" 00032 00033 class BaseOneInputGate { 00034 protected: 00035 00037 std::string outputName; 00038 00040 std::string inputName; 00041 00043 LogicVal outputVal; 00044 00046 LogicVal inputVal; 00047 00048 00049 public: 00056 BaseOneInputGate (const std::string& outputName, const std::string& inputName) 00057 : outputName (outputName), inputName (inputName), outputVal ('0'), inputVal ('0') {} 00058 00059 00060 00065 bool hasInputName(const std::string& net) const { 00066 return (inputName == (net)); 00067 } 00068 00073 bool hasOutputName(const std::string& net) const { 00074 return outputName == (net); 00075 } 00076 00080 const std::string toString() const { 00081 std::ostringstream ss; 00082 00083 ss << "output: " << outputName << " = " << outputVal << ", input: " << inputName << " = " << inputVal; 00084 return ss.str (); 00085 } 00086 00092 const std::string& getInputName() const { 00093 return inputName; 00094 } 00095 00101 void setInputName(const std::string& inputName) { 00102 this->inputName = inputName; 00103 } 00104 00110 const LogicVal& getInputVal() const { 00111 return inputVal; 00112 } 00113 00119 void setInputVal(const LogicVal& inputVal) { 00120 this->inputVal = inputVal; 00121 } 00122 00123 /* (non-Javadoc) 00124 * @see des.unordered.circuitlib.LogicGate#getOutputName() 00125 */ 00126 const std::string& getOutputName() const { 00127 return outputName; 00128 } 00129 00135 void setOutputName(const std::string& outputName) { 00136 this->outputName = outputName; 00137 } 00138 00144 const LogicVal& getOutputVal() const { 00145 return outputVal; 00146 } 00147 00153 void setOutputVal(const LogicVal& outputVal) { 00154 this->outputVal = outputVal; 00155 } 00156 }; 00157 00162 #endif