libSBML Perl API
libSBML 5.17.2 Perl API
|
{core}
Abstract Syntax Tree (AST) representation of a mathematical expression.This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.
Abstract Syntax Trees (ASTs) are a simple kind of data structure used in libSBML for storing mathematical expressions. The ASTNode is the cornerstone of libSBML's AST representation. An AST "node" represents the most basic, indivisible part of a mathematical formula and come in many types. For instance, there are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions. LibSBML ASTs provide a canonical, in-memory representation for all mathematical formulas regardless of their original format (which might be MathML or might be text strings).
The text-string form of mathematical formulas produced by and read by and
are in a simple C-inspired infix notation. A formula in this text-string form can be handed to a program that understands SBML mathematical expressions, or used as part of a translation system. The libSBML distribution comes with an example program in the "examples"
subdirectory called translateMath
that implements an interactive command-line demonstration of translating infix formulas into MathML and vice-versa.
The formula strings may contain operators, function calls, symbols, and white space characters. The allowable white space characters are tab and space. The following are illustrative examples of formulas expressed in the syntax:
0.10 * k4^2
(vm * s1)/(km + s1)
The following table shows the precedence rules in this syntax. In the Class column, operand implies the construct is an operand, prefix implies the operation is applied to the following arguments, unary implies there is one argument, and binary implies there are two arguments. The values in the Precedence column show how the order of different types of operation are determined. For example, the expression a * b + c is evaluated as (a * b) + c because the *
operator has higher precedence. The Associates column shows how the order of similar precedence operations is determined; for example, a - b + c is evaluated as (a - b) + c because the +
and -
operators are left-associative. The precedence and associativity rules are taken from the C programming language, except for the symbol ^
, which is used in C for a different purpose. (Exponentiation can be invoked using either ^
or the function power
.)
Token | Operation | Class | Precedence | Associates |
---|---|---|---|---|
name | symbol reference | operand | 6 | n/a |
( expression) | expression grouping | operand | 6 | n/a |
f( ...) | function call | prefix | 6 | left |
- | negation | unary | 5 | right |
^ | power | binary | 4 | left |
* | multiplication | binary | 3 | left |
/ | divison | binary | 3 | left |
+ | addition | binary | 2 | left |
- | subtraction | binary | 2 | left |
, | argument delimiter | binary | 1 | left |
A program parsing a formula in an SBML model should assume that names appearing in the formula are the identifiers of Species, Parameter, Compartment, FunctionDefinition, Reaction (in SBML Levels 2 and 3), or SpeciesReference (in SBML Level 3 only) objects defined in a model. When a function call is involved, the syntax consists of a function identifier, followed by optional white space, followed by an opening parenthesis, followed by a sequence of zero or more arguments separated by commas (with each comma optionally preceded and/or followed by zero or more white space characters), followed by a closing parenthesis. There is an almost one-to-one mapping between the list of predefined functions available, and those defined in MathML. All of the MathML functions are recognized; this set is larger than the functions defined in SBML Level 1. In the subset of functions that overlap between MathML and SBML Level 1, there exist a few differences. The following table summarizes the differences between the predefined functions in SBML Level 1 and the MathML equivalents in SBML Levels 2 and 3:
Text string formula functions | MathML equivalents in SBML Levels 2 and 3 |
---|---|
acos | arccos |
asin | arcsin |
atan | arctan |
ceil | ceiling |
log | ln |
log10(x) | log(x) or log(10, x) |
pow(x, y) | power(x, y) |
sqr(x) | power(x, 2) |
sqrt(x) | root(x) or root(2, x) |
Public Member Functions | |
int | addChild (ASTNode *disownedChild, bool inRead=false) |
Adds the given node as a child of this ASTNode. More... | |
int | addSemanticsAnnotation (XMLNode *disownedAnnotation) |
Adds the given XMLNode as a semantic annotation of this ASTNode. More... | |
ASTNode (ASTNodeType_t type=AST_UNKNOWN) | |
Creates and returns a new ASTNode. More... | |
ASTNode (Token_t *token) | |
Creates a new ASTNode from the given Token. More... | |
ASTNode (const ASTNode &orig) | |
Copy constructor; creates a deep copy of the given ASTNode. More... | |
bool | canonicalize () |
Converts this ASTNode to a canonical form and returns true if successful, false otherwise. More... | |
ASTNode * | deepCopy () const |
Creates a recursive copy of this node and all its children. More... | |
void | fillListOfNodes (ASTNodePredicate predicate, List *lst) const |
Returns a list of nodes rooted at a given node and satisfying a given predicate. More... | |
int | freeName () |
Frees the name of this ASTNode and sets it to NULL . More... | |
ASTBasePlugin * | getASTPlugin (const SBMLNamespaces *sbmlns) |
ASTBasePlugin * | getASTPlugin (ASTNodeType_t type) |
ASTBasePlugin * | getASTPlugin (const std::string &name, bool isCsymbol=false) |
const ASTBasePlugin * | getASTPlugin (const SBMLNamespaces *sbmlns) const |
const ASTBasePlugin * | getASTPlugin (ASTNodeType_t type) const |
const ASTBasePlugin * | getASTPlugin (const std::string &name, bool isCsymbol=false) const |
char | getCharacter () const |
Gets the value of this node as a single character. More... | |
ASTNode * | getChild (unsigned int n) const |
Gets a child of this node according to its index number. More... | |
std::string | getClass () const |
Gets the class of this ASTNode. More... | |
XMLAttributes * | getDefinitionURL () const |
Gets the MathML "definitionURL" attribute value. More... | |
std::string | getDefinitionURLString () const |
Returns the MathML definitionURL attribute value as a string. More... | |
long | getDenominator () const |
Gets the value of the denominator of this node. More... | |
long | getExponent () const |
Gets the exponent value of this ASTNode. More... | |
std::string | getId () const |
Gets the id of this ASTNode. More... | |
long | getInteger () const |
Gets the value of this node as an integer. More... | |
ASTNode * | getLeftChild () const |
Gets the left child of this node. More... | |
List * | getListOfNodes (ASTNodePredicate predicate) const |
Returns a list of nodes satisfying a given predicate. More... | |
double | getMantissa () const |
Gets the mantissa value of this node. More... | |
const char * | getName () const |
Gets the value of this node as a string. More... | |
unsigned int | getNumChildren () const |
Gets the number of children that this node has. More... | |
long | getNumerator () const |
Gets the value of the numerator of this node. More... | |
unsigned int | getNumSemanticsAnnotations () const |
Gets the number of semantic annotation elements inside this node. More... | |
const char * | getOperatorName () const |
Gets the value of this operator node as a string. More... | |
SBase * | getParentSBMLObject () const |
Returns the parent SBML object. More... | |
int | getPrecedence () const |
Gets the precedence of this node in the infix math syntax of SBML Level 1. More... | |
double | getReal () const |
Gets the real-numbered value of this node. More... | |
ASTNode * | getRightChild () const |
Gets the right child of this node. More... | |
XMLNode * | getSemanticsAnnotation (unsigned int n) const |
Gets the nth semantic annotation of this node. More... | |
std::string | getStyle () const |
Gets the style of this ASTNode. More... | |
ASTNodeType_t | getType () const |
Gets the type of this ASTNode. More... | |
std::string | getUnits () const |
Gets the units of this ASTNode. More... | |
void * | getUserData () const |
Returns the user data that has been previously set via setUserData(). More... | |
double | getValue () const |
Returns the numerical value of this ASTNode. More... | |
bool | hasCorrectNumberArguments () const |
Returns true or false depending on whether this ASTNode has the correct number of children for its type. More... | |
int | hasTypeAndNumChildren (ASTNodeType_t type, unsigned int numchildren) const |
Returns true if this node is of type. More... | |
bool | hasUnits () const |
Returns true (non-zero) if this node or any of its children nodes have the attribute sbml:units . More... | |
int | insertChild (unsigned int n, ASTNode *disownedChild) |
Inserts the given ASTNode at point n in the list of children of this ASTNode. More... | |
bool | isAvogadro () const |
Returns true (non-zero) if this node is the special symbol avogadro . More... | |
bool | isBoolean () const |
Returns true (non-zero) if this node has a boolean type (a logical operator, a relational operator, or the constants true or false ). More... | |
bool | isCiNumber () const |
Returns true (non-zero) if this node represents a MathML ci element representing a value not a function (e.g., true , Pi ). More... | |
bool | isConstant () const |
Returns true (non-zero) if this node represents a MathML constant (e.g., true , Pi ). More... | |
bool | isConstantNumber () const |
Returns true (non-zero) if this node represents a MathML constant with numeric value(e.g., Pi ). More... | |
bool | isCSymbolFunction () const |
Returns true (non-zero) if this node represents a MathML csymbol representing a function. More... | |
bool | isFunction () const |
Returns true (non-zero) if this node represents a MathML function (e.g., abs() ), or an SBML Level 1 function, or a user-defined function. More... | |
bool | isInfinity () const |
Returns true (non-zero) if this node represents the special IEEE 754 value infinity, false (zero) otherwise. More... | |
bool | isInteger () const |
Returns true (non-zero) if this node contains an integer value, false (zero) otherwise. More... | |
bool | isLambda () const |
Returns true (non-zero) if this node is a MathML <lambda> , false (zero) otherwise. More... | |
bool | isLog10 () const |
Returns true (non-zero) if this node represents a log10 function, false (zero) otherwise. More... | |
bool | isLogical () const |
Returns true (non-zero) if this node is a MathML logical operator (i.e., and , or , not , xor ). More... | |
bool | isName () const |
Returns true (non-zero) if this node is a user-defined variable name in SBML L1, L2 (MathML), or the special symbols time or avogadro . More... | |
bool | isNaN () const |
Returns true (non-zero) if this node represents the special IEEE 754 value "not a number" (NaN), false (zero) otherwise. More... | |
bool | isNegInfinity () const |
Returns true (non-zero) if this node represents the special IEEE 754 value "negative infinity", false (zero) otherwise. More... | |
bool | isNumber () const |
Returns true (non-zero) if this node contains a number, false (zero) otherwise. More... | |
bool | isOperator () const |
Returns true (non-zero) if this node is a mathematical operator, meaning, + , - , * , / or ^ (power). More... | |
bool | isPiecewise () const |
Returns true (non-zero) if this node is the MathML <piecewise> construct, false (zero) otherwise. More... | |
bool | isRational () const |
Returns true (non-zero) if this node represents a rational number, false (zero) otherwise. More... | |
bool | isReal () const |
Returns true (non-zero) if this node can represent a real number, false (zero) otherwise. More... | |
bool | isRelational () const |
Returns true (non-zero) if this node is a MathML relational operator, meaning == , >= , > , < , and != . More... | |
bool | isSetClass () const |
Returns true (non-zero) if this node has a value for the MathML attribute "class". More... | |
bool | isSetId () const |
Returns true (non-zero) if this node has a value for the MathML attribute "id". More... | |
bool | isSetParentSBMLObject () const |
Returns true if this node has a value for the parent SBML object. More... | |
bool | isSetStyle () const |
Returns true (non-zero) if this node has a value for the MathML attribute "style". More... | |
bool | isSetUnits () const |
Returns true (non-zero) if this node has the attribute sbml:units . More... | |
bool | isSetUserData () const |
Returns true if this node has a user data object. More... | |
bool | isSqrt () const |
Returns true (non-zero) if this node represents a square root function, false (zero) otherwise. More... | |
bool | isUMinus () const |
Returns true (non-zero) if this node is a unary minus operator, false (zero) otherwise. More... | |
bool | isUnknown () const |
Returns true (non-zero) if this node has an unknown type. More... | |
bool | isUPlus () const |
Returns true (non-zero) if this node is a unary plus operator, false (zero) otherwise. More... | |
bool | isUserFunction () const |
Returns true (non-zero) if this node represents a MathML user-defined function. More... | |
bool | isWellFormedASTNode () const |
Returns true or false depending on whether this ASTNode is well-formed. More... | |
ASTNode & | operator= (const ASTNode &rhs) |
Assignment operator for ASTNode. More... | |
int | prependChild (ASTNode *disownedChild) |
Adds the given node as a child of this ASTNode. More... | |
void | reduceToBinary () |
Reduces this ASTNode to a binary tree. More... | |
int | removeChild (unsigned int n) |
Removes the nth child of this ASTNode object. More... | |
virtual void | renameSIdRefs (const std::string &oldid, const std::string &newid) |
Renames all the SIdRef attributes on this node and any child node. More... | |
virtual void | renameUnitSIdRefs (const std::string &oldid, const std::string &newid) |
Renames all the UnitSIdRef attributes on this node and any child node. More... | |
void | replaceArgument (const std::string bvar, ASTNode *arg) |
Replaces occurences of a given name within this ASTNode with the name/value/formula represented by arg . More... | |
int | replaceChild (unsigned int n, ASTNode *disownedChild, bool delreplaced=false) |
Replaces and optionally deletes the nth child of this ASTNode with the given ASTNode. More... | |
bool | returnsBoolean (const Model *model=NULL) const |
Returns true (non-zero) if this node returns a boolean type or false (zero) otherwise. More... | |
int | setCharacter (char value) |
Sets the value of this ASTNode to the given character. More... | |
int | setClass (const std::string &className) |
Sets the MathML class of this ASTNode to className. More... | |
int | setId (const std::string &id) |
Sets the MathML id of this ASTNode to id. More... | |
int | setName (const char *name) |
Sets the value of this ASTNode to the given name. More... | |
int | setStyle (const std::string &style) |
Sets the MathML style of this ASTNode to style. More... | |
int | setType (ASTNodeType_t type) |
Sets the type of this ASTNode to the given type code. More... | |
int | setUnits (const std::string &units) |
Sets the units of this ASTNode to units. More... | |
int | setUserData (void *userData) |
Sets the user data of this node. More... | |
int | setValue (int value) |
Sets the value of this ASTNode to the given integer and sets the node type to. More... | |
int | setValue (long value) |
Sets the value of this ASTNode to the given (long ) integer and sets the node type to. More... | |
int | setValue (long numerator, long denominator) |
Sets the value of this ASTNode to the given rational in two parts: the numerator and denominator. More... | |
int | setValue (double value) |
Sets the value of this ASTNode to the given real (double ) and sets the node type to. More... | |
int | setValue (double mantissa, long exponent) |
Sets the value of this ASTNode to the given real (double ) in two parts: the mantissa and the exponent. More... | |
int | swapChildren (ASTNode *that) |
Swaps the children of this ASTNode object with the children of the given ASTNode object. More... | |
int | unsetClass () |
Unsets the MathML class of this ASTNode. More... | |
int | unsetId () |
Unsets the MathML id of this ASTNode. More... | |
int | unsetParentSBMLObject () |
Unsets the parent SBML object. More... | |
int | unsetStyle () |
Unsets the MathML style of this ASTNode. More... | |
int | unsetUnits () |
Unsets the units of this ASTNode. More... | |
int | unsetUserData () |
Unsets the user data of this node. More... | |
virtual | ~ASTNode () |
Destroys this ASTNode, including any child nodes. More... | |
ASTNode::ASTNode | ( | ASTNodeType_t | type = AST_UNKNOWN | ) |
Creates and returns a new ASTNode.
Unless the argument type
is given, the returned node will by default have a type of
ASTNode::ASTNode | ( | Token_t * | token | ) |
ASTNode::ASTNode | ( | const ASTNode & | orig | ) |
|
virtual |
Destroys this ASTNode, including any child nodes.
int ASTNode::addChild | ( | ASTNode * | disownedChild, |
bool | inRead = false |
||
) |
int ASTNode::addSemanticsAnnotation | ( | XMLNode * | disownedAnnotation | ) |
Adds the given XMLNode as a semantic annotation of this ASTNode.
The<semantics>
element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct. The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation>
or
<annotation-xml>
elements. Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key. Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
disownedAnnotation | the annotation to add. |
bool ASTNode::canonicalize | ( | ) |
Converts this ASTNode to a canonical form and returns true
if successful, false
otherwise.
The rules determining the canonical form conversion are as follows:
ASTNode * ASTNode::deepCopy | ( | ) | const |
void ASTNode::fillListOfNodes | ( | ASTNodePredicate | predicate, |
List * | lst | ||
) | const |
Returns a list of nodes rooted at a given node and satisfying a given predicate.
This method is identical to calling getListOfNodes(ASTNodePredicate predicate) const, except that instead of creating a new List object, it uses the one passed in as argument lst
. This method a depth-first search of the tree rooted at this ASTNode object, and adds to the list lst
the nodes for which the given function predicate(node)
returns true
(non-zero).
For portability between different programming languages, the predicate is passed in as a pointer to a function. The function definition must have the type ASTNodePredicate , which is defined as
int (*ASTNodePredicate) (const ASTNode_t *node);
where a return value of non-zero represents true
and zero represents false
.
int ASTNode::freeName | ( | ) |
ASTBasePlugin* ASTNode::getASTPlugin | ( | const SBMLNamespaces * | sbmlns | ) |
ASTBasePlugin* ASTNode::getASTPlugin | ( | ASTNodeType_t | type | ) |
ASTBasePlugin* ASTNode::getASTPlugin | ( | const std::string & | name, |
bool | isCsymbol = false |
||
) |
const ASTBasePlugin* ASTNode::getASTPlugin | ( | const SBMLNamespaces * | sbmlns | ) | const |
const ASTBasePlugin* ASTNode::getASTPlugin | ( | ASTNodeType_t | type | ) | const |
const ASTBasePlugin* ASTNode::getASTPlugin | ( | const std::string & | name, |
bool | isCsymbol = false |
||
) | const |
char ASTNode::getCharacter | ( | ) | const |
Gets the value of this node as a single character.
This function should be called only when ASTNode::getType() returns
ASTNode * ASTNode::getChild | ( | unsigned int | n | ) | const |
Gets a child of this node according to its index number.
n | the index of the child to get |
NULL
if this node has no nth child (n >
ASTNode::getNumChildren() - 1
).std::string ASTNode::getClass | ( | ) | const |
XMLAttributes * ASTNode::getDefinitionURL | ( | ) | const |
Gets the MathML "definitionURL" attribute value.
definitionURL
attribute, in the form of a libSBML XMLAttributes object. std::string ASTNode::getDefinitionURLString | ( | ) | const |
Returns the MathML definitionURL
attribute value as a string.
definitionURL
attribute, as a string.long ASTNode::getDenominator | ( | ) | const |
Gets the value of the denominator of this node.
This function should be called only when ASTNode::getType() ==
long ASTNode::getExponent | ( | ) | const |
Gets the exponent value of this ASTNode.
This function should be called only when ASTNode::getType() returns
std::string ASTNode::getId | ( | ) | const |
long ASTNode::getInteger | ( | ) | const |
Gets the value of this node as an integer.
This function should be called only whenASTNode::getType() ==
ASTNode * ASTNode::getLeftChild | ( | ) | const |
Gets the left child of this node.
0
.List * ASTNode::getListOfNodes | ( | ASTNodePredicate | predicate | ) | const |
Returns a list of nodes satisfying a given predicate.
This performs a depth-first search of the tree rooted at this ASTNode object, and returns a List of nodes for which the given function predicate(node)
returns true
(non-zero).
For portability between different programming languages, the predicate is passed in as a pointer to a function.
predicate | the predicate to use |
true
(non-zero). The List returned is owned by the caller and should be deleted after the caller is done using it. The ASTNode objects in the list; however, are not owned by the caller (as they still belong to the tree itself), and therefore should not be deleted. double ASTNode::getMantissa | ( | ) | const |
Gets the mantissa value of this node.
This function should be called only when ASTNode::getType() returns
const char * ASTNode::getName | ( | ) | const |
Gets the value of this node as a string.
This function may be called on nodes that (1) are not operators, i.e., nodes for whichASTNode::isOperator() returns false
, and (2) are not numbers, i.e., ASTNode::isNumber() returns false
.
unsigned int ASTNode::getNumChildren | ( | ) | const |
Gets the number of children that this node has.
long ASTNode::getNumerator | ( | ) | const |
Gets the value of the numerator of this node.
This function should be called only when ASTNode::getType() ==
unsigned int ASTNode::getNumSemanticsAnnotations | ( | ) | const |
Gets the number of semantic annotation elements inside this node.
The<semantics>
element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct. The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation>
or
<annotation-xml>
elements. Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key. Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
const char * ASTNode::getOperatorName | ( | ) | const |
Gets the value of this operator node as a string.
This function may be called on nodes that are operators, i.e., nodes for which ASTNode::isOperator() returns true
.
SBase * ASTNode::getParentSBMLObject | ( | ) | const |
Returns the parent SBML object.
int ASTNode::getPrecedence | ( | ) | const |
Gets the precedence of this node in the infix math syntax of SBML Level 1.
For more information about the infix syntax, see the discussion about text string formulas at the top of the documentation for ASTNode.
double ASTNode::getReal | ( | ) | const |
Gets the real-numbered value of this node.
This function should be called only when ASTNode::isReal() == true
.
This function performs the necessary arithmetic if the node type is
ASTNode * ASTNode::getRightChild | ( | ) | const |
Gets the right child of this node.
NULL
if this node has no right child. If ASTNode::getNumChildren() > 1
, then this is equivalent to: getChild( getNumChildren() - 1 );
XMLNode * ASTNode::getSemanticsAnnotation | ( | unsigned int | n | ) | const |
Gets the nth semantic annotation of this node.
The<semantics>
element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct. The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation>
or
<annotation-xml>
elements. Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key. Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
NULL
if this node has no nth annotation (n >
ASTNode::getNumSemanticsAnnotations() - 1
).std::string ASTNode::getStyle | ( | ) | const |
ASTNodeType_t ASTNode::getType | ( | ) | const |
Gets the type of this ASTNode.
The value returned is one of the enumeration values such as
std::string ASTNode::getUnits | ( | ) | const |
Gets the units of this ASTNode.
SBML Level 3 Version 1 introduced the ability to include an attributesbml:units
on MathML cn
elements
appearing in SBML mathematical formulas. The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn
element. The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model. Here, the sbml
portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3. The following example illustrates how this attribute can be
used to define a number with value 10
and unit of measurement
second
:
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> <cn type="integer" sbml:units="second"> 10 </cn> </math>
sbml:units
attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML. void * ASTNode::getUserData | ( | ) | const |
Returns the user data that has been previously set via setUserData().
NULL
if no user data has been set. double ASTNode::getValue | ( | ) | const |
bool ASTNode::hasCorrectNumberArguments | ( | ) | const |
int ASTNode::hasTypeAndNumChildren | ( | ASTNodeType_t | type, |
unsigned int | numchildren | ||
) | const |
Returns true
if this node is of type.
type | and has |
numchildren | number of children. Designed for use in cases where it is useful to discover if the node is a unary not or unary minus, or a times node with no children, etc. |
true
if this ASTNode is has the specified type and number of children, false
otherwise. bool ASTNode::hasUnits | ( | ) | const |
Returns true
(non-zero) if this node or any of its children nodes have the attribute sbml:units
.
sbml:units
on MathML cn
elements
appearing in SBML mathematical formulas. The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn
element. The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model. Here, the sbml
portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3. The following example illustrates how this attribute can be
used to define a number with value 10
and unit of measurement
second
:
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> <cn type="integer" sbml:units="second"> 10 </cn> </math>
true
if this ASTNode or its children has units associated with it, false
otherwise.sbml:units
attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML. int ASTNode::insertChild | ( | unsigned int | n, |
ASTNode * | disownedChild | ||
) |
bool ASTNode::isAvogadro | ( | ) | const |
Returns true
(non-zero) if this node is the special symbol avogadro
.
The predicate returns false
(zero) otherwise.
true
if this ASTNode is the special symbol avogadro. bool ASTNode::isBoolean | ( | ) | const |
Returns true
(non-zero) if this node has a boolean type (a logical operator, a relational operator, or the constants true
or false
).
bool ASTNode::isCiNumber | ( | ) | const |
Returns true
(non-zero) if this node represents a MathML ci element representing a value not a function (e.g., true
, Pi
).
true
if this ASTNode is a MathML ci element, false
otherwise. bool ASTNode::isConstant | ( | ) | const |
Returns true
(non-zero) if this node represents a MathML constant (e.g., true
, Pi
).
true
if this ASTNode is a MathML constant, false
otherwise.true
for bool ASTNode::isConstantNumber | ( | ) | const |
Returns true
(non-zero) if this node represents a MathML constant with numeric value(e.g., Pi
).
true
if this ASTNode is a MathML constant, false
otherwise.true
for bool ASTNode::isCSymbolFunction | ( | ) | const |
Returns true
(non-zero) if this node represents a MathML csymbol representing a function.
true
if this ASTNode is a MathML csymbol function, false
otherwise. bool ASTNode::isFunction | ( | ) | const |
Returns true
(non-zero) if this node represents a MathML function (e.g., abs()
), or an SBML Level 1 function, or a user-defined function.
true
if this ASTNode is a function, false
otherwise. bool ASTNode::isInfinity | ( | ) | const |
Returns true
(non-zero) if this node represents the special IEEE 754 value infinity, false
(zero) otherwise.
true
if this ASTNode is the special IEEE 754 value infinity, false
otherwise. bool ASTNode::isInteger | ( | ) | const |
Returns true
(non-zero) if this node contains an integer value, false
(zero) otherwise.
true
if this ASTNode is of type bool ASTNode::isLambda | ( | ) | const |
Returns true
(non-zero) if this node is a MathML <lambda>
, false
(zero) otherwise.
true
if this ASTNode is of type bool ASTNode::isLog10 | ( | ) | const |
Returns true
(non-zero) if this node represents a log10
function, false
(zero) otherwise.
More precisely, this predicate returns true
if the node type is
bool ASTNode::isLogical | ( | ) | const |
Returns true
(non-zero) if this node is a MathML logical operator (i.e., and
, or
, not
, xor
).
true
if this ASTNode is a MathML logical operator bool ASTNode::isName | ( | ) | const |
Returns true
(non-zero) if this node is a user-defined variable name in SBML L1, L2 (MathML), or the special symbols time
or avogadro
.
The predicate returns false
(zero) otherwise.
true
if this ASTNode is a user-defined variable name in SBML L1, L2 (MathML) or the special symbols delay or time. bool ASTNode::isNaN | ( | ) | const |
Returns true
(non-zero) if this node represents the special IEEE 754 value "not a number" (NaN), false
(zero) otherwise.
true
if this ASTNode is the special IEEE 754 NaN. bool ASTNode::isNegInfinity | ( | ) | const |
Returns true
(non-zero) if this node represents the special IEEE 754 value "negative infinity", false
(zero) otherwise.
true
if this ASTNode is the special IEEE 754 value negative infinity, false
otherwise. bool ASTNode::isNumber | ( | ) | const |
Returns true
(non-zero) if this node contains a number, false
(zero) otherwise.
This is functionally equivalent to the following code:
isInteger() || isReal()
true
if this ASTNode is a number, false
otherwise. bool ASTNode::isOperator | ( | ) | const |
Returns true
(non-zero) if this node is a mathematical operator, meaning, +
, -
, *
, /
or ^
(power).
true
if this ASTNode is an operator. bool ASTNode::isPiecewise | ( | ) | const |
Returns true
(non-zero) if this node is the MathML <piecewise>
construct, false
(zero) otherwise.
true
if this ASTNode is a MathML piecewise
function bool ASTNode::isRational | ( | ) | const |
Returns true
(non-zero) if this node represents a rational number, false
(zero) otherwise.
true
if this ASTNode is of type bool ASTNode::isReal | ( | ) | const |
Returns true
(non-zero) if this node can represent a real number, false
(zero) otherwise.
More precisely, this node must be of one of the following types:
bool ASTNode::isRelational | ( | ) | const |
Returns true
(non-zero) if this node is a MathML relational operator, meaning ==
, >=
, >
, <
, and !=
.
true
if this ASTNode is a MathML relational operator, false
otherwise bool ASTNode::isSetClass | ( | ) | const |
Returns true
(non-zero) if this node has a value for the MathML attribute "class".
bool ASTNode::isSetId | ( | ) | const |
Returns true
(non-zero) if this node has a value for the MathML attribute "id".
bool ASTNode::isSetParentSBMLObject | ( | ) | const |
Returns true
if this node has a value for the parent SBML object.
false
otherwise.bool ASTNode::isSetStyle | ( | ) | const |
Returns true
(non-zero) if this node has a value for the MathML attribute "style".
bool ASTNode::isSetUnits | ( | ) | const |
Returns true
(non-zero) if this node has the attribute sbml:units
.
sbml:units
on MathML cn
elements
appearing in SBML mathematical formulas. The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn
element. The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model. Here, the sbml
portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3. The following example illustrates how this attribute can be
used to define a number with value 10
and unit of measurement
second
:
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> <cn type="integer" sbml:units="second"> 10 </cn> </math>
true
if this ASTNode has units associated with it, false
otherwise.sbml:units
attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML. bool ASTNode::isSetUserData | ( | ) | const |
Returns true
if this node has a user data object.
false
otherwise. bool ASTNode::isSqrt | ( | ) | const |
Returns true
(non-zero) if this node represents a square root function, false
(zero) otherwise.
More precisely, the node type must be
bool ASTNode::isUMinus | ( | ) | const |
Returns true
(non-zero) if this node is a unary minus operator, false
(zero) otherwise.
A node is defined as a unary minus node if it is of type
bool ASTNode::isUnknown | ( | ) | const |
Returns true
(non-zero) if this node has an unknown type.
"Unknown" nodes have the type
bool ASTNode::isUPlus | ( | ) | const |
Returns true
(non-zero) if this node is a unary plus operator, false
(zero) otherwise.
A node is defined as a unary minus node if it is of type
bool ASTNode::isUserFunction | ( | ) | const |
Returns true
(non-zero) if this node represents a MathML user-defined function.
true
if this ASTNode is a user-defined function, false
otherwise. bool ASTNode::isWellFormedASTNode | ( | ) | const |
Returns true
or false
depending on whether this ASTNode is well-formed.
true
if this ASTNode is well-formed, false
otherwise.int ASTNode::prependChild | ( | ASTNode * | disownedChild | ) |
void ASTNode::reduceToBinary | ( | ) |
int ASTNode::removeChild | ( | unsigned int | n | ) |
Removes the nth child of this ASTNode object.
n | unsigned int the index of the child to remove |
|
virtual |
Renames all the SIdRef attributes on this node and any child node.
|
virtual |
Renames all the UnitSIdRef attributes on this node and any child node.
(The only place UnitSIDRefs appear in MathML <cn>
elements.)
void ASTNode::replaceArgument | ( | const std::string | bvar, |
ASTNode * | arg | ||
) |
Replaces occurences of a given name within this ASTNode with the name/value/formula represented by arg
.
For example, if the formula in this ASTNode is x + y
, then the <bvar>
is x
and arg
is an ASTNode representing the real value 3
. This method substitutes 3
for x
within this ASTNode object.
bvar | a string representing the variable name to be substituted |
arg | an ASTNode representing the name/value/formula to substitute |
int ASTNode::replaceChild | ( | unsigned int | n, |
ASTNode * | disownedChild, | ||
bool | delreplaced = false |
||
) |
bool ASTNode::returnsBoolean | ( | const Model * | model = NULL | ) | const |
Returns true
(non-zero) if this node returns a boolean type or false
(zero) otherwise.
This function looks at the whole ASTNode rather than just the top level of the ASTNode. Thus it will consider return values from piecewise statements. In addition, if this ASTNode uses a function call, the return value of the functionDefinition will be determined. Note that this is only possible where the ASTNode can trace its parent Model, that is, the ASTNode must represent the math element of some SBML object that has already been added to an instance of an SBMLDocument.
int ASTNode::setCharacter | ( | char | value | ) |
Sets the value of this ASTNode to the given character.
If character is one of +
, -
, *
, /
or ^
, the node type will be set accordingly. For all other characters, the node type will be set to
int ASTNode::setClass | ( | const std::string & | className | ) |
Sets the MathML class of this ASTNode to className.
className | string representing the MathML class for this node. |
int ASTNode::setId | ( | const std::string & | id | ) |
int ASTNode::setName | ( | const char * | name | ) |
int ASTNode::setStyle | ( | const std::string & | style | ) |
int ASTNode::setType | ( | ASTNodeType_t | type | ) |
Sets the type of this ASTNode to the given type code.
type | the type to which this node should be set |
int ASTNode::setUnits | ( | const std::string & | units | ) |
Sets the units of this ASTNode to units.
The units will be set only if this ASTNode object represents a MathML <cn>
element, i.e., represents a number. Callers may use ASTNode::isNumber() to inquire whether the node is of that type.
sbml:units
on MathML cn
elements
appearing in SBML mathematical formulas. The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn
element. The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model. Here, the sbml
portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3. The following example illustrates how this attribute can be
used to define a number with value 10
and unit of measurement
second
:
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> <cn type="integer" sbml:units="second"> 10 </cn> </math>
units | string representing the unit identifier. |
int ASTNode::setUserData | ( | void * | userData | ) |
Sets the user data of this node.
The user data can be used by the application developer to attach custom information to the node. In case of a deep copy, this attribute will passed as it is. The attribute will be never interpreted by this class.
userData | specifies the new user data. |
int ASTNode::setValue | ( | int | value | ) |
Sets the value of this ASTNode to the given integer and sets the node type to.
int ASTNode::setValue | ( | long | value | ) |
Sets the value of this ASTNode to the given (long
) integer and sets the node type to.
int ASTNode::setValue | ( | long | numerator, |
long | denominator | ||
) |
Sets the value of this ASTNode to the given rational in two parts: the numerator and denominator.
The node type is set to
int ASTNode::setValue | ( | double | value | ) |
Sets the value of this ASTNode to the given real (double
) and sets the node type to.
int ASTNode::setValue | ( | double | mantissa, |
long | exponent | ||
) |
Sets the value of this ASTNode to the given real (double
) in two parts: the mantissa and the exponent.
The node type is set to
int ASTNode::swapChildren | ( | ASTNode * | that | ) |
int ASTNode::unsetClass | ( | ) |
Unsets the MathML class of this ASTNode.
int ASTNode::unsetId | ( | ) |
Unsets the MathML id of this ASTNode.
int ASTNode::unsetParentSBMLObject | ( | ) |
Unsets the parent SBML object.
int ASTNode::unsetStyle | ( | ) |
Unsets the MathML style of this ASTNode.
int ASTNode::unsetUnits | ( | ) |
Unsets the units of this ASTNode.
int ASTNode::unsetUserData | ( | ) |
Unsets the user data of this node.
The user data can be used by the application developer to attach custom information to the node. In case of a deep copy, this attribute will passed as it is. The attribute will be never interpreted by this class.