UnitDefinition.cpp File Reference

Detailed Description

Implementations of SBML's UnitDefinition and ListOfUnitDefinitions.

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

Functions

UnitDefinition_t * ListOfUnitDefinitions_getById (ListOf_t *lo, const char *sid)
UnitDefinition_t * ListOfUnitDefinitions_removeById (ListOf_t *lo, const char *sid)
 Removes item in this ListOf items with the given id or NULL if no such item exists.
int UnitDefinition_addUnit (UnitDefinition_t *ud, const Unit_t *u)
 Adds a copy of the given Unit to the given UnitDefinition_t structure.
int UnitDefinition_areEquivalent (UnitDefinition_t *ud1, UnitDefinition_t *ud2)
int UnitDefinition_areIdentical (UnitDefinition_t *ud1, UnitDefinition_t *ud2)
UnitDefinition_t * UnitDefinition_clone (const UnitDefinition_t *ud)
 Creates and returns a deep copy of the given UnitDefinition_t structure.
UnitDefinition_t * UnitDefinition_combine (UnitDefinition_t *ud1, UnitDefinition_t *ud2)
UnitDefinition_t * UnitDefinition_convertToSI (UnitDefinition_t *ud)
UnitDefinition_t * UnitDefinition_create (unsigned int level, unsigned int version)
 Creates a new UnitDefinition_t structure using the given SBML level and version values.
Unit_t * UnitDefinition_createUnit (UnitDefinition_t *ud)
 Creates a new and empty Unit_t structure, adds it to the given UnitDefinition_t structure's list of units, and returns the Unit_t structure.
UnitDefinition_t * UnitDefinition_createWithNS (SBMLNamespaces_t *sbmlns)
 Creates a new UnitDefinition_t structure using the given SBMLNamespaces_t structure.
void UnitDefinition_free (UnitDefinition_t *ud)
 Frees the given UnitDefinition_t.
const char * UnitDefinition_getId (const UnitDefinition_t *ud)
 Returns the identifier of this UnitDefinition_t structure.
ListOf_t * UnitDefinition_getListOfUnits (UnitDefinition_t *ud)
 Returns the list of Units for the given UnitDefinition_t structure.
const char * UnitDefinition_getName (const UnitDefinition_t *ud)
 Returns the name of this UnitDefinition_t structure.
const XMLNamespaces_t * UnitDefinition_getNamespaces (UnitDefinition_t *ud)
 Returns a list of XMLNamespaces_t associated with this UnitDefinition_t structure.
unsigned int UnitDefinition_getNumUnits (const UnitDefinition_t *ud)
 Returns the number of Unit_t structures contained within this UnitDefinition_t.
Unit_t * UnitDefinition_getUnit (UnitDefinition_t *ud, unsigned int n)
 Returns a specific Unit_t instance belonging to the given UnitDefinition_t structure.
int UnitDefinition_isSetId (const UnitDefinition_t *ud)
 Predicate to test whether the "id" attribute of the given UnitDefinition_t ud is set.
int UnitDefinition_isSetName (const UnitDefinition_t *ud)
 Predicate to test whether the "name" attribute of the given UnitDefinition_t ud is set.
int UnitDefinition_isVariantOfArea (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "area".
int UnitDefinition_isVariantOfDimensionless (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the unit "dimensionless".
int UnitDefinition_isVariantOfLength (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "length".
int UnitDefinition_isVariantOfMass (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "mass".
int UnitDefinition_isVariantOfSubstance (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "substance".
int UnitDefinition_isVariantOfSubstancePerTime (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "substance" divided by the built-in unit "time".
int UnitDefinition_isVariantOfTime (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "time".
int UnitDefinition_isVariantOfVolume (const UnitDefinition_t *ud)
 Convenience function for testing if a given unit definition is a variant of the built-in unit "volume".
const char * UnitDefinition_printUnits (UnitDefinition_t *ud, int compact)
Unit_t * UnitDefinition_removeUnit (UnitDefinition_t *ud, unsigned int n)
 Removes the nth Unit_t object from this UnitDefinition_t object and returns a pointer to it.
void UnitDefinition_reorder (UnitDefinition_t *ud)
int UnitDefinition_setId (UnitDefinition_t *ud, const char *id)
 Sets the attribute "id" of the given UnitDefinition_t structure to a copy of the given string.
int UnitDefinition_setName (UnitDefinition_t *ud, const char *name)
 Sets the attribute "name" of the given UnitDefinition_t structure to a copy of the given string.
void UnitDefinition_simplify (UnitDefinition_t *ud)
int UnitDefinition_unsetName (UnitDefinition_t *ud)
 Unsets the name of the given UnitDefinition_t structure.

Function Documentation

UnitDefinition_t* ListOfUnitDefinitions_getById ( ListOf_t *  lo,
const char *  sid 
)
Returns:
item in this ListOfUnitDefinition with the given id or NULL if no such item exists.
UnitDefinition_t* ListOfUnitDefinitions_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.

int UnitDefinition_addUnit ( UnitDefinition_t *  ud,
const Unit_t *  u 
)

Adds a copy of the given Unit to the given UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t structure.
uthe Unit instance to add.
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_LEVEL_MISMATCH
  • LIBSBML_VERSION_MISMATCH
  • LIBSBML_DUPLICATE_OBJECT_ID
  • LIBSBML_OPERATION_FAILED
int UnitDefinition_areEquivalent ( UnitDefinition_t *  ud1,
UnitDefinition_t *  ud2 
)
int UnitDefinition_areIdentical ( UnitDefinition_t *  ud1,
UnitDefinition_t *  ud2 
)
UnitDefinition_t* UnitDefinition_clone ( const UnitDefinition_t *  ud)

Creates and returns a deep copy of the given UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t structure to copy
Returns:
a (deep) copy of UnitDefinition_t.
UnitDefinition_t* UnitDefinition_combine ( UnitDefinition_t *  ud1,
UnitDefinition_t *  ud2 
)
UnitDefinition_t* UnitDefinition_convertToSI ( UnitDefinition_t *  ud)
UnitDefinition_t* UnitDefinition_create ( unsigned int  level,
unsigned int  version 
)

Creates a new UnitDefinition_t structure using the given SBML level and version values.

Parameters:
levelan unsigned int, the SBML Level to assign to this UnitDefinition
versionan unsigned int, the SBML Version to assign to this UnitDefinition
Returns:
a pointer to the newly created UnitDefinition_t structure.
Note:
Once a UnitDefinition has been added to an SBMLDocument, the level and version for the document override those used to create the UnitDefinition. 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.
Unit_t* UnitDefinition_createUnit ( UnitDefinition_t *  ud)

Creates a new and empty Unit_t structure, adds it to the given UnitDefinition_t structure's list of units, and returns the Unit_t structure.

Returns:
a newly constructed (and empty) Unit_t structure.
Note:
It is worth emphasizing that the attribute "kind" value of a Unit_t is a required attribute for a valid Unit_t definition. The UnitDefinition_createUnit() method does not assign a valid kind to the constructed unit (instead, it sets the "kind" to UNIT_KIND_INVALID). Callers are cautioned to set the newly-constructed Unit's kind using UnitDefinition_setKind() soon after calling this method.
UnitDefinition_t* UnitDefinition_createWithNS ( SBMLNamespaces_t *  sbmlns)

Creates a new UnitDefinition_t structure using the given SBMLNamespaces_t structure.

Parameters:
sbmlnsSBMLNamespaces, a pointer to an SBMLNamespaces structure to assign to this UnitDefinition
Returns:
a pointer to the newly created UnitDefinition_t structure.
Note:
Once a UnitDefinition has been added to an SBMLDocument, the sbmlns namespaces for the document override those used to create the UnitDefinition. 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 UnitDefinition_free ( UnitDefinition_t *  ud)

Frees the given UnitDefinition_t.

const char* UnitDefinition_getId ( const UnitDefinition_t *  ud)

Returns the identifier of this UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t whose identifier is sought
Returns:
the value of the "id" attribute of this UnitDefinition_t.
ListOf_t* UnitDefinition_getListOfUnits ( UnitDefinition_t *  ud)

Returns the list of Units for the given UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t to use
Returns:
the ListOfUnits value for the given UnitDefinition_t.
const char* UnitDefinition_getName ( const UnitDefinition_t *  ud)

Returns the name of this UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t whose name is sought
Returns:
the value of the "name" attribute of this UnitDefinition_t.
const XMLNamespaces_t* UnitDefinition_getNamespaces ( UnitDefinition_t *  ud)

Returns a list of XMLNamespaces_t associated with this UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t structure
Returns:
pointer to the XMLNamespaces_t structure associated with this SBML object
unsigned int UnitDefinition_getNumUnits ( const UnitDefinition_t *  ud)

Returns the number of Unit_t structures contained within this UnitDefinition_t.

Parameters:
udthe UnitDefinition_t structure in question
Returns:
an integer representing the number of Unit_t structures in this UnitDefinition_t structure.
Unit_t* UnitDefinition_getUnit ( UnitDefinition_t *  ud,
unsigned int  n 
)

Returns a specific Unit_t instance belonging to the given UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t structure in question
nan integer, the index of the Unit_t structure to be returned.
Returns:
the nth Unit_t of this UnitDefinition_t structure.
See also:
UnitDefinition_getNumUnits()
int UnitDefinition_isSetId ( const UnitDefinition_t *  ud)

Predicate to test whether the "id" attribute of the given UnitDefinition_t ud is set.

Parameters:
udthe UnitDefinition_t to query.
Returns:
nonzero (true) if the "id" attribute of the given UnitDefinition_t is set, zero (0) otherwise.
int UnitDefinition_isSetName ( const UnitDefinition_t *  ud)

Predicate to test whether the "name" attribute of the given UnitDefinition_t ud is set.

Parameters:
udthe UnitDefinition_t to query.
Returns:
nonzero (true) if the "name" attribute of the given UnitDefinition_t is set, zero (0) otherwise.
int UnitDefinition_isVariantOfArea ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "area".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if the UnitDefinition_t structure ud is a variant of the built-in unit area, meaning square metres with only abritrary variations in scale or multiplier values; false otherwise.
int UnitDefinition_isVariantOfDimensionless ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the unit "dimensionless".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition is a variant of dimensionless, meaning dimensionless with only abritrary variations in scale or multiplier values; false otherwise.
int UnitDefinition_isVariantOfLength ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "length".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition_t is a variant of the built-in unit length, meaning metres with only abritrary variations in scale or multiplier values; false otherwise.
int UnitDefinition_isVariantOfMass ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "mass".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition is a variant of mass, meaning gram or kilogram with only abritrary variations in scale or multiplier values; false otherwise.
int UnitDefinition_isVariantOfSubstance ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "substance".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition is a variant of the built-in unit substance, meaning moles or items with only abritrary variations in scale or multiplier values; false otherwise.
int UnitDefinition_isVariantOfSubstancePerTime ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "substance" divided by the built-in unit "time".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition is a variant of the built-in unit substance per built-in unit time, meaning it contains two units one of which is a variant of substance and the other is a variant of time which an exponent of -1; false otherwise.
int UnitDefinition_isVariantOfTime ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "time".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition is a variant of the built-in unit time, meaning seconds with only abritrary variations in scale or multiplier values; false otherwise.
int UnitDefinition_isVariantOfVolume ( const UnitDefinition_t *  ud)

Convenience function for testing if a given unit definition is a variant of the built-in unit "volume".

Parameters:
udthe UnitDefinition_t to query.
Returns:
true if this UnitDefinition is a variant of the built-in unit volume, meaning litre or cubic metre with only abritrary variations in scale or multiplier values; false otherwise.
const char* UnitDefinition_printUnits ( UnitDefinition_t *  ud,
int  compact 
)
Unit_t* UnitDefinition_removeUnit ( UnitDefinition_t *  ud,
unsigned int  n 
)

Removes the nth Unit_t object from this UnitDefinition_t object and returns a pointer to it.

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

Parameters:
mthe UnitDefinition_t structure
nthe integer index of the Unit_t sought
Returns:
the Unit_t object removed. As mentioned above, the caller owns the returned item. NULL is returned if the given index is out of range.
void UnitDefinition_reorder ( UnitDefinition_t *  ud)
int UnitDefinition_setId ( UnitDefinition_t *  ud,
const char *  id 
)

Sets the attribute "id" of the given UnitDefinition_t structure to a copy of the given string.

Parameters:
udthe UnitDefinition_t structure whose id is to be set
ida string, the new identifier for the UnitDefinition_t structure
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
Note:
Using this function with an id of NULL is equivalent to unsetting the "id" attribute.
int UnitDefinition_setName ( UnitDefinition_t *  ud,
const char *  name 
)

Sets the attribute "name" of the given UnitDefinition_t structure to a copy of the given string.

Parameters:
udthe UnitDefinition_t structure whose name is to be set
namea string, the new name for the UnitDefinition_t structure
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
Note:
Using this function with the name set to NULL is equivalent to unsetting the "name" attribute.
void UnitDefinition_simplify ( UnitDefinition_t *  ud)
int UnitDefinition_unsetName ( UnitDefinition_t *  ud)

Unsets the name of the given UnitDefinition_t structure.

Parameters:
udthe UnitDefinition_t whose name is to be unset.
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