COPASI API  4.16.103
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
CNormalCall Class Reference

#include <CNormalCall.h>

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

Public Types

enum  Type { FUNCTION, EXPRESSION, DELAY, INVALID }
 

Public Member Functions

bool add (const CNormalFraction &fraction)
 
 CNormalCall ()
 
 CNormalCall (const CNormalCall &src)
 
virtual CNormalBasecopy () const
 
const std::vector
< CNormalFraction * > & 
getFractions () const
 
const std::string & getName () const
 
int getSize () const
 
Type getType () const
 
bool operator< (const CNormalCall &rhs) const
 
CNormalCalloperator= (const CNormalCall &src)
 
bool operator== (const CNormalCall &rhs) const
 
void setFractions (const std::vector< CNormalFraction * > &set)
 
void setName (const std::string &name)
 
void setType (Type type)
 
virtual bool simplify ()
 
virtual std::string toString () const
 
virtual ~CNormalCall ()
 
- Public Member Functions inherited from CNormalBase
virtual bool areEqual (const CNormalBase &rhs) const
 
virtual ~CNormalBase ()
 

Private Attributes

std::vector< CNormalFraction * > mFractions
 
std::string mName
 
Type mType
 

Friends

std::ostream & operator<< (std::ostream &os, const CNormalCall &d)
 

Detailed Description

The class for function calls used in CNormal

Definition at line 33 of file CNormalCall.h.

Member Enumeration Documentation

Enumerator
FUNCTION 
EXPRESSION 
DELAY 
INVALID 

Definition at line 36 of file CNormalCall.h.

Constructor & Destructor Documentation

CNormalCall::CNormalCall ( )

Default constructor

Definition at line 25 of file CNormalCall.cpp.

Referenced by copy().

CNormalCall::CNormalCall ( const CNormalCall src)

Copy Constructor

Definition at line 31 of file CNormalCall.cpp.

References mFractions, mName, mType, and setFractions().

31  : CNormalBase(src)
32 {
33  this->mName = src.mName;
34  this->mType = src.mType;
35  this->setFractions(src.mFractions);
36 }
std::string mName
Definition: CNormalCall.h:48
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
void setFractions(const std::vector< CNormalFraction * > &set)
CNormalCall::~CNormalCall ( )
virtual

Destructor

Definition at line 109 of file CNormalCall.cpp.

References mFractions.

110 {
111  // delete all fractions
112  std::vector<CNormalFraction*>::iterator it = this->mFractions.begin(), endit = this->mFractions.end();
113 
114  while (it != endit)
115  {
116  delete *it;
117  ++it;
118  }
119 }
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60

Member Function Documentation

bool CNormalCall::add ( const CNormalFraction fraction)

Add fraction to this sum.

Returns
true.

Definition at line 139 of file CNormalCall.cpp.

References mFractions.

Referenced by createCall(), and setFractions().

140 {
141  this->mFractions.push_back(new CNormalFraction(fraction));
142  return true;
143 }
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
CNormalBase * CNormalCall::copy ( ) const
virtual

Implements CNormalBase.

Definition at line 121 of file CNormalCall.cpp.

References CNormalCall().

122 {
123  return new CNormalCall(*this);
124 }
const std::vector< CNormalFraction * > & CNormalCall::getFractions ( ) const

Retrieve the set of fractions of this sum.

Returns
mFractions.

Definition at line 149 of file CNormalCall.cpp.

References mFractions.

Referenced by convertToCEvaluationNode().

150 {
151  return this->mFractions;
152 }
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
const std::string & CNormalCall::getName ( ) const

Definition at line 262 of file CNormalCall.cpp.

References mName.

Referenced by convertToCEvaluationNode().

263 {
264  return this->mName;
265 }
std::string mName
Definition: CNormalCall.h:48
int CNormalCall::getSize ( ) const

Retrieve the number of summands of this sum.

Returns
int

Definition at line 130 of file CNormalCall.cpp.

References mFractions.

131 {
132  return this->mFractions.size();
133 }
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
CNormalCall::Type CNormalCall::getType ( ) const

Definition at line 272 of file CNormalCall.cpp.

References mType.

Referenced by convertToCEvaluationNode().

273 {
274  return this->mType;
275 }
bool CNormalCall::operator< ( const CNormalCall rhs) const

Smaller operator

Definition at line 56 of file CNormalCall.cpp.

References mFractions, mName, and mType.

57 {
58  bool result = false;
59 
60  if (this->mType < rhs.mType)
61  {
62  result = true;
63  }
64  else
65  {
66  if (this->mName < rhs.mName)
67  {
68  result = true;
69  }
70  else
71  {
72  if (this->mName == rhs.mName)
73  {
74  if (this->mFractions.size() < rhs.mFractions.size())
75  {
76  result = true;
77  }
78  else
79  {
80  if (this->mFractions.size() == rhs.mFractions.size())
81  {
82  bool smaller = true;
83  std::vector<CNormalFraction*>::const_iterator it = this->mFractions.begin(), endit = this->mFractions.end();
84  std::vector<CNormalFraction*>::const_iterator it2 = rhs.mFractions.begin();
85 
86  while (it != endit && smaller == true)
87  {
88  smaller = ((*it2) < (*it));
89  ++it;
90  ++it2;
91  }
92 
93  if (smaller)
94  {
95  result = true;
96  }
97  }
98  }
99  }
100  }
101  }
102 
103  return result;
104 }
std::string mName
Definition: CNormalCall.h:48
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
CNormalCall & CNormalCall::operator= ( const CNormalCall src)

Assignment operator

Definition at line 41 of file CNormalCall.cpp.

References mFractions, mName, mType, and setFractions().

42 {
43  if (&src != this)
44  {
45  this->mName = src.mName;
46  this->mType = src.mType;
47  this->setFractions(src.mFractions);
48  }
49 
50  return *this;
51 }
std::string mName
Definition: CNormalCall.h:48
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
void setFractions(const std::vector< CNormalFraction * > &set)
bool CNormalCall::operator== ( const CNormalCall rhs) const

Examine equality of two sums.

Returns
bool.

Definition at line 158 of file CNormalCall.cpp.

References mFractions, mName, and mType.

159 {
160  bool result = true;
161 
162  if (this->mType == rhs.mType)
163  {
164  if (this->mName == rhs.mName)
165  {
166  if (this->mFractions.size() == rhs.mFractions.size())
167  {
168  std::vector<CNormalFraction*>::const_iterator it = this->mFractions.begin();
169  std::vector<CNormalFraction*>::const_iterator it2 = rhs.mFractions.begin();
170  std::vector<CNormalFraction*>::const_iterator endit = this->mFractions.end();
171 
172  while (it != endit && result == true)
173  {
174  result = ((**it) == (**it2));
175  ++it;
176  ++it2;
177  }
178  }
179  else
180  {
181  result = false;
182  }
183  }
184  else
185  {
186  result = false;
187  }
188  }
189  else
190  {
191  result = false;
192  }
193 
194  return result;
195 }
std::string mName
Definition: CNormalCall.h:48
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
void CNormalCall::setFractions ( const std::vector< CNormalFraction * > &  set)

Sets the fractions of this product.

Definition at line 200 of file CNormalCall.cpp.

References add(), and mFractions.

Referenced by CNormalCall(), and operator=().

201 {
202  // delete all fractions
203  std::vector<CNormalFraction*>::iterator it = this->mFractions.begin(), endit = this->mFractions.end();
204 
205  while (it != endit)
206  {
207  delete *it;
208  ++it;
209  }
210 
211  this->mFractions.clear();
212  std::vector<CNormalFraction*>::const_iterator it2 = set.begin(), endit2 = set.end();
213 
214  while (it2 != endit2)
215  {
216  this->add(**it2);
217  ++it2;
218  }
219 }
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
bool add(const CNormalFraction &fraction)
void CNormalCall::setName ( const std::string &  name)

Definition at line 267 of file CNormalCall.cpp.

References mName.

Referenced by createCall().

268 {
269  this->mName = name;
270 }
std::string mName
Definition: CNormalCall.h:48
void CNormalCall::setType ( CNormalCall::Type  type)

Definition at line 277 of file CNormalCall.cpp.

References mType.

Referenced by createCall().

278 {
279  this->mType = type;
280 }
bool CNormalCall::simplify ( )
virtual

Implements CNormalBase.

Definition at line 242 of file CNormalCall.cpp.

References mFractions.

243 {
244  // simplify all children
245  std::vector<CNormalFraction*>::iterator it = this->mFractions.begin(), endit = this->mFractions.end();
246 
247  while (it != endit)
248  {
249  (*it)->simplify();
250  ++it;
251  }
252 
253  return true;
254 }
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60
std::string CNormalCall::toString ( ) const
virtual

Implements CNormalBase.

Definition at line 221 of file CNormalCall.cpp.

References mFractions, and mName.

Referenced by operator<<().

222 {
223  std::ostringstream os;
224  os << this->mName << "(";
225  std::vector<CNormalFraction*>::const_iterator it = this->mFractions.begin(), endit = this->mFractions.end();
226 
227  while (it != endit)
228  {
229  os << (**it);
230  ++it;
231 
232  if (it != endit)
233  {
234  os << ",";
235  }
236  }
237 
238  os << ")";
239  return os.str();
240 }
std::string mName
Definition: CNormalCall.h:48
std::vector< CNormalFraction * > mFractions
Definition: CNormalCall.h:60

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CNormalCall d 
)
friend

Definition at line 256 of file CNormalCall.cpp.

257 {
258  os << d.toString();
259  return os;
260 }
virtual std::string toString() const

Member Data Documentation

std::vector<CNormalFraction*> CNormalCall::mFractions
private

Enumeration of members The members of a call have to be kept in the correct order since the order of arguments to a call matters.

Definition at line 60 of file CNormalCall.h.

Referenced by add(), CNormalCall(), getFractions(), getSize(), operator<(), operator=(), operator==(), setFractions(), simplify(), toString(), and ~CNormalCall().

std::string CNormalCall::mName
private

The name of the called function

Definition at line 48 of file CNormalCall.h.

Referenced by CNormalCall(), getName(), operator<(), operator=(), operator==(), setName(), and toString().

Type CNormalCall::mType
private

the call type

Definition at line 53 of file CNormalCall.h.

Referenced by CNormalCall(), getType(), operator<(), operator=(), operator==(), and setType().


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