Rule.cpp File Reference

Detailed Description

Implementations of Rule, ListOfRules, AlgebraicRule, AssignmentRule and RateRule.

Author:
Ben Bornstein
Include dependency graph for Rule.cpp:

Functions

Rule_t * ListOfRules_getById (ListOf_t *lo, const char *sid)
Rule_t * ListOfRules_removeById (ListOf_t *lo, const char *sid)
 Removes item in this ListOf items with the given id or NULL if no such item exists.
Rule_t * Rule_clone (const Rule_t *r)
int Rule_containsUndeclaredUnits (Rule_t *r)
 Predicate returning true or false depending on whether the math expression of this Rule_t contains parameters/numbers with undeclared units.
Rule_t * Rule_createAlgebraic (unsigned int level, unsigned int version)
 Creates a new AlgebraicRule (Rule_t) structure using the given SBML level and version values.
Rule_t * Rule_createAlgebraicWithNS (SBMLNamespaces_t *sbmlns)
 Creates a new AlgebraicRule (Rule_t) structure using the given SBMLNamespaces_t structure.
Rule_t * Rule_createAssignment (unsigned int level, unsigned int version)
 Creates a new AssignmentRule (Rule_t) structure using the given SBML level and version values.
Rule_t * Rule_createAssignmentWithNS (SBMLNamespaces_t *sbmlns)
 Creates a new AssignmentRule (Rule_t) structure using the given SBMLNamespaces_t structure.
Rule_t * Rule_createRate (unsigned int level, unsigned int version)
 Creates a new RateRule (Rule_t) structure using the given SBML level and version values.
Rule_t * Rule_createRateWithNS (SBMLNamespaces_t *sbmlns)
 Creates a new RateRule (Rule_t) structure using the given SBMLNamespaces_t structure.
void Rule_free (Rule_t *r)
 Destroys this Rule.
UnitDefinition_t * Rule_getDerivedUnitDefinition (Rule_t *r)
 Calculates and returns a UnitDefinition_t that expresses the units returned by the math expression of this Rule_t.
const char * Rule_getFormula (const Rule_t *r)
int Rule_getL1TypeCode (const Rule_t *r)
const ASTNode_t * Rule_getMath (const Rule_t *r)
const XMLNamespaces_t * Rule_getNamespaces (Rule_t *r)
 Returns a list of XMLNamespaces_t associated with this Rule_t structure.
RuleType_t Rule_getType (const Rule_t *r)
int Rule_getTypeCode (const Rule_t *r)
const char * Rule_getUnits (const Rule_t *r)
const char * Rule_getVariable (const Rule_t *r)
int Rule_isAlgebraic (const Rule_t *r)
int Rule_isAssignment (const Rule_t *r)
int Rule_isCompartmentVolume (const Rule_t *r)
 This method attempts to lookup the Rule's variable in the Model's list of Compartments.
int Rule_isParameter (const Rule_t *r)
 This method attempts to lookup the Rule's variable in the Model's list of Parameters.
int Rule_isRate (const Rule_t *r)
int Rule_isScalar (const Rule_t *r)
int Rule_isSetFormula (const Rule_t *r)
int Rule_isSetMath (const Rule_t *r)
int Rule_isSetUnits (const Rule_t *r)
int Rule_isSetVariable (const Rule_t *r)
int Rule_isSpeciesConcentration (const Rule_t *r)
 This method attempts to lookup the Rule's variable in the Model's list of Species.
int Rule_setFormula (Rule_t *r, const char *formula)
 Sets the formula of this Rule to a copy of string.
int Rule_setL1TypeCode (Rule_t *r, int L1Type)
 Sets the SBML Level 1 typecode for this Rule.
int Rule_setMath (Rule_t *r, const ASTNode_t *math)
 Sets the math of this Rule to a copy of the given ASTNode.
int Rule_setUnits (Rule_t *r, const char *sname)
 Sets the units for this Rule to a copy of sname (L1 ParameterRules only).
int Rule_setVariable (Rule_t *r, const char *sid)
 Sets the variable of this RateRule to a copy of sid.
int Rule_unsetUnits (Rule_t *r)
 Unsets the units for this Rule (L1 ParameterRules only).

Function Documentation

Rule_t* ListOfRules_getById ( ListOf_t *  lo,
const char *  sid 
)
Returns:
item in this ListOfRule with the given id or NULL if no such item exists.
Rule_t* ListOfRules_removeById ( ListOf_t *  lo,
const char *  sid 
)

Removes item in this ListOf items with the given id or NULL if no such item exists.

The caller owns the returned item and is responsible for deleting it.

Rule_t* Rule_clone ( const Rule_t *  r)
Returns:
a (deep) copy of this Rule.
int Rule_containsUndeclaredUnits ( Rule_t *  r)

Predicate returning true or false depending on whether the math expression of this Rule_t contains parameters/numbers with undeclared units.

Returns:
true if the math expression of this Rule_t includes parameters/numbers with undeclared units, false otherwise.
Note:
a return value of true indicates that the UnitDefinition_t returned by the getDerivedUnitDefinition function may not accurately represent the units of the expression.
See also:
Rule_getDerivedUnitDefinition()
Rule_t* Rule_createAlgebraic ( unsigned int  level,
unsigned int  version 
)

Creates a new AlgebraicRule (Rule_t) structure using the given SBML level and version values.

Parameters:
levelan unsigned int, the SBML Level to assign to this AlgebraicRule
versionan unsigned int, the SBML Version to assign to this AlgebraicRule
Returns:
a pointer to the newly created Rule_t structure.
Note:
Once a AlgebraicRule has been added to an SBMLDocument, the level and version for the document override those used to create the AlgebraicRule. Despite this, the ability to supply the values at creation time is an important aid to creating valid SBML. Knowledge of the intended SBML Level and Version determine whether it is valid to assign a particular value to an attribute, or whether it is valid to add an object to an existing SBMLDocument.
Rule_t* Rule_createAlgebraicWithNS ( SBMLNamespaces_t *  sbmlns)

Creates a new AlgebraicRule (Rule_t) structure using the given SBMLNamespaces_t structure.

Parameters:
sbmlnsSBMLNamespaces, a pointer to an SBMLNamespaces structure to assign to this AlgebraicRule
Returns:
a pointer to the newly created Rule_t structure.
Note:
Once a AlgebraicRule has been added to an SBMLDocument, the sbmlns namespaces for the document override those used to create the AlgebraicRule. Despite this, the ability to supply the values at creation time is an important aid to creating valid SBML. Knowledge of the intended SBML Level and Version determine whether it is valid to assign a particular value to an attribute, or whether it is valid to add an object to an existing SBMLDocument.
Rule_t* Rule_createAssignment ( unsigned int  level,
unsigned int  version 
)

Creates a new AssignmentRule (Rule_t) structure using the given SBML level and version values.

Parameters:
levelan unsigned int, the SBML Level to assign to this AssignmentRule
versionan unsigned int, the SBML Version to assign to this AssignmentRule
Returns:
a pointer to the newly created Rule_t structure.
Note:
Once a AssignmentRule has been added to an SBMLDocument, the level and version for the document override those used to create the AssignmentRule. Despite this, the ability to supply the values at creation time is an important aid to creating valid SBML. Knowledge of the intended SBML Level and Version determine whether it is valid to assign a particular value to an attribute, or whether it is valid to add an object to an existing SBMLDocument.
Rule_t* Rule_createAssignmentWithNS ( SBMLNamespaces_t *  sbmlns)

Creates a new AssignmentRule (Rule_t) structure using the given SBMLNamespaces_t structure.

Parameters:
sbmlnsSBMLNamespaces, a pointer to an SBMLNamespaces structure to assign to this AssignmentRule
Returns:
a pointer to the newly created Rule_t structure.
Note:
Once a AssignmentRule has been added to an SBMLDocument, the sbmlns namespaces for the document override those used to create the AssignmentRule. Despite this, the ability to supply the values at creation time is an important aid to creating valid SBML. Knowledge of the intended SBML Level and Version determine whether it is valid to assign a particular value to an attribute, or whether it is valid to add an object to an existing SBMLDocument.
Rule_t* Rule_createRate ( unsigned int  level,
unsigned int  version 
)

Creates a new RateRule (Rule_t) structure using the given SBML level and version values.

Parameters:
levelan unsigned int, the SBML Level to assign to this RateRule
versionan unsigned int, the SBML Version to assign to this RateRule
Returns:
a pointer to the newly created Rule_t structure.
Note:
Once a RateRule has been added to an SBMLDocument, the level and version for the document override those used to create the RateRule. Despite this, the ability to supply the values at creation time is an important aid to creating valid SBML. Knowledge of the intended SBML Level and Version determine whether it is valid to assign a particular value to an attribute, or whether it is valid to add an object to an existing SBMLDocument.
Rule_t* Rule_createRateWithNS ( SBMLNamespaces_t *  sbmlns)

Creates a new RateRule (Rule_t) structure using the given SBMLNamespaces_t structure.

Parameters:
sbmlnsSBMLNamespaces, a pointer to an SBMLNamespaces structure to assign to this RateRule
Returns:
a pointer to the newly created Rule_t structure.
Note:
Once a RateRule has been added to an SBMLDocument, the sbmlns namespaces for the document override those used to create the RateRule. Despite this, the ability to supply the values at creation time is an important aid to creating valid SBML. Knowledge of the intended SBML Level and Version determine whether it is valid to assign a particular value to an attribute, or whether it is valid to add an object to an existing SBMLDocument.
void Rule_free ( Rule_t *  r)

Destroys this Rule.

UnitDefinition_t* Rule_getDerivedUnitDefinition ( Rule_t *  r)

Calculates and returns a UnitDefinition_t that expresses the units returned by the math expression of this Rule_t.

Returns:
a UnitDefinition_t that expresses the units of the math expression of this Rule_t.

Note that the functionality that facilitates unit analysis depends on the model as a whole. Thus, in cases where the object has not been added to a model or the model itself is incomplete, unit analysis is not possible and this method will return NULL.

Note:
The units are calculated by applying the mathematics from the expression to the units of the <ci> elements used within the expression. Where there are parameters/numbers with undeclared units the UnitDefinition_t returned by this function may not accurately represent the units of the expression.
See also:
Rule_containsUndeclaredUnits()
const char* Rule_getFormula ( const Rule_t *  r)
Note:
SBML Level 1 uses a text-string format for mathematical formulas. SBML Level 2 uses MathML, an XML format for representing mathematical expressions. LibSBML provides an Abstract Syntax Tree API for working with mathematical expressions; this API is more powerful than working with formulas directly in text form, and ASTs can be translated into either MathML or the text-string syntax. The libSBML methods that accept text-string formulas directly (such as this one) are provided for SBML Level 1 compatibility, but developers are encouraged to use the AST mechanisms.
Returns:
the formula for this Rule.
int Rule_getL1TypeCode ( const Rule_t *  r)
Returns:
the SBML Level 1 typecode for this Rule or SBML_UNKNOWN (default).
const ASTNode_t* Rule_getMath ( const Rule_t *  r)
Returns:
the math for this Rule.
const XMLNamespaces_t* Rule_getNamespaces ( Rule_t *  r)

Returns a list of XMLNamespaces_t associated with this Rule_t structure.

Parameters:
rthe Rule_t structure
Returns:
pointer to the XMLNamespaces_t structure associated with this SBML object
RuleType_t Rule_getType ( const Rule_t *  r)
Returns:
the type of this Rule, either RULE_TYPE_RATE or RULE_TYPE_SCALAR.
int Rule_getTypeCode ( const Rule_t *  r)
Returns:
the typecode (int) of SBML objects contained in this ListOf or (default).
const char* Rule_getUnits ( const Rule_t *  r)
Returns:
the units for this Rule (L1 ParameterRules only).
const char* Rule_getVariable ( const Rule_t *  r)
Returns:
the variable for this Rule.
int Rule_isAlgebraic ( const Rule_t *  r)
Returns:
true (non-zero) if this Rule is an AlgebraicRule, false (0) otherwise.
int Rule_isAssignment ( const Rule_t *  r)
Returns:
true (non-zero) if this Rule is an AssignmentRule, false (0) otherwise.
int Rule_isCompartmentVolume ( const Rule_t *  r)

This method attempts to lookup the Rule's variable in the Model's list of Compartments.

Returns:
true (non-zero) if this Rule is a CompartmentVolumeRule, false (0) otherwise.
int Rule_isParameter ( const Rule_t *  r)

This method attempts to lookup the Rule's variable in the Model's list of Parameters.

Returns:
true (non-zero) if this Rule is a ParameterRule, false (0) otherwise.
int Rule_isRate ( const Rule_t *  r)
Returns:
true (non-zero) if this Rule is a RateRule (L2) or has type="rate" (L1), false (0) otherwise.
int Rule_isScalar ( const Rule_t *  r)
Returns:
true (non-zero) if this Rule is an AssignmentRule (L2) has type="scalar" (L1), false (0) otherwise.
int Rule_isSetFormula ( const Rule_t *  r)
Note:
SBML Level 1 uses a text-string format for mathematical formulas. SBML Level 2 uses MathML, an XML format for representing mathematical expressions. LibSBML provides an Abstract Syntax Tree API for working with mathematical expressions; this API is more powerful than working with formulas directly in text form, and ASTs can be translated into either MathML or the text-string syntax. The libSBML methods that accept text-string formulas directly (such as this one) are provided for SBML Level 1 compatibility, but developers are encouraged to use the AST mechanisms.
Returns:
true (non-zero) if the formula (or equivalently the math) for this Rule is set, false (0) otherwise.
int Rule_isSetMath ( const Rule_t *  r)
Returns:
true (non-zero) if the math (or equivalently the formula) for this Rule is set, false (0) otherwise.
int Rule_isSetUnits ( const Rule_t *  r)
Returns:
true (non-zero) if the units for this Rule is set, false (0) otherwise (L1 ParameterRules only).
int Rule_isSetVariable ( const Rule_t *  r)
Returns:
true (non-zero) if the variable of this Rule is set, false (0) otherwise.
int Rule_isSpeciesConcentration ( const Rule_t *  r)

This method attempts to lookup the Rule's variable in the Model's list of Species.

Returns:
true (non-zero) if this Rule is a SpeciesConcentrationRule, false (0) otherwise.
int Rule_setFormula ( Rule_t *  r,
const char *  formula 
)

Sets the formula of this Rule to a copy of string.

Returns:
integer value indicating success/failure of the function. The value is drawn from the enumeration #OperationReturnValues_t.The possible values returned by this function are:
  • LIBSBML_OPERATION_SUCCESS
  • LIBSBML_INVALID_OBJECT
Note:
SBML Level 1 uses a text-string format for mathematical formulas. SBML Level 2 uses MathML, an XML format for representing mathematical expressions. LibSBML provides an Abstract Syntax Tree API for working with mathematical expressions; this API is more powerful than working with formulas directly in text form, and ASTs can be translated into either MathML or the text-string syntax. The libSBML methods that accept text-string formulas directly (such as this one) are provided for SBML Level 1 compatibility, but developers are encouraged to use the AST mechanisms.
int Rule_setL1TypeCode ( Rule_t *  r,
int  L1Type 
)

Sets the SBML Level 1 typecode for this Rule.

Parameters:
rthe Rule_t structure
typethe SBML Level 1 typecode for this Rule (SBML_COMPARTMENT_VOLUME_RULE, SBML_PARAMETER_RULE, or SBML_SPECIES_CONCENTRATION_RULE).
Returns:
integer value indicating success/failure of the function. The value is drawn from the enumeration #OperationReturnValues_t.The possible values returned by this function are:
  • LIBSBML_OPERATION_SUCCESS
  • LIBSBML_INVALID_ATTRIBUTE_VALUE
int Rule_setMath ( Rule_t *  r,
const ASTNode_t *  math 
)

Sets the math of this Rule to a copy of the given ASTNode.

Returns:
integer value indicating success/failure of the function. The value is drawn from the enumeration #OperationReturnValues_t.The possible values returned by this function are:
  • LIBSBML_OPERATION_SUCCESS
  • LIBSBML_INVALID_OBJECT
int Rule_setUnits ( Rule_t *  r,
const char *  sname 
)

Sets the units for this Rule to a copy of sname (L1 ParameterRules only).

Returns:
integer value indicating success/failure of the function. The value is drawn from the enumeration #OperationReturnValues_t.The possible values returned by this function are:
  • LIBSBML_OPERATION_SUCCESS
  • LIBSBML_INVALID_ATTRIBUTE_VALUE
  • LIBSBML_UNEXPECTED_ATTRIBUTE
Note:
Using this function with an id of NULL is equivalent to unsetting the "units" attribute.
int Rule_setVariable ( Rule_t *  r,
const char *  sid 
)

Sets the variable of this RateRule to a copy of sid.

Returns:
integer value indicating success/failure of the function. The value is drawn from the enumeration #OperationReturnValues_t.The possible values returned by this function are:
  • LIBSBML_OPERATION_SUCCESS
  • LIBSBML_INVALID_ATTRIBUTE_VALUE
  • LIBSBML_UNEXPECTED_ATTRIBUTE
Note:
Using this function with an id of NULL is equivalent to unsetting the "variable" attribute.
int Rule_unsetUnits ( Rule_t *  r)

Unsets the units for this Rule (L1 ParameterRules only).

Returns:
integer value indicating success/failure of the function. The value is drawn from the enumeration #OperationReturnValues_t.The possible values returned by this function are:
  • LIBSBML_OPERATION_SUCCESS
  • LIBSBML_OPERATION_FAILED
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines