COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
CNormalChoiceLogical Class Reference

#include <CNormalChoiceLogical.h>

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

Public Member Functions

 CNormalChoiceLogical ()
 
 CNormalChoiceLogical (const CNormalChoiceLogical &src)
 
virtual CNormalBasecopy () const
 
const CNormalLogicalgetCondition () const
 
CNormalLogicalgetCondition ()
 
const CNormalLogicalgetFalseExpression () const
 
CNormalLogicalgetFalseExpression ()
 
const CNormalLogicalgetTrueExpression () const
 
CNormalLogicalgetTrueExpression ()
 
void negate ()
 
bool operator< (const CNormalChoiceLogical &rhs) const
 
CNormalChoiceLogicaloperator= (const CNormalChoiceLogical &src)
 
bool operator== (const CNormalChoiceLogical &rhs) const
 
bool setCondition (const CNormalLogical &cond)
 
bool setFalseExpression (const CNormalLogical &branch)
 
bool setTrueExpression (const CNormalLogical &branch)
 
virtual bool simplify ()
 
virtual std::string toString () const
 
virtual ~CNormalChoiceLogical ()
 
- Public Member Functions inherited from CNormalBase
virtual bool areEqual (const CNormalBase &rhs) const
 
virtual ~CNormalBase ()
 

Static Public Member Functions

static bool checkConditionTree (const CNormalBase &branch)
 

Protected Attributes

CNormalLogicalmpCondition
 
CNormalLogicalmpFalse
 
CNormalLogicalmpTrue
 

Detailed Description

Definition at line 23 of file CNormalChoiceLogical.h.

Constructor & Destructor Documentation

CNormalChoiceLogical::CNormalChoiceLogical ( )

Definition at line 27 of file CNormalChoiceLogical.cpp.

Referenced by copy().

27  : CNormalBase(), mpCondition(NULL), mpTrue(NULL), mpFalse(NULL)
28 {}
CNormalLogical * mpCondition
CNormalLogical * mpFalse
CNormalChoiceLogical::CNormalChoiceLogical ( const CNormalChoiceLogical src)

Definition at line 30 of file CNormalChoiceLogical.cpp.

30  :
31  CNormalBase(src),
32  mpCondition(NULL),
33  mpTrue(NULL),
34  mpFalse(NULL)
35 {*this = src;}
CNormalLogical * mpCondition
CNormalLogical * mpFalse
CNormalChoiceLogical::~CNormalChoiceLogical ( )
virtual

Definition at line 37 of file CNormalChoiceLogical.cpp.

References mpCondition, mpFalse, mpTrue, and pdelete.

38 {
40  pdelete(mpTrue);
42 }
#define pdelete(p)
Definition: copasi.h:215
CNormalLogical * mpCondition
CNormalLogical * mpFalse

Member Function Documentation

bool CNormalChoiceLogical::checkConditionTree ( const CNormalBase branch)
static

Definition at line 129 of file CNormalChoiceLogical.cpp.

References CNormalItem::CONSTANT, getCondition(), getFalseExpression(), CNormalItem::getName(), getTrueExpression(), and CNormalItem::getType().

Referenced by setCondition(), setFalseExpression(), and setTrueExpression().

130 {
131  bool result = true;
132  const CNormalChoiceLogical* pChoice = dynamic_cast<const CNormalChoiceLogical*>(&branch);
133  if (pChoice != NULL)
134  {
135  // check the condition and the two branches
136  result = checkConditionTree(pChoice->getCondition());
137  if (result == true) result = checkConditionTree(pChoice->getTrueExpression());
138  if (result == true) result = checkConditionTree(pChoice->getFalseExpression());
139  }
140  else
141  {
142  const CNormalLogical* pLogical = dynamic_cast<const CNormalLogical*>(&branch);
143  if (pLogical == NULL)
144  {
145  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&branch);
146  if (pItem == NULL)
147  {
148  result = false;
149  }
150  else
151  {
152  result = pItem->getType() == CNormalItem::CONSTANT;
153  if (result == true)
154  {
155  std::string name = pItem->getName();
156  if (name != "true" && name != "TRUE" && name != "false" && name != "FALSE")
157  {
158  result = false;
159  }
160  }
161  }
162  }
163  }
164  return result;
165 }
const CNormalLogical & getCondition() const
const CNormalLogical & getFalseExpression() const
const CNormalLogical & getTrueExpression() const
const Type & getType() const
Definition: CNormalItem.cpp:91
static bool checkConditionTree(const CNormalBase &branch)
const std::string getName() const
Definition: CNormalItem.cpp:82
CNormalBase * CNormalChoiceLogical::copy ( ) const
virtual

Implements CNormalBase.

Definition at line 124 of file CNormalChoiceLogical.cpp.

References CNormalChoiceLogical().

125  {
126  return new CNormalChoiceLogical(*this);
127  }
const CNormalLogical & CNormalChoiceLogical::getCondition ( ) const

Definition at line 94 of file CNormalChoiceLogical.cpp.

References mpCondition.

Referenced by checkConditionTree(), and convertToCEvaluationNode().

95  {
96  return *mpCondition;
97  }
CNormalLogical * mpCondition
CNormalLogical & CNormalChoiceLogical::getCondition ( )

Definition at line 99 of file CNormalChoiceLogical.cpp.

References mpCondition.

100 {
101  return *mpCondition;
102 }
CNormalLogical * mpCondition
const CNormalLogical & CNormalChoiceLogical::getFalseExpression ( ) const

Definition at line 114 of file CNormalChoiceLogical.cpp.

References mpFalse.

Referenced by checkConditionTree(), and convertToCEvaluationNode().

115  {
116  return *mpFalse;
117  }
CNormalLogical * mpFalse
CNormalLogical & CNormalChoiceLogical::getFalseExpression ( )

Definition at line 119 of file CNormalChoiceLogical.cpp.

References mpFalse.

120 {
121  return *mpFalse;
122 }
CNormalLogical * mpFalse
const CNormalLogical & CNormalChoiceLogical::getTrueExpression ( ) const

Definition at line 104 of file CNormalChoiceLogical.cpp.

References mpTrue.

Referenced by checkConditionTree(), and convertToCEvaluationNode().

105  {
106  return *mpTrue;
107  }
CNormalLogical & CNormalChoiceLogical::getTrueExpression ( )

Definition at line 109 of file CNormalChoiceLogical.cpp.

References mpTrue.

110 {
111  return *mpTrue;
112 }
void CNormalChoiceLogical::negate ( )

Definition at line 189 of file CNormalChoiceLogical.cpp.

References mpFalse, and mpTrue.

190 {
191  CNormalLogical* pTmp = this->mpTrue;
192  this->mpTrue = this->mpFalse;
193  this->mpFalse = pTmp;
194 }
CNormalLogical * mpFalse
bool CNormalChoiceLogical::operator< ( const CNormalChoiceLogical rhs) const

Definition at line 201 of file CNormalChoiceLogical.cpp.

References mpCondition, mpFalse, and mpTrue.

202  {
203  bool result = true;
204  if ((*rhs.mpCondition) < (*this->mpCondition))
205  {
206  result = false;
207  }
208  else if ((*this->mpCondition) == (*rhs.mpCondition))
209  {
210  if ((*rhs.mpTrue) < (*this->mpTrue))
211  {
212  result = false;
213  }
214  else if ((*rhs.mpTrue) == (*this->mpTrue))
215  {
216  if (!((*this->mpFalse) < (*rhs.mpFalse)))
217  {
218  result = false;
219  }
220  }
221  }
222  return result;
223  }
CNormalLogical * mpCondition
CNormalLogical * mpFalse
CNormalChoiceLogical & CNormalChoiceLogical::operator= ( const CNormalChoiceLogical src)

Definition at line 44 of file CNormalChoiceLogical.cpp.

References mpCondition, mpFalse, mpTrue, and pdelete.

45 {
47  pdelete(mpTrue);
49 
50  if (src.mpCondition != NULL)
52  if (src.mpTrue != NULL)
53  mpTrue = new CNormalLogical(*src.mpTrue);
54  if (src.mpFalse != NULL)
55  mpFalse = new CNormalLogical(*src.mpFalse);
56 
57  return *this;
58 }
#define pdelete(p)
Definition: copasi.h:215
CNormalLogical * mpCondition
CNormalLogical * mpFalse
bool CNormalChoiceLogical::operator== ( const CNormalChoiceLogical rhs) const

Definition at line 196 of file CNormalChoiceLogical.cpp.

References mpCondition, mpFalse, and mpTrue.

197  {
198  return ((*this->mpCondition) == (*rhs.mpCondition) && (*this->mpTrue == *rhs.mpTrue) && (*this->mpFalse == *rhs.mpFalse));
199  }
CNormalLogical * mpCondition
CNormalLogical * mpFalse
bool CNormalChoiceLogical::setCondition ( const CNormalLogical cond)

Definition at line 60 of file CNormalChoiceLogical.cpp.

References checkConditionTree(), mpCondition, and pdelete.

Referenced by createLogicalChoice().

61 {
62  bool result = true;
64 
65  // check the cond if it is OK
66  result = checkConditionTree(cond);
67  if (result == true)
68  mpCondition = new CNormalLogical(cond);
69  return result;
70 }
#define pdelete(p)
Definition: copasi.h:215
CNormalLogical * mpCondition
static bool checkConditionTree(const CNormalBase &branch)
bool CNormalChoiceLogical::setFalseExpression ( const CNormalLogical branch)

Definition at line 83 of file CNormalChoiceLogical.cpp.

References checkConditionTree(), mpFalse, and pdelete.

Referenced by createLogicalChoice().

84 {
85  bool result = true;
87 
88  // check the branch if it is OK
89  result = checkConditionTree(branch);
90  mpFalse = new CNormalLogical(branch);
91  return result;
92 }
#define pdelete(p)
Definition: copasi.h:215
static bool checkConditionTree(const CNormalBase &branch)
CNormalLogical * mpFalse
bool CNormalChoiceLogical::setTrueExpression ( const CNormalLogical branch)

Definition at line 72 of file CNormalChoiceLogical.cpp.

References checkConditionTree(), mpTrue, and pdelete.

Referenced by createLogicalChoice().

73 {
74  bool result = true;
75  pdelete(mpTrue);
76 
77  // check the branch if it is OK
78  result = checkConditionTree(branch);
79  mpTrue = new CNormalLogical(branch);
80  return result;
81 }
#define pdelete(p)
Definition: copasi.h:215
static bool checkConditionTree(const CNormalBase &branch)
bool CNormalChoiceLogical::simplify ( )
virtual

Implements CNormalBase.

Definition at line 180 of file CNormalChoiceLogical.cpp.

References mpCondition, mpFalse, mpTrue, and CNormalLogical::simplify().

181 {
182  bool result = true;
183  if (this->mpCondition != NULL) result &= this->mpCondition->simplify();
184  if (this->mpTrue != NULL) result &= this->mpTrue->simplify();
185  if (this->mpFalse != NULL) result &= this->mpFalse->simplify();
186  return result;
187 }
CNormalLogical * mpCondition
virtual bool simplify()
CNormalLogical * mpFalse
std::string CNormalChoiceLogical::toString ( ) const
virtual

Implements CNormalBase.

Definition at line 167 of file CNormalChoiceLogical.cpp.

References mpCondition, mpFalse, mpTrue, and CNormalLogical::toString().

Referenced by operator<<().

168  {
169  std::ostringstream os;
170  os << "if(" << this->mpCondition->toString() << ") then (" << this->mpTrue->toString() << ") else (" << this->mpFalse->toString() << ")";
171  return os.str();
172  }
CNormalLogical * mpCondition
virtual std::string toString() const
CNormalLogical * mpFalse

Member Data Documentation

CNormalLogical* CNormalChoiceLogical::mpCondition
protected
CNormalLogical* CNormalChoiceLogical::mpFalse
protected
CNormalLogical* CNormalChoiceLogical::mpTrue
protected

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