00001 // -*- c++ -*- 00002 //***************************************************************************** 00016 //***************************************************************************** 00017 00018 #ifndef polybori_BooleVariable_h_ 00019 #define polybori_BooleVariable_h_ 00020 00021 // include basic definitions 00022 #include <polybori/pbori_defs.h> 00023 00024 // get BoolePolynomial's definition 00025 #include <polybori/BooleEnv.h> 00026 #include <polybori/BoolePolynomial.h> 00027 #include <polybori/BooleSet.h> 00028 00029 BEGIN_NAMESPACE_PBORI 00030 00039 class BooleVariable: 00040 public CAuxTypes { 00041 00043 typedef BooleVariable self; 00044 00045 public: 00046 00048 typedef BooleSet set_type; 00049 00051 typedef BoolePolyRing ring_type; 00052 00054 00058 00059 BooleVariable(idx_type idx, const ring_type& ring): 00060 m_poly( ring.variableDiagram(idx) ) {} 00061 00063 BooleVariable(const ring_type& ring): 00064 m_poly( ring.variableDiagram(0) ) {} 00065 00067 BooleVariable(const self& rhs): 00068 m_poly(rhs.m_poly) {} 00069 00071 operator const BoolePolynomial&() const { return m_poly; } 00072 00074 idx_type index() const { return *m_poly.firstBegin(); } 00075 00077 bool operator== (const self& other) const{ 00078 return m_poly==other.m_poly; 00079 } 00080 00081 // Nonequality check 00082 bool operator!= (const self& other) const{ 00083 return m_poly!=other.m_poly; 00084 } 00085 00087 hash_type stableHash() const{ return m_poly.stableHash(); } 00088 00090 hash_type hash() const { return m_poly.hash(); } 00091 00093 set_type set() const { return m_poly.set(); } 00094 00096 const ring_type& ring() const { return m_poly.ring(); } 00097 00098 private: 00099 friend class BoolePolyRing; 00100 BooleVariable(const BoolePolynomial& poly):m_poly(poly){} 00101 00102 BoolePolynomial m_poly; 00103 }; 00104 00105 00107 inline BoolePolynomial 00108 operator/(const BooleVariable& lhs, const BooleVariable& rhs) { 00109 return BoolePolynomial(BooleConstant(lhs == rhs), lhs.ring()); 00110 } 00111 00112 END_NAMESPACE_PBORI 00113 00114 #endif // of polybori_BooleVariable_h_