CellML API
cellml_services::CanonicalUnitRepresentation Interface Reference
The canonical representation of a units definition, as the product of powers of base units (perhaps with multiplicative factors, and optionally an offset if there is a single base unit). More...


Public Member Functions | |
BaseUnitInstance | fetchBaseUnit (in unsigned long index) raises (cellml_api::CellMLException) |
Fetches the nth base unit (0 for the first). | |
boolean | compatibleWith (in CanonicalUnitRepresentation aCompareWith) |
Compares one unit representation with another. | |
double | convertUnits (in CanonicalUnitRepresentation aConvertTo, out double offset) |
Computes the conversion needed if you have a value in the units of this object, and you want to convert it to another. | |
double | siConversion (out double offset) |
Computes the conversion needed to convert to the SI base units representation (i.e. | |
void | addBaseUnit (in BaseUnitInstance baseUnit) |
Adds a new base unit to the canonical unit representation. | |
CanonicalUnitRepresentation | mergeWith (in double thisExponent, in CanonicalUnitRepresentation other, in double otherExponent) raises (cellml_api::CellMLException) |
Merges this unit with another CanonicalUnitRepresentation, applying an exponent along the way. | |
![]() | |
void | add_ref () |
Called to indicate that some code is keeping an owning reference to the object. | |
oneway void | release_ref () |
Removes a reference to an object which was created by some other means (e.g. | |
IObject | query_interface (in utf8string id) |
Returns an IObject of the same implementation, which supports a specific interface. |
Public Attributes | |
readonly attribute unsigned long | length |
Returns the number of base unit instances. | |
![]() | |
readonly attribute string | objid |
Fetches the ID of the object. |
Detailed Description
The canonical representation of a units definition, as the product of powers of base units (perhaps with multiplicative factors, and optionally an offset if there is a single base unit).
Member Function Documentation
void cellml_services::CanonicalUnitRepresentation::addBaseUnit | ( | in BaseUnitInstance | baseUnit | ) |
Adds a new base unit to the canonical unit representation.
Under normal circumstances, CanonicalUnitRepresentations should be treated as immutable, but this is provided as an aid to code which wishes to create its own CanonicalUnitRepresentations for other purposes.
boolean cellml_services::CanonicalUnitRepresentation::compatibleWith | ( | in CanonicalUnitRepresentation | aCompareWith | ) |
Compares one unit representation with another.
Whether this checks for exact unit identity or dimensional equivalence depends on whether the CUSES object used to create this representation is strict or not.
- Parameters
-
aCompareWith the unit representation to compare with.
- Returns
- True if the units are equivalent.
double cellml_services::CanonicalUnitRepresentation::convertUnits | ( | in CanonicalUnitRepresentation | aConvertTo, |
out double | offset | ||
) |
Computes the conversion needed if you have a value in the units of this object, and you want to convert it to another.
If x is the value in the units of this object, and y is the desired value, the equation is: y = A * x + b.
- Parameters
-
convertTo The units representation to convert to. offset The value b in the equation above.
- Returns
- The multiplier, i.e. the value A in the equation above.
BaseUnitInstance cellml_services::CanonicalUnitRepresentation::fetchBaseUnit | ( | in unsigned long | index | ) | raises (cellml_api::CellMLException) |
Fetches the nth base unit (0 for the first).
The ordering is arbitrary, but fixed for a given CUSES instance.
- Parameters
-
index The index of the base unit.
- Returns
- The base unit instance at the specified index. CellMLException on error.
CanonicalUnitRepresentation cellml_services::CanonicalUnitRepresentation::mergeWith | ( | in double | thisExponent, |
in CanonicalUnitRepresentation | other, | ||
in double | otherExponent | ||
) | raises (cellml_api::CellMLException) |
Merges this unit with another CanonicalUnitRepresentation, applying an exponent along the way.
This performs the operations of the units algebra, and can be used to form products or quotients of units, or (by setting otherExponent to zero) to just raise this definition to the given exponent.
- Parameters
-
thisExponent The exponent to apply to this canonical unit representation. other The other canonical unit representation. This is ignored and may be null if otherExponent is zero. otherExponent The exponent to apply to the other canonical unit representation. CellMLException if other is null and otherExponent is non-zero.
double cellml_services::CanonicalUnitRepresentation::siConversion | ( | out double | offset | ) |
Computes the conversion needed to convert to the SI base units representation (i.e.
where the base units referenced are kg, m, etc. rather than, say, g, cm, etc.). The equation is: y = A * x + b Where y is the SI base units, and x is the current units. offset the value b in the equation above.
- Returns
- The multiplier, i.e. the value A in the equation above.