00001 00024 #ifndef _BASE_TWO_INPUT_GATE_H_ 00025 #define _BASE_TWO_INPUT_GATE_H_ 00026 00027 #include <string> 00028 #include <sstream> 00029 00030 #include "comDefs.h" 00031 #include "logicDefs.h" 00032 00033 class BaseTwoInputGate { 00034 protected: 00035 00037 std::string outputName; 00038 00040 std::string input1Name; 00041 00043 std::string input2Name; 00044 00046 LogicVal outputVal; 00047 00049 LogicVal input1Val; 00050 00052 LogicVal input2Val; 00053 00054 00055 public: 00063 BaseTwoInputGate (const std::string& outputName, const std::string& input1Name, const std::string& input2Name) 00064 : outputName (outputName), input1Name (input1Name), input2Name (input2Name) 00065 , outputVal ('0'), input1Val ('0'), input2Val ('0') {} 00066 00067 00072 bool hasInputName(const std::string& net) const { 00073 return (input1Name == (net) || input2Name == (net)); 00074 } 00075 00080 bool hasOutputName(const std::string& net) const { 00081 return outputName == (net); 00082 } 00083 00087 const std::string toString() const { 00088 std::ostringstream ss; 00089 ss << "output: " << outputName << " = " << outputVal << " input1: " << input1Name << " = " 00090 << input1Val << " input2: " << input2Name << " = " << input2Val; 00091 return ss.str (); 00092 } 00093 00099 const std::string& getInput1Name() const { 00100 return input1Name; 00101 } 00102 00108 void setInput1Name(const std::string& input1Name) { 00109 this->input1Name = input1Name; 00110 } 00111 00117 const LogicVal& getInput1Val() const { 00118 return input1Val; 00119 } 00120 00126 void setInput1Val(const LogicVal& input1Val) { 00127 this->input1Val = input1Val; 00128 } 00129 00135 const std::string& getInput2Name() { 00136 return input2Name; 00137 } 00138 00144 void setInput2Name(const std::string& input2Name) { 00145 this->input2Name = input2Name; 00146 } 00147 00153 const LogicVal& getInput2Val() const { 00154 return input2Val; 00155 } 00156 00162 void setInput2Val(const LogicVal& input2Val) { 00163 this->input2Val = input2Val; 00164 } 00165 00169 const std::string& getOutputName() const { 00170 return outputName; 00171 } 00172 00178 void setOutputName(const std::string& outputName) { 00179 this->outputName = outputName; 00180 } 00181 00187 const LogicVal& getOutputVal() const { 00188 return outputVal; 00189 } 00190 00196 void setOutputVal (const LogicVal& outputVal) { 00197 this->outputVal = outputVal; 00198 } 00199 }; 00200 00201 #endif