libSBML C++ API
libSBML 5.12.0 C++ API
|
{core}
Abstract Syntax Trees for mathematical expressions.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. 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).
"1 + 2"
is represented as an AST with one plus node having two integer children nodes for the numbers 1
and 2
. The figure also shows the corresponding MathML representation:Infix | AST | MathML |
---|---|---|
1 + 2
|
<math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <plus/> <cn type="integer"> 1 </cn> <cn type="integer"> 2 </cn> </apply> </math>
|
The following are other noteworthy points about the AST representation in libSBML:
double
data type. This is done so that when an SBML model is read in and then written out again, the amount of change introduced by libSBML to the SBML during the round-trip activity is minimized.For many applications, the details of ASTs are irrelevant because libSBML provides text-string based translation functions such as SBML_formulaToL3String()
The text-string form of mathematical formulas produced by SBML_formulaToString()
Public Member Functions | |
int | addChild (ASTNode *disownedChild) |
Adds the given node as a child of this ASTNode. More... | |
int | addSemanticsAnnotation (XMLNode *disownedAnnotation) |
Adds the given XMLNode as a MathML <semantics> element to this ASTNode. More... | |
ASTNode (ASTNodeType_t type) | |
Creates 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. 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... | |
char | getCharacter () const |
Returns the value of this node as a single character. More... | |
virtual ASTNode * | getChild (unsigned int n) const |
Returns the child at index n of this node. More... | |
std::string | getClass () const |
Returns the MathML class attribute value of this ASTNode. More... | |
XMLAttributes * | getDefinitionURL () const |
Returns the MathML definitionURL attribute value. More... | |
std::string | getDefinitionURLString () const |
Returns the MathML definitionURL attribute value as a string. More... | |
long | getDenominator () const |
Returns the value of the denominator of this node. More... | |
long | getExponent () const |
Returns the exponent value of this ASTNode. More... | |
virtual int | getExtendedType () const |
Returns the extended type of this ASTNode. More... | |
std::string | getId () const |
Returns the MathML id attribute value of this ASTNode. More... | |
long | getInteger () const |
Returns the value of this node as an integer. More... | |
ASTNode * | getLeftChild () const |
Returns 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 |
Returns the mantissa value of this node. More... | |
const char * | getName () const |
Returns the value of this node as a string. More... | |
unsigned int | getNumChildren () const |
Returns the number of children of this node. More... | |
long | getNumerator () const |
Returns the value of the numerator of this node. More... | |
unsigned int | getNumSemanticsAnnotations () const |
Returns the number of MathML <semantics> element elements on this node. More... | |
const char * | getOperatorName () const |
Returns the value of this operator node as a string. More... | |
SBase * | getParentSBMLObject () const |
Returns the parent SBML object. More... | |
int | getPrecedence () const |
Returns the precedence of this node in the infix math syntax of SBML Level 1. More... | |
double | getReal () const |
Returns the real-numbered value of this node. More... | |
ASTNode * | getRightChild () const |
Returns the right child of this node. More... | |
XMLNode * | getSemanticsAnnotation (unsigned int n) const |
Returns the nth MathML <semantics> element on this ASTNode. More... | |
std::string | getStyle () const |
Returns the MathML style attribute value of this ASTNode. More... | |
ASTNodeType_t | getType () const |
Returns the type of this ASTNode. More... | |
std::string | getUnits () const |
Returns 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 if this ASTNode has the correct number of children for its type. More... | |
int | hasTypeAndNumChildren (int type, unsigned int numchildren) const |
Returns true if this node is of a certain type with a specific number of children. More... | |
bool | hasUnits () const |
Returns true 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 node at a given point in the current ASTNode's list of children. More... | |
virtual bool | isAvogadro () const |
Returns true if this node represents the predefined value for Avogadro's constant. More... | |
virtual bool | isBoolean () const |
Returns true if this node has a Boolean type. More... | |
virtual bool | isConstant () const |
Returns true if this node represents a MathML constant. More... | |
virtual bool | isFunction () const |
Returns true if this node represents a function. More... | |
bool | isInfinity () const |
Returns true if this node represents the special IEEE 754 value for infinity. More... | |
virtual bool | isInteger () const |
Returns true if this node contains an integer value. More... | |
virtual bool | isLambda () const |
Returns true if this node is a MathML <lambda> . More... | |
virtual bool | isLog10 () const |
Returns true if this node represents a log10 function. More... | |
virtual bool | isLogical () const |
Returns true if this node is a MathML logical operator. More... | |
virtual bool | isName () const |
Returns true if this node is a user-defined variable name or the symbols for time or Avogadro's constant. More... | |
bool | isNaN () const |
Returns true if this node represents the special IEEE 754 value "not a number" (NaN). More... | |
bool | isNegInfinity () const |
Returns true if this node represents the special IEEE 754 value "negative infinity". More... | |
virtual bool | isNumber () const |
Returns true if this node contains a number. More... | |
virtual bool | isOperator () const |
Returns true if this node is a mathematical operator. More... | |
virtual bool | isPiecewise () const |
Returns true if this node is the MathML <piecewise> construct. More... | |
virtual bool | isQualifier () const |
Predicate returning true if this node is a MathML qualifier. More... | |
virtual bool | isRational () const |
Returns true if this node represents a rational number. More... | |
virtual bool | isReal () const |
Returns true if this node can represent a real number. More... | |
virtual bool | isRelational () const |
Returns true if this node is a MathML relational operator. More... | |
virtual bool | isSemantics () const |
Predicate returning true if this node is a MathML semantics node. More... | |
bool | isSetClass () const |
Returns true if this node has a value for the MathML attribute class . More... | |
bool | isSetId () const |
Returns true 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 if this node has a value for the MathML attribute style . More... | |
bool | isSetUnits () const |
Returns true 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 if this node represents a square root function. More... | |
bool | isUMinus () const |
Returns true if this node is a unary minus operator. More... | |
virtual bool | isUnknown () const |
Returns true if this node has an unknown type. More... | |
bool | isUPlus () const |
Returns true if this node is a unary plus operator. 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 its child nodes. More... | |
virtual void | renameUnitSIdRefs (const std::string &oldid, const std::string &newid) |
Renames all the UnitSIdRef attributes on this node and its child nodes. More... | |
void | replaceArgument (const std::string &bvar, ASTNode *arg) |
Replaces occurrences of a given name with a given ASTNode. More... | |
int | replaceChild (unsigned int n, ASTNode *disownedChild, bool delreplaced=false) |
Replaces the nth child of this ASTNode with the given ASTNode. More... | |
bool | returnsBoolean (const Model *model=NULL) const |
Returns true if this node returns a Boolean value. 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 attribute class of this ASTNode. More... | |
int | setDefinitionURL (XMLAttributes url) |
Sets the MathML attribute definitionURL . More... | |
int | setDefinitionURL (const std::string &url) |
Sets the MathML attribute definitionURL . More... | |
int | setId (const std::string &id) |
Sets the MathML attribute id of this ASTNode. More... | |
int | setName (const char *name) |
Sets the value of this ASTNode to the given name. More... | |
int | setParentSBMLObject (SBase *sb) |
Sets the parent SBML object. More... | |
int | setStyle (const std::string &style) |
Sets the MathML attribute style of this ASTNode. More... | |
int | setType (ASTNodeType_t type) |
Sets the type of this ASTNode to the given type code. More... | |
int | setType (int type) |
Sets the type of this ASTNode. 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. More... | |
int | setValue (long value) |
Sets the value of this ASTNode to the given (long ) integer. More... | |
int | setValue (long numerator, long denominator) |
Sets the value of this ASTNode to the given rational. More... | |
int | setValue (double value) |
Sets the value of this ASTNode to the given real (double ). More... | |
int | setValue (double mantissa, long exponent) |
Sets the value of this ASTNode to the given real (double ) More... | |
int | swapChildren (ASTNode *that) |
Swaps the children of this node with the children of another node. More... | |
int | unsetClass () |
Unsets the MathML class attribute of this ASTNode. More... | |
int | unsetId () |
Unsets the MathML id attribute of this ASTNode. More... | |
int | unsetParentSBMLObject () |
Unsets the parent SBML object. More... | |
int | unsetStyle () |
Unsets the MathML style attribute 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... | |
Friends | |
class | ASTSemanticsNode |
ASTNode::ASTNode | ( | ASTNodeType_t | type | ) |
Creates a new ASTNode.
Unless the argument type
is given, the returned node will by default have a type of AST_UNKNOWNendif
ASTNode::ASTNode | ( | Token_t * | token | ) |
ASTNode::ASTNode | ( | const ASTNode & | orig | ) |
|
virtual |
Destroys this ASTNode, including any child nodes.
int ASTNode::addChild | ( | ASTNode * | disownedChild | ) |
Adds the given node as a child of this ASTNode.
Child nodes are added in-order, from left to right.
disownedChild | the ASTNode instance to add |
int ASTNode::addSemanticsAnnotation | ( | XMLNode * | disownedAnnotation | ) |
Adds the given XMLNode as a MathML <semantics>
element to this ASTNode.
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.
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 ASTNode::getListOfNodes(), 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
.
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
where a return value of nonzero represents true
and zero represents false
.
int ASTNode::freeName | ( | ) |
Frees the name of this ASTNode and sets it to NULL
.
This operation is only applicable to ASTNode objects corresponding to operators, numbers, or AST_UNKNOWNendif
char ASTNode::getCharacter | ( | ) | const |
Returns the value of this node as a single character.
This function should be called only when ASTNode::getType() returns AST_MINUSendif
|
virtual |
Returns the child at index n of this node.
n | the index of the child to get |
NULL
if this node has no nth child (n >
getNumChildren() - 1
).std::string ASTNode::getClass | ( | ) | const |
Returns the MathML class
attribute value of this ASTNode.
XMLAttributes * ASTNode::getDefinitionURL | ( | ) | const |
Returns 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 |
Returns the value of the denominator of this node.
1
if this node has no numerical value.long ASTNode::getExponent | ( | ) | const |
Returns the exponent value of this ASTNode.
0
if this is not a type of node that has an exponent.
|
virtual |
Returns the extended type of this ASTNode.
The type may be either a core ASTNodeType_t valueor a value of a type code defined by an SBML Level 3 package.
std::string ASTNode::getId | ( | ) | const |
long ASTNode::getInteger | ( | ) | const |
Returns the value of this node as an integer.
If this node type is AST_RATIONALendif
ASTNode * ASTNode::getLeftChild | ( | ) | const |
Returns 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
. 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
where a return value of nonzero represents true
and zero represents false
.
predicate | the predicate to use |
true
. 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 |
Returns the mantissa value of this node.
If getType() returns AST_REALendif
const char * ASTNode::getName | ( | ) | const |
Returns the value of this node as a string.
This function may be called on nodes that (1) are not operators, i.e., nodes for which isOperator() returns false
, and (2) are not numbers, i.e., isNumber() returns false
.
NULL
if it is a node that does not have a name equivalent (e.g., if it is a number). unsigned int ASTNode::getNumChildren | ( | ) | const |
Returns the number of children of this node.
long ASTNode::getNumerator | ( | ) | const |
Returns the value of the numerator of this node.
This function should be called only when getType() returns AST_RATIONALendif
unsigned int ASTNode::getNumSemanticsAnnotations | ( | ) | const |
Returns the number of MathML <semantics>
element elements on this node.
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.
<semantics>
annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these annotations are still poorly understood. If you wish to use this construct, we urge you to discuss possible uses and applications on the SBML discussion lists, particularly sbml-discuss and/or sbml-interoperability.const char * ASTNode::getOperatorName | ( | ) | const |
Returns the value of this operator node as a string.
This function may be called on nodes that are operators, i.e., nodes for which isOperator() returns true
.
NULL
if not an operator). SBase * ASTNode::getParentSBMLObject | ( | ) | const |
Returns the parent SBML object.
int ASTNode::getPrecedence | ( | ) | const |
Returns 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 |
Returns the real-numbered value of this node.
This function performs the necessary arithmetic if the node type is AST_REAL_Eendif
ASTNode * ASTNode::getRightChild | ( | ) | const |
Returns the right child of this node.
NULL
if this node has no right child. If getNumChildren() > 1
, then this is equivalent to: getChild( getNumChildren() - 1 );
XMLNode * ASTNode::getSemanticsAnnotation | ( | unsigned int | n | ) | const |
Returns the nth MathML <semantics>
element on this ASTNode.
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.
n | the index of the annotation to return. Callers should use ASTNode::getNumSemanticsAnnotations() to first find out how many annotations there are. |
NULL
if this node has no nth annotation (n >
getNumSemanticsAnnotations() - 1
).<semantics>
annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these annotations are still poorly understood. If you wish to use this construct, we urge you to discuss possible uses and applications on the SBML discussion lists, particularly sbml-discuss and/or sbml-interoperability.std::string ASTNode::getStyle | ( | ) | const |
Returns the MathML style
attribute value of this ASTNode.
ASTNodeType_t ASTNode::getType | ( | ) | const |
Returns the type of this ASTNode.
The value returned is one of the Core AST type codes such as AST_LAMBDAendif
std::string ASTNode::getUnits | ( | ) | const |
Returns 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 |
Returns the numerical value of this ASTNode.
NaN
if this is not a type of node that has a numerical value.bool ASTNode::hasCorrectNumberArguments | ( | ) | const |
Returns true
if this ASTNode has the correct number of children for its type.
For example, an ASTNode with type AST_PLUSendif
int ASTNode::hasTypeAndNumChildren | ( | int | type, |
unsigned int | numchildren | ||
) | const |
Returns true
if this node is of a certain type with a specific 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.
type | the type of ASTNode sought. |
numchildren | the number of child nodes sought. |
true
if this ASTNode is has the specified type and number of children, false
otherwise. bool ASTNode::hasUnits | ( | ) | const |
Returns true
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 | ||
) |
|
virtual |
Returns true
if this node represents the predefined value for Avogadro's constant.
SBML Level 3 introduced a predefined MathML <csymbol>
for the value of Avogadro's constant. LibSBML stores this internally as a node of type AST_NAME_AVOGADROendif
|
virtual |
|
virtual |
Returns true
if this node represents a MathML constant.
Examples of MathML constants include such things as pi.
true
if this ASTNode is a MathML constant, false
otherwise.true
for nodes of type AST_NAME_AVOGADROendif
|
virtual |
Returns true
if this node represents a function.
The three types of functions in SBML are MathML functions (e.g., abs()
), SBML Level 1 functions (in the SBML Level 1 math syntax), and user-defined functions (using FunctionDefinition in SBML Level 2 and 3).
true
if this ASTNode is a function, false
otherwise. bool ASTNode::isInfinity | ( | ) | const |
Returns true
if this node represents the special IEEE 754 value for infinity.
true
if this ASTNode is the special IEEE 754 value infinity, false
otherwise.
|
virtual |
Returns true
if this node contains an integer value.
true
if this ASTNode is of type AST_INTEGERendif
|
virtual |
Returns true
if this node is a MathML <lambda>
.
true
if this ASTNode is of type AST_LAMBDAendif
|
virtual |
Returns true
if this node represents a log10
function.
More precisely, this predicate returns true
if the node type is AST_FUNCTION_LOGendif
|
virtual |
Returns true
if this node is a MathML logical operator.
The possible MathML logical operators are and
, or
, not
, and xor
.
true
if this ASTNode is a MathML logical operator, false
otherwise.
|
virtual |
Returns true
if this node is a user-defined variable name or the symbols for time or Avogadro's constant.
SBML Levels 2 and 3 provides <csymbol>
definitions for "time" and "avogadro", which can be used to represent simulation time and Avogadro's constant in MathML. Note that this method does not return true
for the other csymbol
values defined by SBML, "delay", because the "delay" is a function and not a constant or variable.
true
if this ASTNode is a user-defined variable name in SBML or the special symbols for time or Avogadro's constant. It returns false
otherwise. bool ASTNode::isNaN | ( | ) | const |
Returns true
if this node represents the special IEEE 754 value "not a number" (NaN).
true
if this ASTNode is the special IEEE 754 NaN, false
otherwise. bool ASTNode::isNegInfinity | ( | ) | const |
Returns true
if this node represents the special IEEE 754 value "negative infinity".
true
if this ASTNode is the special IEEE 754 value negative infinity, false
otherwise.
|
virtual |
Returns true
if this node contains a number.
true
if this ASTNode is a number, false
otherwise.
|
virtual |
Returns true
if this node is a mathematical operator.
The possible mathematical operators in the MathML syntax supported by SBML are +
, -
, *
, /
and ^
(power).
true
if this ASTNode is an operator, false
otherwise.
|
virtual |
Returns true
if this node is the MathML <piecewise>
construct.
true
if this ASTNode is a MathML piecewise
function, false
otherwise.
|
virtual |
Predicate returning true
if this node is a MathML qualifier.
The MathML qualifier node types are bvar
, degree
, base
, piece
, and otherwise
.
true
if this ASTNode is a MathML qualifier, false
otherwise.
|
virtual |
Returns true
if this node represents a rational number.
true
if this ASTNode is of type AST_RATIONALendif
|
virtual |
Returns true
if this node can represent a real number.
More precisely, this node must be of one of the following types: AST_REALendif
|
virtual |
Returns true
if this node is a MathML relational operator.
The MathML relational operators are ==
, >=
, >
, <
, and !=
.
true
if this ASTNode is a MathML relational operator, false
otherwise.
|
virtual |
Predicate returning true
if this node is a MathML semantics node.
true
if this ASTNode is a MathML semantics node, false
otherwise. bool ASTNode::isSetClass | ( | ) | const |
Returns true
if this node has a value for the MathML attribute class
.
false
otherwise.bool ASTNode::isSetId | ( | ) | const |
Returns true
if this node has a value for the MathML attribute id
.
false
otherwise.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
if this node has a value for the MathML attribute style
.
false
otherwise.bool ASTNode::isSetUnits | ( | ) | const |
Returns true
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
if this node represents a square root function.
More precisely, the node type must be AST_FUNCTION_ROOTendif
bool ASTNode::isUMinus | ( | ) | const |
Returns true
if this node is a unary minus operator.
A node is defined as a unary minus node if it is of type AST_MINUSendif
|
virtual |
Returns true
if this node has an unknown type.
"Unknown" nodes have the type AST_UNKNOWNendif
bool ASTNode::isUPlus | ( | ) | const |
Returns true
if this node is a unary plus operator.
A node is defined as a unary plus node if it is of type AST_PLUSendif
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 its child nodes.
oldid | the old identifier. |
newid | the new identifier. |
|
virtual |
Renames all the UnitSIdRef attributes on this node and its child nodes.
The only place UnitSIDRefs appear in MathML <cn>
elements, so the effects of this method are limited to that.
oldid | the old identifier. |
newid | the new identifier. |
void ASTNode::replaceArgument | ( | const std::string & | bvar, |
ASTNode * | arg | ||
) |
Replaces occurrences of a given name with a given ASTNode.
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 use as a replacement. |
int ASTNode::replaceChild | ( | unsigned int | n, |
ASTNode * | disownedChild, | ||
bool | delreplaced = false |
||
) |
bool ASTNode::returnsBoolean | ( | const Model * | model = NULL | ) | const |
Returns true
if this node returns a Boolean value.
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 to a user-defined function, the return value of the corresponding FunctionDefinition object 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.
model | the Model to use as context |
false
otherwise. 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 AST_UNKNOWNendif
int ASTNode::setClass | ( | const std::string & | className | ) |
Sets the MathML attribute class
of this ASTNode.
className | string representing the MathML class for this node. |
int ASTNode::setDefinitionURL | ( | XMLAttributes | url | ) |
Sets the MathML attribute definitionURL
.
url | the URL value for the definitionURL attribute. |
int ASTNode::setDefinitionURL | ( | const std::string & | url | ) |
Sets the MathML attribute definitionURL
.
url | the URL value for the definitionURL attribute. |
int ASTNode::setId | ( | const std::string & | id | ) |
Sets the MathML attribute id
of this ASTNode.
id | string representing the identifier. |
int ASTNode::setName | ( | const char * | name | ) |
Sets the value of this ASTNode to the given name.
As a side effect, this ASTNode object's type will be reset to AST_NAMEendif
int ASTNode::setParentSBMLObject | ( | SBase * | sb | ) |
Sets the parent SBML object.
sb | the parent SBML object of this ASTNode. |
int ASTNode::setStyle | ( | const std::string & | style | ) |
Sets the MathML attribute style
of this ASTNode.
style | string representing the identifier. |
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::setType | ( | int | type | ) |
Sets the type of this ASTNode.
This uses integer type codes, which may come from the enumeration ASTNodeType_t or an enumeration of AST types in an SBML Level 3 package.
type | the integer representing 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 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.
As a side effect, this operation sets the node type to AST_INTEGERendif
int ASTNode::setValue | ( | long | value | ) |
Sets the value of this ASTNode to the given (long
) integer.
As a side effect, this operation sets the node type to AST_INTEGERendif
int ASTNode::setValue | ( | long | numerator, |
long | denominator | ||
) |
Sets the value of this ASTNode to the given rational.
As a side effect, this operation sets the node type to AST_RATIONALendif
int ASTNode::setValue | ( | double | value | ) |
Sets the value of this ASTNode to the given real (double
).
As a side effect, this operation sets the node type to AST_REALendif
int ASTNode::setValue | ( | double | mantissa, |
long | exponent | ||
) |
Sets the value of this ASTNode to the given real (double
)
As a side effet, this operation sets the node type to AST_REAL_Eendif
int ASTNode::swapChildren | ( | ASTNode * | that | ) |
Swaps the children of this node with the children of another node.
that | the other node whose children should be used to replace this node's children. |
int ASTNode::unsetClass | ( | ) |
Unsets the MathML class
attribute of this ASTNode.
int ASTNode::unsetId | ( | ) |
Unsets the MathML id
attribute of this ASTNode.
int ASTNode::unsetParentSBMLObject | ( | ) |
Unsets the parent SBML object.
int ASTNode::unsetStyle | ( | ) |
Unsets the MathML style
attribute 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.
|
friend |