COPASI API  4.16.103
CNormalFunction.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/compareExpressions/CNormalFunction.cpp,v $
3 // $Revision: 1.5 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2008/08/02 14:09:17 $
7 // End CVS Header
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 #ifdef WIN32
19 # pragma warning (disable: 4786)
20 # pragma warning (disable: 4243)
21 // warning C4355: 'this' : used in base member initializer list
22 # pragma warning (disable: 4355)
23 #endif // WIN32
24 
25 #include <sstream>
26 
27 #include "CNormalFunction.h"
28 #include "CNormalFraction.h"
29 
30 const char* CNormalFunction::NAMES[] =
31  {"LOG",
32  "LOG10",
33  "EXP",
34  "SIN",
35  "COS",
36  "TAN",
37  "SEC",
38  "CSC",
39  "COT",
40  "SIN",
41  "COS",
42  "TAN",
43  "SEC",
44  "CSC",
45  "COT",
46  "ARCSIN",
47  "ARCCOS",
48  "ARCTAN",
49  "ARCSEC",
50  "ARCCSC",
51  "ARCCOT",
52  "ARCSINH",
53  "ARCCOSH",
54  "ARCTANH",
55  "ARCSECH",
56  "ARCCSCH",
57  "ARCCOTH",
58  "SQRT",
59  "ABS",
60  "FLOOR",
61  "CEIL",
62  "FACTORIAL"
63  };
64 
65 CNormalFunction::CNormalFunction(): CNormalBase(), mType(CNormalFunction::INVALID), mpFraction(NULL)
66 {}
67 
68 CNormalFunction::CNormalFunction(const CNormalFunction& src): CNormalBase(src), mType(src.getType()), mpFraction(new CNormalFraction(src.getFraction()))
69 {}
70 
72 {
73  if (this->mpFraction != NULL) delete mpFraction;
74 }
75 
77 {
78  if (this->mpFraction != NULL) delete this->mpFraction;
79  this->mpFraction = new CNormalFraction(src.getFraction());
80  this->mType = src.getType();
81  return *this;
82 }
83 
84 std::string CNormalFunction::toString() const
85  {
86  std::ostringstream s;
87  if (this->mType != INVALID && this->mpFraction != NULL)
88  {
89  s << CNormalFunction::NAMES[this->mType] << "(" << *this->mpFraction << ")";
90  }
91  return s.str();
92  }
93 
95  {
96  return this->mType;
97  }
98 
100 {
101  this->mType = type;
102 }
103 
105 {
106  return *mpFraction;
107 }
108 
110  {
111  return *mpFraction;
112  }
113 
115 {
116  if (this->mpFraction != NULL) delete this->mpFraction;
117  this->mpFraction = new CNormalFraction(frac);
118 }
119 
120 std::ostream& operator<<(std::ostream& os, const CNormalFunction& fun)
121 {
122  os << fun.toString();
123  return os;
124 }
125 
127  {
128  return ((this->mType == rhs.mType) && (*this->mpFraction) == (*rhs.mpFraction));
129  }
130 
132  {
133  bool result = false;
134  if (this->mType < rhs.mType)
135  {
136  result = true;
137  }
138  else if (this->mType == rhs.mType)
139  {
140  result = (*this->mpFraction) < (*rhs.mpFraction);
141  }
142  return result;
143  }
144 
146 {
147  bool result = true;
148  if (this->mpFraction != NULL) result = this->mpFraction->simplify();
149  return result;
150 }
151 
153  {
154  return new CNormalFunction(*this);
155  }
virtual bool simplify()
void setFraction(const CNormalFraction &frac)
std::ostream & operator<<(std::ostream &os, const CNormalFunction &fun)
virtual CNormalBase * copy() const
void setType(Type type)
bool operator<(const CNormalFunction &src) const
virtual bool simplify()
virtual std::string toString() const
static const char * NAMES[]
bool operator==(const CNormalFunction &src) const
virtual ~CNormalFunction()
CNormalFraction * mpFraction
CNormalFunction & operator=(const CNormalFunction &src)
Type getType() const
CNormalFraction & getFraction()