COPASI API  4.16.103
Public Member Functions | Private Attributes | List of all members
CNodeK Class Reference

#include <CNodeK.h>

Collaboration diagram for CNodeK:
Collaboration graph
[legend]

Public Member Functions

void cleanup ()
 
 CNodeK ()
 
 CNodeK (const CNodeK &src)
 
 CNodeK (char type, char subtype)
 
 CNodeK (const std::string &name)
 
 CNodeK (C_FLOAT64 constant)
 
C_FLOAT64 getConstant () const
 
std::string getExplicitFunctionString (const std::vector< std::vector< std::string > > &callParameterNames, const std::string &r)
 
C_INT32 getIndex () const
 
CNodeKgetLeft () const
 
std::string getName () const
 
CNodeKgetRight () const
 
char getSubtype () const
 
char getType () const
 
C_INT16 isIdentifier () const
 
C_INT16 isLeftValid () const
 
C_INT16 isNumber () const
 
C_INT16 isOperator () const
 
C_INT16 isRightValid () const
 
C_INT16 leftPrecedence () const
 
C_INT32 load (CReadConfig &configbuffer)
 
C_INT16 rightPrecedence () const
 
void setConstant (C_FLOAT64 &constant)
 
void setIndex (C_INT32 index)
 
void setLeft (CNodeK &left)
 
void setLeft (CNodeK *pleft)
 
void setName (const std::string &name)
 
void setOldIndex (C_INT32 oldindex)
 
void setRight (CNodeK &right)
 
void setRight (CNodeK *pright)
 
void setSubtype (const char subtype)
 
void setType (const char ype)
 
C_FLOAT64 value (const CCallParameters< C_FLOAT64 > &callParameters) const
 
void writeMathML (std::ostream &out, C_INT32 level) const
 
 ~CNodeK ()
 

Private Attributes

int attribute1
 
C_FLOAT64 mConstant
 
std::string mExplicitFunction
 
C_INT32 mIndex
 
CNodeKmLeft
 
std::string mName
 
C_INT32 mOldIndex
 
CNodeKmRight
 
char mSubtype
 
char mType
 

Detailed Description

Definition at line 84 of file CNodeK.h.

Constructor & Destructor Documentation

CNodeK::CNodeK ( )

Default constructor

Definition at line 31 of file CNodeK.cpp.

References CONSTRUCTOR_TRACE, mConstant, mIndex, mLeft, mOldIndex, mRight, mSubtype, mType, and N_NOP.

32 {
34  mType = N_NOP;
35  mSubtype = N_NOP;
36  mLeft = NULL;
37  mRight = NULL;
38  mConstant = 0.0;
39  mIndex = -1;
40  mOldIndex = -1;
41 }
char mType
Definition: CNodeK.h:92
C_INT32 mOldIndex
Definition: CNodeK.h:132
C_FLOAT64 mConstant
Definition: CNodeK.h:117
C_INT32 mIndex
Definition: CNodeK.h:127
#define N_NOP
Definition: CNodeK.h:33
CNodeK * mLeft
Definition: CNodeK.h:107
CNodeK * mRight
Definition: CNodeK.h:112
char mSubtype
Definition: CNodeK.h:102
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CNodeK::CNodeK ( const CNodeK src)

Copy constructor

Parameters
const CNodeK &src

Definition at line 43 of file CNodeK.cpp.

References CONSTRUCTOR_TRACE, mConstant, mIndex, mLeft, mName, mOldIndex, mRight, mSubtype, and mType.

44 {
46  mType = src.mType;
47  mSubtype = src.mSubtype;
48  mLeft = src.mLeft;
49  mRight = src.mRight;
50  mConstant = src.mConstant;
51  mName = src.mName;
52  mIndex = src.mIndex;
53  mOldIndex = src.mOldIndex;
54 }
char mType
Definition: CNodeK.h:92
std::string mName
Definition: CNodeK.h:122
C_INT32 mOldIndex
Definition: CNodeK.h:132
C_FLOAT64 mConstant
Definition: CNodeK.h:117
C_INT32 mIndex
Definition: CNodeK.h:127
CNodeK * mLeft
Definition: CNodeK.h:107
CNodeK * mRight
Definition: CNodeK.h:112
char mSubtype
Definition: CNodeK.h:102
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CNodeK::CNodeK ( char  type,
char  subtype 
)

Constructor for operator

Parameters
const chartype
const charsubtype

Definition at line 56 of file CNodeK.cpp.

References CONSTRUCTOR_TRACE, mConstant, mIndex, mLeft, mOldIndex, mRight, mSubtype, and mType.

57 {
59  mType = type;
60  mSubtype = subtype;
61  mLeft = NULL;
62  mRight = NULL;
63  mConstant = 0.0;
64  mIndex = -1;
65  mOldIndex = -1;
66 }
char mType
Definition: CNodeK.h:92
C_INT32 mOldIndex
Definition: CNodeK.h:132
C_FLOAT64 mConstant
Definition: CNodeK.h:117
C_INT32 mIndex
Definition: CNodeK.h:127
CNodeK * mLeft
Definition: CNodeK.h:107
CNodeK * mRight
Definition: CNodeK.h:112
char mSubtype
Definition: CNodeK.h:102
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CNodeK::CNodeK ( const std::string &  name)

Constructor for identifier

Parameters
const string&name

Definition at line 68 of file CNodeK.cpp.

References CONSTRUCTOR_TRACE, mConstant, mIndex, mLeft, mName, mOldIndex, mRight, mSubtype, mType, N_IDENTIFIER, and N_NOP.

69 {
72  mSubtype = N_NOP;
73  mLeft = NULL;
74  mRight = NULL;
75  mConstant = 0.0;
76  mName = name;
77  mIndex = -1;
78  mOldIndex = -1;
79 }
char mType
Definition: CNodeK.h:92
#define N_IDENTIFIER
Definition: CNodeK.h:37
std::string mName
Definition: CNodeK.h:122
C_INT32 mOldIndex
Definition: CNodeK.h:132
C_FLOAT64 mConstant
Definition: CNodeK.h:117
C_INT32 mIndex
Definition: CNodeK.h:127
#define N_NOP
Definition: CNodeK.h:33
CNodeK * mLeft
Definition: CNodeK.h:107
CNodeK * mRight
Definition: CNodeK.h:112
char mSubtype
Definition: CNodeK.h:102
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CNodeK::CNodeK ( C_FLOAT64  constant)

Constructor for a constant

Parameters
const C_FLOAT64constant

Definition at line 81 of file CNodeK.cpp.

References CONSTRUCTOR_TRACE, mConstant, mIndex, mLeft, mOldIndex, mRight, mSubtype, mType, N_NOP, and N_NUMBER.

82 {
84  mType = N_NUMBER;
85  mSubtype = N_NOP;
86  mLeft = NULL;
87  mRight = NULL;
88  mConstant = constant;
89  mIndex = -1;
90  mOldIndex = -1;
91 }
char mType
Definition: CNodeK.h:92
C_INT32 mOldIndex
Definition: CNodeK.h:132
C_FLOAT64 mConstant
Definition: CNodeK.h:117
C_INT32 mIndex
Definition: CNodeK.h:127
#define N_NOP
Definition: CNodeK.h:33
CNodeK * mLeft
Definition: CNodeK.h:107
CNodeK * mRight
Definition: CNodeK.h:112
char mSubtype
Definition: CNodeK.h:102
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
#define N_NUMBER
Definition: CNodeK.h:40
CNodeK::~CNodeK ( )

Destructor

Definition at line 96 of file CNodeK.cpp.

References DESTRUCTOR_TRACE.

97 {
99 }
#define DESTRUCTOR_TRACE
Definition: copasi.h:206

Member Function Documentation

void CNodeK::cleanup ( )

Delete

Definition at line 93 of file CNodeK.cpp.

94 {}
C_FLOAT64 CNodeK::getConstant ( ) const

Retrieving value of a node

Returns
C_FLOAT64

Definition at line 375 of file CNodeK.cpp.

References mConstant.

376 {
377  return mConstant;
378 }
C_FLOAT64 mConstant
Definition: CNodeK.h:117
std::string CNodeK::getExplicitFunctionString ( const std::vector< std::vector< std::string > > &  callParameterNames,
const std::string &  r 
)

Returns a string that contains the equation defined from this node downwards. The function contains explicit names of node identifiers, rather than the abstract symbol.

Parameters
const CCallParameters &callParameterNames a vector of string pointers with identifier names
const string &r a suffix for parameter names (usually reaction number)
Returns
string
C_INT32 CNodeK::getIndex ( ) const

Retrieving index the name of a node

Returns
C_INT32

Definition at line 380 of file CNodeK.cpp.

References mIndex.

381 {
382  return mIndex;
383 }
C_INT32 mIndex
Definition: CNodeK.h:127
CNodeK & CNodeK::getLeft ( ) const

Retrieving mLeft the left branch of a node

Returns
CNodeK

Definition at line 340 of file CNodeK.cpp.

References fatalError, and mLeft.

341 {
342  if (!mLeft)
343  fatalError(); // Call LeftIsValid first to avoid this!
344 
345  return *mLeft;
346 }
#define fatalError()
CNodeK * mLeft
Definition: CNodeK.h:107
std::string CNodeK::getName ( ) const

Retrieving mName the name of a node

Returns
string

Definition at line 356 of file CNodeK.cpp.

References C_INT, isIdentifier(), and mName.

357 {
358  return mName;
359 #ifdef XXXX
360 
361  static unsigned C_INT ctr = 0;
362  char name[9];
363 
364  if (isIdentifier())
365  return mName;
366  else
367  {
368  sprintf(name, "%X", ctr++);
369  return name;
370  }
371 
372 #endif // XXXX
373 }
#define C_INT
Definition: copasi.h:115
std::string mName
Definition: CNodeK.h:122
C_INT16 isIdentifier() const
Definition: CNodeK.cpp:450
CNodeK & CNodeK::getRight ( ) const

Retrieving mName the name of a node

Returns
string

Definition at line 348 of file CNodeK.cpp.

References fatalError, and mRight.

349 {
350  if (!mRight)
351  fatalError(); // Call RightIsValid first to avoid this!
352 
353  return *mRight;
354 }
#define fatalError()
CNodeK * mRight
Definition: CNodeK.h:112
char CNodeK::getSubtype ( ) const

Retrieving mSubtype the subtype of a node

Returns
char

Definition at line 335 of file CNodeK.cpp.

References mSubtype.

336 {
337  return mSubtype;
338 }
char mSubtype
Definition: CNodeK.h:102
char CNodeK::getType ( ) const

Retrieving mType the type of a node

Returns
char

Definition at line 330 of file CNodeK.cpp.

References mType.

331 {
332  return mType;
333 }
char mType
Definition: CNodeK.h:92
C_INT16 CNodeK::isIdentifier ( ) const

This checks whether the node is an identifier (mType = N_IDENTIFIER)

Returns
int 1 or 0

Definition at line 450 of file CNodeK.cpp.

References mType, N_IDENTIFIER, N_KCONSTANT, N_MODIFIER, N_OBJECT, N_PRODUCT, N_SUBSTRATE, and N_VOLUME.

Referenced by getName().

451 {
452  switch (mType)
453  {
454  case N_OBJECT:
455  case N_IDENTIFIER:
456  case N_SUBSTRATE:
457  case N_PRODUCT:
458  case N_MODIFIER:
459  case N_KCONSTANT:
460  case N_VOLUME:
461  return true;
462  default:
463  return false;
464  }
465 }
#define N_OBJECT
Definition: CNodeK.h:39
char mType
Definition: CNodeK.h:92
#define N_IDENTIFIER
Definition: CNodeK.h:37
#define N_SUBSTRATE
Definition: CNodeK.h:78
#define N_KCONSTANT
Definition: CNodeK.h:81
#define N_VOLUME
Definition: CNodeK.h:82
#define N_PRODUCT
Definition: CNodeK.h:79
#define N_MODIFIER
Definition: CNodeK.h:80
C_INT16 CNodeK::isLeftValid ( ) const

This checks whether mLeft points to a valid CNodeK

Returns
int 1 or 0

Definition at line 435 of file CNodeK.cpp.

References mLeft.

436 {
437  return (mLeft != NULL);
438 }
CNodeK * mLeft
Definition: CNodeK.h:107
C_INT16 CNodeK::isNumber ( ) const

This checks whether the node is a number (mType = N_NUMBER)

Returns
int 1 or 0

Definition at line 445 of file CNodeK.cpp.

References mType, and N_NUMBER.

446 {
447  return (mType == N_NUMBER);
448 }
char mType
Definition: CNodeK.h:92
#define N_NUMBER
Definition: CNodeK.h:40
C_INT16 CNodeK::isOperator ( ) const

This checks whether the node is a operator (mType = N_OPERATOR)

Returns
int 1 or 0

Definition at line 467 of file CNodeK.cpp.

References mType, and N_OPERATOR.

468 {
469  return mType == N_OPERATOR;
470 }
char mType
Definition: CNodeK.h:92
#define N_OPERATOR
Definition: CNodeK.h:36
C_INT16 CNodeK::isRightValid ( ) const

This checks whether mRight points to a valid CNodeK

Returns
int 1 or 0

Definition at line 440 of file CNodeK.cpp.

References mRight.

441 {
442  return (mRight != NULL);
443 }
CNodeK * mRight
Definition: CNodeK.h:112
C_INT16 CNodeK::leftPrecedence ( ) const

This returns the left precedence value of a node

Returns
int

Definition at line 472 of file CNodeK.cpp.

References mSubtype, mType, N_FUNCTION, N_IDENTIFIER, N_NUMBER, and N_OBJECT.

473 {
474  switch (mType)
475  {
476  case N_OBJECT:
477  case N_NUMBER:
478  case N_IDENTIFIER:
479  case N_FUNCTION:
480  return 5;
481  }
482 
483  // if we got here then it is an operator
484  switch (mSubtype)
485  {
486  case '+':
487  case '-':
488  return 1;
489  case '*':
490  case '/':
491  return 3;
492  case '(':
493  return 6;
494  case '^':
495  return 5;
496  case ')':
497  case '%':
498  return 0;
499  }
500 
501  return 0;
502 }
#define N_OBJECT
Definition: CNodeK.h:39
char mType
Definition: CNodeK.h:92
#define N_IDENTIFIER
Definition: CNodeK.h:37
#define N_FUNCTION
Definition: CNodeK.h:38
char mSubtype
Definition: CNodeK.h:102
#define N_NUMBER
Definition: CNodeK.h:40
C_INT32 CNodeK::load ( CReadConfig configbuffer)

Loads an object with data coming from a CReadConfig object. (CReadConfig object reads an input stream)

Parameters
pconfigbufferreference to a CReadConfig object.
Returns
Fail

Definition at line 101 of file CNodeK.cpp.

References C_INT32, CReadConfig::getVariable(), mConstant, mIndex, mName, mSubtype, mType, N_IDENTIFIER, N_KCONSTANT, N_MODIFIER, N_NUMBER, N_PRODUCT, N_SUBSTRATE, and CReadConfig::SEARCH.

102 {
103  C_INT32 Fail = 0;
104 
105  if ((Fail = configbuffer.getVariable("Node", "node", &mType, &mSubtype,
107  return Fail;
108 
109  /* This COPASI treats all these as identifiers */
110  if (mType == N_SUBSTRATE ||
111  mType == N_PRODUCT ||
112  mType == N_MODIFIER ||
113  mType == N_KCONSTANT)
114  {
115  mSubtype = mType;
117  }
118 
119  // leave the Left & Right pointers out
120  // value of the constant if one
121  if (mType == N_NUMBER)
122  {
123  if ((Fail = configbuffer.getVariable("Value", "C_FLOAT64", &mConstant)))
124  return Fail;
125  }
126  else if (mType == N_IDENTIFIER)
127  {
128  if ((Fail = configbuffer.getVariable("Index", "C_INT32", &mIndex)))
129  return Fail;
130 
131  if ((Fail = configbuffer.getVariable("Name", "string", &mName)))
132  return Fail;
133  }
134 
135  return Fail;
136 }
char mType
Definition: CNodeK.h:92
#define N_IDENTIFIER
Definition: CNodeK.h:37
std::string mName
Definition: CNodeK.h:122
#define C_INT32
Definition: copasi.h:90
#define N_SUBSTRATE
Definition: CNodeK.h:78
C_FLOAT64 mConstant
Definition: CNodeK.h:117
C_INT32 mIndex
Definition: CNodeK.h:127
#define N_KCONSTANT
Definition: CNodeK.h:81
#define N_PRODUCT
Definition: CNodeK.h:79
C_INT32 getVariable(const std::string &name, const std::string &type, void *pout, CReadConfig::Mode mode=CReadConfig::NEXT)
Definition: CReadConfig.cpp:81
char mSubtype
Definition: CNodeK.h:102
#define N_MODIFIER
Definition: CNodeK.h:80
#define N_NUMBER
Definition: CNodeK.h:40
C_INT16 CNodeK::rightPrecedence ( ) const

This returns the right precedence value of a node

Returns
int

Definition at line 504 of file CNodeK.cpp.

References mSubtype, mType, N_FUNCTION, N_IDENTIFIER, N_NUMBER, and N_OBJECT.

505 {
506  switch (mType)
507  {
508  case N_OBJECT:
509  case N_NUMBER:
510  case N_IDENTIFIER:
511  return 6;
512  case N_FUNCTION:
513  return 4;
514  }
515 
516  // if we got here then it is an operator
517  switch (mSubtype)
518  {
519  case '+':
520  case '-':
521  return 2;
522  case '*':
523  case '/':
524  return 4;
525  case ')':
526  return 6;
527  case '^':
528  return 4;
529  case '(':
530  case '%':
531  return 0;
532  }
533 
534  return 0;
535 }
#define N_OBJECT
Definition: CNodeK.h:39
char mType
Definition: CNodeK.h:92
#define N_IDENTIFIER
Definition: CNodeK.h:37
#define N_FUNCTION
Definition: CNodeK.h:38
char mSubtype
Definition: CNodeK.h:102
#define N_NUMBER
Definition: CNodeK.h:40
void CNodeK::setConstant ( C_FLOAT64 constant)

Setting the value of a number

Parameters
C_FLOAT64&constant

Definition at line 420 of file CNodeK.cpp.

References mConstant.

421 {
422  mConstant = constant;
423 }
C_FLOAT64 mConstant
Definition: CNodeK.h:117
void CNodeK::setIndex ( C_INT32  index)

Setting the index of an identifier

Parameters
C_INT32&index

Definition at line 425 of file CNodeK.cpp.

References mIndex.

426 {
427  mIndex = index;
428 }
C_INT32 mIndex
Definition: CNodeK.h:127
void CNodeK::setLeft ( CNodeK left)

Setting mLeft the pointer to the left branch

Parameters
CNodeK&left

Definition at line 395 of file CNodeK.cpp.

References mLeft.

396 {
397  mLeft = &left;
398 }
CNodeK * mLeft
Definition: CNodeK.h:107
void CNodeK::setLeft ( CNodeK pleft)

Setting mLeft the pointer to the left branch

Parameters
CNodeK*pleft

Definition at line 400 of file CNodeK.cpp.

References mLeft.

401 {
402  mLeft = pleft;
403 }
CNodeK * mLeft
Definition: CNodeK.h:107
void CNodeK::setName ( const std::string &  name)

Setting mName the name of an identifier

Parameters
const string&name

Definition at line 415 of file CNodeK.cpp.

References mName.

416 {
417  mName = name;
418 }
std::string mName
Definition: CNodeK.h:122
void CNodeK::setOldIndex ( C_INT32  oldindex)

Setting the old index (Gepasi format, each type is indexed separately)

Parameters
C_INT32&index

Definition at line 430 of file CNodeK.cpp.

References mOldIndex.

431 {
432  mOldIndex = oldindex;
433 }
C_INT32 mOldIndex
Definition: CNodeK.h:132
void CNodeK::setRight ( CNodeK right)

Setting mRight the pointer to the right branch

Parameters
CNodeK&right

Definition at line 405 of file CNodeK.cpp.

References mRight.

406 {
407  mRight = &right;
408 }
CNodeK * mRight
Definition: CNodeK.h:112
void CNodeK::setRight ( CNodeK pright)

Setting mRight the pointer to the right branch

Parameters
CNodeK*pright

Definition at line 410 of file CNodeK.cpp.

References mRight.

411 {
412  mRight = pright;
413 }
CNodeK * mRight
Definition: CNodeK.h:112
void CNodeK::setSubtype ( const char  subtype)

Setting mSubtype the subtype of a node

Parameters
const charsubtype

Definition at line 390 of file CNodeK.cpp.

References mSubtype.

391 {
392  mSubtype = subtype;
393 }
char mSubtype
Definition: CNodeK.h:102
void CNodeK::setType ( const char  ype)

Setting mType the subtype of a node

Parameters
const chartype

Definition at line 385 of file CNodeK.cpp.

References mType.

386 {
387  mType = type;
388 }
char mType
Definition: CNodeK.h:92
C_FLOAT64 CNodeK::value ( const CCallParameters< C_FLOAT64 > &  callParameters) const

This calculates the value of this sub-tree (ie with this node as root)

Parameters
constCCallParameters<C_FLOAT64> & callParameters
Returns
C_FLOAT64
void CNodeK::writeMathML ( std::ostream &  out,
C_INT32  level 
) const

Member Data Documentation

int CNodeK::attribute1
private

WHAT IS THIS FOR??? PLEASE ADD COMMENT!

Definition at line 137 of file CNodeK.h.

C_FLOAT64 CNodeK::mConstant
private

The value of a node of type N_NUMBER

Definition at line 117 of file CNodeK.h.

Referenced by CNodeK(), getConstant(), load(), and setConstant().

std::string CNodeK::mExplicitFunction
private

The explicit function string

Definition at line 142 of file CNodeK.h.

C_INT32 CNodeK::mIndex
private

The index of the node for type N_IDENTIFIER

Definition at line 127 of file CNodeK.h.

Referenced by CNodeK(), getIndex(), load(), and setIndex().

CNodeK* CNodeK::mLeft
private

The left branch of the tree originating from tyhis node

Definition at line 107 of file CNodeK.h.

Referenced by CNodeK(), getLeft(), isLeftValid(), and setLeft().

std::string CNodeK::mName
private

The name of the node for type N_IDENTIFIER

Definition at line 122 of file CNodeK.h.

Referenced by CNodeK(), getName(), load(), and setName().

C_INT32 CNodeK::mOldIndex
private

The index in old Gepasi format

Definition at line 132 of file CNodeK.h.

Referenced by CNodeK(), and setOldIndex().

CNodeK* CNodeK::mRight
private

The right branch of the tree originating from tyhis node

Definition at line 112 of file CNodeK.h.

Referenced by CNodeK(), getRight(), isRightValid(), and setRight().

char CNodeK::mSubtype
private

The subtype of a node. for type N_FUNCTION one of: N_LOG10, N_LOG, N_EXP, N_SIN, N_COS, N_RND, N_GAUSS, N_BOLTZ for type N_IDENTIFIER one of:N_SUBSTRATE, N_PRODUCT, N_MODIFIER, N_KCONSTANT for type N_OPERATOR one of: + - * / ^ () ...

Definition at line 102 of file CNodeK.h.

Referenced by CNodeK(), getSubtype(), leftPrecedence(), load(), rightPrecedence(), and setSubtype().

char CNodeK::mType
private

The type of the node. One of N_ROOT, N_OPERATOR, N_IDENTIFIER, N_FUNCTION, N_NUMBER

Definition at line 92 of file CNodeK.h.

Referenced by CNodeK(), getType(), isIdentifier(), isNumber(), isOperator(), leftPrecedence(), load(), rightPrecedence(), and setType().


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