| 1 |
|
|---|
| 2 | #ifndef __LOGICVALUE_H__
|
|---|
| 3 | #define __LOGICVALUE_H__
|
|---|
| 4 |
|
|---|
| 5 | #include <iostream>
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | class LogicValue {
|
|---|
| 9 | public:
|
|---|
| 10 | enum Value { Zero=0, One=1, Undefined=2 };
|
|---|
| 11 | public:
|
|---|
| 12 | LogicValue ();
|
|---|
| 13 | LogicValue ( int );
|
|---|
| 14 | ~LogicValue ();
|
|---|
| 15 | void print ( std::ostream& ) const;
|
|---|
| 16 | int toInt () const;
|
|---|
| 17 | void fromInt ( int );
|
|---|
| 18 | private:
|
|---|
| 19 | Value _value;
|
|---|
| 20 |
|
|---|
| 21 | friend bool operator == ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 22 | friend bool operator != ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 23 | };
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | LogicValue operator not ( const LogicValue& lhs );
|
|---|
| 27 | LogicValue operator and ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 28 | LogicValue operator or ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 29 | LogicValue operator xor ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 30 | bool operator == ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 31 | bool operator != ( const LogicValue& lhs, const LogicValue& rhs );
|
|---|
| 32 |
|
|---|
| 33 | inline std::ostream& operator<< ( std::ostream& o, const LogicValue& v ) { v.print(o); return o; }
|
|---|
| 34 |
|
|---|
| 35 | #endif // __LOGICVALUE_H__
|
|---|