BooleConstant.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_BooleConstant_h_
#define polybori_BooleConstant_h_
// include basic definitions
#include <polybori/pbori_defs.h>
BEGIN_NAMESPACE_PBORI
class BooleConstant:
public CTypes {
typedef BooleConstant self;
public:
typedef const self* const_iterator;
BooleConstant(): m_value(false) {}
BooleConstant(bool value): m_value(value) {}
BooleConstant(short value): m_value(value % 2) {}
BooleConstant(unsigned short value): m_value(value % 2) {}
BooleConstant(int value): m_value(value % 2) {}
BooleConstant(unsigned int value): m_value(value % 2) {}
BooleConstant(long value): m_value(value % 2) {}
BooleConstant(unsigned long value): m_value(value % 2) {}
operator bool() const { return m_value; }
BooleConstant operator!() const { return !m_value; }
deg_type deg() const { return (m_value? 0: -1); }
const_iterator orderedBegin() const { return this; }
const_iterator orderedEnd() const { return this + (m_value? 1: 0); }
const_iterator variableBegin() const { return this; }
const_iterator variableEnd() const { return variableBegin(); }
bool isOne() const { return m_value; }
bool isZero() const { return !m_value; }
bool isConstant() const { return true; }
bool hasConstantPart() const { return isOne(); }
protected:
const bool m_value;
};
inline CTypes::ostream_type&
operator<<(CTypes::ostream_type& os, const BooleConstant& rhs) {
return (os << (int) rhs);
}
inline BooleConstant
operator+(const BooleConstant& lhs, const BooleConstant& rhs) {
return lhs ^ rhs;
}
inline BooleConstant
operator-(const BooleConstant& lhs, const BooleConstant& rhs) {
return lhs + rhs;
}
inline BooleConstant
operator*(const BooleConstant& lhs, const BooleConstant& rhs) {
return lhs && rhs;
}
END_NAMESPACE_PBORI
#endif // polybori_BooleConstant_h_
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::BooleConstant::BooleConstant
BooleConstant()
Default constructor.
Definition: BooleConstant.h:50
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
polybori::BooleConstant::operator!
BooleConstant operator!() const
Negation operation.
Definition: BooleConstant.h:77
polybori::BooleConstant::deg
deg_type deg() const
Get constant degree.
Definition: BooleConstant.h:80
polybori::CAuxTypes::deg_type
int deg_type
Type for polynomial degrees (ranges from -1 to maxint)
Definition: pbori_defs.h:222
polybori::BooleConstant::BooleConstant
BooleConstant(unsigned long value)
Constructor for unsigned long integer values (nontrivial conversion)
Definition: BooleConstant.h:71
polybori::operator-
BooleConstant operator-(const BooleConstant &lhs, const BooleConstant &rhs)
Definition: BooleConstant.h:119
polybori::BooleConstant::isOne
bool isOne() const
Mimic constant monomial or polynmomial term.
Definition: BooleConstant.h:96
polybori::BooleConstant::BooleConstant
BooleConstant(unsigned short value)
Constructor for unsigned shoer integer values (nontrivial conversion)
Definition: BooleConstant.h:59
polybori::BooleConstant::BooleConstant
BooleConstant(unsigned int value)
Constructor for unsigned integer values (nontrivial conversion)
Definition: BooleConstant.h:65
polybori::CAuxTypes::ostream_type
std::ostream ostream_type
Type for out-stream.
Definition: pbori_defs.h:246
polybori::operator+
BooleConstant operator+(const BooleConstant &lhs, const BooleConstant &rhs)
Definition: BooleConstant.h:114
polybori::BooleConstant::BooleConstant
BooleConstant(short value)
Constructor for short integer values (nontrivial conversion)
Definition: BooleConstant.h:56
pbori_defs.h
polybori::BooleConstant::isConstant
bool isConstant() const
Definition: BooleConstant.h:98
polybori::BooleConstant::m_value
const bool m_value
Boolean value is stored as simple bool.
Definition: BooleConstant.h:104
polybori::BooleConstant::const_iterator
const self * const_iterator
Define dummy iterator.
Definition: BooleConstant.h:47
polybori::BooleConstant::isZero
bool isZero() const
Definition: BooleConstant.h:97
polybori::BooleConstant::orderedEnd
const_iterator orderedEnd() const
Finish polynomial-style iterations.
Definition: BooleConstant.h:86
polybori::BooleConstant::variableBegin
const_iterator variableBegin() const
Start empty monomial iteration.
Definition: BooleConstant.h:89
polybori::BooleConstant::BooleConstant
BooleConstant(bool value)
constructor for bool values
Definition: BooleConstant.h:53
polybori::BooleConstant::variableEnd
const_iterator variableEnd() const
Finish empty monomial iteration.
Definition: BooleConstant.h:92
polybori::BooleConstant::BooleConstant
BooleConstant(int value)
Constructor for integer values (nontrivial conversion)
Definition: BooleConstant.h:62
polybori::operator<<
CTypes::ostream_type & operator<<(CTypes::ostream_type &os, const BooleConstant &rhs)
Stream output operator.
Definition: BooleConstant.h:109
polybori::operator*
BooleConstant operator*(const BooleConstant &lhs, const BooleConstant &rhs)
Definition: BooleConstant.h:124
polybori::BooleConstant
This class wraps a bool value, which was not converted to a boolean polynomial or monomial yet...
Definition: BooleConstant.h:40
polybori::BooleConstant::orderedBegin
const_iterator orderedBegin() const
Start polynomial-style iterations.
Definition: BooleConstant.h:83
polybori::BooleConstant::BooleConstant
BooleConstant(long value)
Constructor for long integer values (nontrivial conversion)
Definition: BooleConstant.h:68
polybori::CTypes
This struct contains type definitions to be used in library classes.
Definition: pbori_defs.h:269
polybori::BooleConstant::hasConstantPart
bool hasConstantPart() const
Definition: BooleConstant.h:99