COPASI API  4.16.103
Public Types | Public Member Functions | Protected Attributes | List of all members
CNormalLogicalItem Class Reference

#include <CNormalLogicalItem.h>

Inheritance diagram for CNormalLogicalItem:
Inheritance graph
[legend]
Collaboration diagram for CNormalLogicalItem:
Collaboration graph
[legend]

Public Types

enum  Type {
  TRUE, FALSE, EQ, NE,
  LT, GT, GE, LE,
  INVALID
}
 

Public Member Functions

 CNormalLogicalItem ()
 
 CNormalLogicalItem (const CNormalLogicalItem &src)
 
virtual CNormalBasecopy () const
 
CNormalFractiongetLeft ()
 
const CNormalFractiongetLeft () const
 
CNormalFractiongetRight ()
 
const CNormalFractiongetRight () const
 
Type getType () const
 
void negate ()
 
bool operator< (const CNormalLogicalItem &rhs) const
 
CNormalLogicalItemoperator= (const CNormalLogicalItem &src)
 
bool operator== (const CNormalLogicalItem &rhs) const
 
bool setLeft (const CNormalFraction &left)
 
bool setRight (const CNormalFraction &right)
 
void setType (Type type)
 
virtual bool simplify ()
 
virtual std::string toString () const
 
virtual ~CNormalLogicalItem ()
 
- Public Member Functions inherited from CNormalBase
virtual bool areEqual (const CNormalBase &rhs) const
 
virtual ~CNormalBase ()
 

Protected Attributes

CNormalFraction mLeft
 
CNormalFraction mRight
 
Type mType
 

Detailed Description

Definition at line 22 of file CNormalLogicalItem.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

CNormalLogicalItem::CNormalLogicalItem ( )
CNormalLogicalItem::CNormalLogicalItem ( const CNormalLogicalItem src)

Definition at line 27 of file CNormalLogicalItem.cpp.

27  : CNormalBase(src), mType(src.mType), mLeft(src.mLeft), mRight(src.mRight)
28 {}
CNormalFraction mLeft
CNormalFraction mRight
CNormalLogicalItem::~CNormalLogicalItem ( )
virtual

Definition at line 30 of file CNormalLogicalItem.cpp.

31 {}

Member Function Documentation

CNormalBase * CNormalLogicalItem::copy ( ) const
virtual

Implements CNormalBase.

Definition at line 62 of file CNormalLogicalItem.cpp.

References CNormalLogicalItem().

63  {
64  return new CNormalLogicalItem(*this);
65  }
CNormalFraction & CNormalLogicalItem::getLeft ( )

Definition at line 126 of file CNormalLogicalItem.cpp.

References mLeft.

Referenced by convertToCEvaluationNode(), and normalize_variable_names().

127 {
128  return this->mLeft;
129 }
CNormalFraction mLeft
const CNormalFraction & CNormalLogicalItem::getLeft ( ) const

Definition at line 131 of file CNormalLogicalItem.cpp.

References mLeft.

132  {
133  return this->mLeft;
134  }
CNormalFraction mLeft
CNormalFraction & CNormalLogicalItem::getRight ( )

Definition at line 136 of file CNormalLogicalItem.cpp.

References mRight.

Referenced by convertToCEvaluationNode(), and normalize_variable_names().

137 {
138  return this->mRight;
139 }
CNormalFraction mRight
const CNormalFraction & CNormalLogicalItem::getRight ( ) const

Definition at line 141 of file CNormalLogicalItem.cpp.

References mRight.

142  {
143  return this->mRight;
144  }
CNormalFraction mRight
CNormalLogicalItem::Type CNormalLogicalItem::getType ( ) const

Definition at line 166 of file CNormalLogicalItem.cpp.

References mType.

Referenced by convertToCEvaluationNode(), CNormalLogical::eliminateNullItems(), and CNormalLogical::simplify().

167  {
168  return this->mType;
169  }
void CNormalLogicalItem::negate ( )

Definition at line 192 of file CNormalLogicalItem.cpp.

References EQ, FALSE, GE, GT, INVALID, LE, LT, mType, NE, and TRUE.

Referenced by CNormalLogical::eliminateNullItems(), CNormalLogical::generateCanonicalDNF(), and CNormalLogical::simplify().

193 {
194  switch (this->mType)
195  {
196  case TRUE:
197  this->mType = FALSE;
198  break;
199  case FALSE:
200  this->mType = TRUE;
201  break;
202  case EQ:
203  this->mType = NE;
204  break;
205  case NE:
206  this->mType = EQ;
207  break;
208  case GT:
209  this->mType = LE;
210  break;
211  case LT:
212  this->mType = GE;
213  break;
214  case LE:
215  this->mType = GT;
216  break;
217  case GE:
218  this->mType = LT;
219  break;
220  case INVALID:
221  break;
222  }
223 }
bool CNormalLogicalItem::operator< ( const CNormalLogicalItem rhs) const

Definition at line 41 of file CNormalLogicalItem.cpp.

References mLeft, mRight, and mType.

42  {
43  bool result = false;
44  if (this->mType < rhs.mType)
45  {
46  result = true;
47  }
48  else if (this->mType == rhs.mType)
49  {
50  if (this->mLeft == rhs.mLeft)
51  {
52  result = (this->mRight < rhs.mRight);
53  }
54  else
55  {
56  result = (this->mLeft < rhs.mLeft);
57  }
58  }
59  return result;
60  }
CNormalFraction mLeft
CNormalFraction mRight
CNormalLogicalItem & CNormalLogicalItem::operator= ( const CNormalLogicalItem src)

Definition at line 33 of file CNormalLogicalItem.cpp.

References mLeft, mRight, and mType.

34 {
35  this->mType = src.mType;
36  this->mLeft = src.mLeft;
37  this->mRight = src.mRight;
38  return *this;
39 }
CNormalFraction mLeft
CNormalFraction mRight
bool CNormalLogicalItem::operator== ( const CNormalLogicalItem rhs) const

Definition at line 225 of file CNormalLogicalItem.cpp.

References mLeft, mRight, and mType.

226  {
227  bool result = true;
228  if (this->mType == rhs.mType)
229  {
230  result = (this->mLeft == rhs.mLeft);
231  if (result)
232  {
233  result = (this->mRight == rhs.mRight);
234  }
235  }
236  else
237  {
238  result = false;
239  }
240  return result;
241  }
CNormalFraction mLeft
CNormalFraction mRight
bool CNormalLogicalItem::setLeft ( const CNormalFraction left)

Definition at line 146 of file CNormalLogicalItem.cpp.

References FALSE, mLeft, mType, and TRUE.

Referenced by createLogicalItem().

147 {
148  bool result = false;
150  {
151  this->mLeft = left;
152  }
153  return result;
154 }
CNormalFraction mLeft
bool CNormalLogicalItem::setRight ( const CNormalFraction right)

Definition at line 156 of file CNormalLogicalItem.cpp.

References FALSE, mRight, mType, and TRUE.

Referenced by createLogicalItem().

157 {
158  bool result = false;
160  {
161  this->mRight = right;
162  }
163  return result;
164 }
CNormalFraction mRight
void CNormalLogicalItem::setType ( CNormalLogicalItem::Type  type)

Definition at line 171 of file CNormalLogicalItem.cpp.

References FALSE, mLeft, mRight, mType, and TRUE.

Referenced by createLogicalItem(), CNormalLogical::eliminateNullItems(), and CNormalLogical::simplify().

172 {
173  switch (type)
174  {
177  this->mLeft = CNormalFraction();
178  this->mRight = CNormalFraction();
179  break;
180  default:
181  break;
182  }
183  this->mType = type;
184 }
CNormalFraction mLeft
CNormalFraction mRight
bool CNormalLogicalItem::simplify ( )
virtual

Implements CNormalBase.

Definition at line 102 of file CNormalLogicalItem.cpp.

References GE, GT, LE, LT, mLeft, mRight, mType, and CNormalFraction::simplify().

Referenced by CNormalLogical::eliminateNullItems(), and CNormalLogical::generateCanonicalDNF().

103 {
104  bool result = true;
105  if (this->mType == GT)
106  {
107  // replace by LT and switch mpLeft and mpRight
108  this->mType = LT;
109  CNormalFraction TMP = this->mLeft;
110  this->mLeft = this->mRight;
111  this->mRight = TMP;
112  }
113  else if (this->mType == GE)
114  {
115  // replace by LE and switch mpLeft and mpRight
116  this->mType = LE;
117  CNormalFraction TMP = this->mLeft;
118  this->mLeft = this->mRight;
119  this->mRight = TMP;
120  }
121  result &= this->mLeft.simplify();
122  if (result) result &= this->mRight.simplify();
123  return result;
124 }
virtual bool simplify()
CNormalFraction mLeft
CNormalFraction mRight
std::string CNormalLogicalItem::toString ( ) const
virtual

Implements CNormalBase.

Definition at line 67 of file CNormalLogicalItem.cpp.

References EQ, FALSE, GE, GT, INVALID, LE, LT, mLeft, mRight, mType, NE, and TRUE.

Referenced by operator<<().

68  {
69  std::ostringstream str;
70  switch (this->mType)
71  {
73  str << "TRUE";
74  break;
76  str << "FALSE";
77  break;
79  str << "(" << this->mLeft << " == " << this->mRight << ")";
80  break;
82  str << "(" << this->mLeft << " != " << this->mRight << ")";
83  break;
85  str << "(" << this->mLeft << " < " << this->mRight << ")";
86  break;
88  str << "(" << this->mLeft << " > " << this->mRight << ")";
89  break;
91  str << "(" << this->mLeft << " >= " << this->mRight << ")";
92  break;
94  str << "(" << this->mLeft << " <= " << this->mRight << ")";
95  break;
96  case INVALID:
97  break;
98  }
99  return str.str();
100  }
CNormalFraction mLeft
CNormalFraction mRight

Member Data Documentation

CNormalFraction CNormalLogicalItem::mLeft
protected
CNormalFraction CNormalLogicalItem::mRight
protected
Type CNormalLogicalItem::mType
protected

The documentation for this class was generated from the following files: