AliasUnit Class Reference

An unit with relation to another unit. More...

#include <Unit.h>

Inheritance diagram for AliasUnit:

Unit ExpressionItem AliasUnit_Composite

List of all members.

Public Member Functions

 AliasUnit (string cat_, string name_, string plural_, string singular_, string title_, Unit *alias, string relation="1", int exp=1, string inverse="", bool is_local=true, bool is_builtin=false, bool is_active=true)
 AliasUnit (const AliasUnit *unit)
virtual ExpressionItemcopy () const
virtual void set (const ExpressionItem *item)
virtual UnitbaseUnit () const
virtual UnitfirstBaseUnit () const
virtual void setBaseUnit (Unit *alias)
virtual string expression () const
virtual string inverseExpression () const
virtual void setExpression (string relation)
virtual void setInverseExpression (string inverse)
virtual MathStructureconvertToFirstBaseUnit (MathStructure &mvalue, MathStructure &mexp) const
virtual MathStructureconvertFromFirstBaseUnit (MathStructure &mvalue, MathStructure &mexp) const
virtual MathStructureconvertToBaseUnit (MathStructure &mvalue, MathStructure &mexp) const
virtual MathStructureconvertFromBaseUnit (MathStructure &mvalue, MathStructure &mexp) const
virtual MathStructureconvertToBaseUnit (MathStructure &mvalue) const
virtual MathStructureconvertFromBaseUnit (MathStructure &mvalue) const
virtual MathStructure convertToBaseUnit () const
virtual MathStructure convertFromBaseUnit () const
virtual int baseExponent (int exp=1) const
virtual void setExponent (int exp)
virtual int firstBaseExponent () const
virtual int subtype () const
virtual bool isChildOf (Unit *u) const
virtual bool isParentOf (Unit *u) const
virtual bool hasComplexExpression () const
virtual bool hasComplexRelationTo (Unit *u) const

Protected Attributes

string svalue
string sinverse
int i_exp
Unito_unit


Detailed Description

An unit with relation to another unit.

Alias units is defined in relation to another unit. For example, hour are defined as an alias unit that equals 60 minutes which in turn is defined in relation to seconds.

Alias units have an associated base unit, exponent and relation expression. For more complex relations an inverse relation can also be specified for conversion back from the base unit. The base unit must not necessarily be of the base unit class and it is recommended that an alias unit is defined in relation to the closest unit (ex. 1ft = 3 hands, 1 hand = 4 in, and 1 in = 0.0254 m).

The relation is usually just a number that tells how large quantity of the base unit is needed to get the alias unit (alias unit = base unit * relation). More complex units can specify the relation as a full-blown expression where '' is replaced by the quantity of the base unit and '' is the exponent. For example, Degrees Celsius has the relation "\x + 273.15" and the inverse relation "\x - 273.15" to the base unit Kelvin. For simple relations, the reversion is automatic and ought not be defined separately.

The precision property inherited from ExpressionItem defines the precision of the relation.

The exponent defines the exponential relation to the base unit, so that the alias unit equals the base unit raised to the exponent. For simple unit relations this gives: alias unit = relation * base unit^exponent.

Alias units normally have three different names defined for use in expressions - abbreviation (ex. "m"), singular ("meter") and plural ("meters").


Member Function Documentation

virtual void AliasUnit::setExpression ( string  relation  )  [virtual]

Sets the relation expression.

virtual void AliasUnit::setInverseExpression ( string  inverse  )  [virtual]

Sets the inverse relation expression.

virtual int AliasUnit::subtype (  )  const [virtual]

Returns the subtype of the unit, corresponding to which subsubclass the object belongs to.

Returns:
UnitSubtype.

Reimplemented from Unit.

virtual bool AliasUnit::isChildOf ( Unit u  )  const [virtual]

If specified unit is a base unit for this unit, directly or with other units in between. Equivalent to u->isParentOf(this).

Reimplemented from Unit.

virtual bool AliasUnit::isParentOf ( Unit u  )  const [virtual]

If this unit is a base unit for specified unit, directly or with other units in between. Equivalent to u->isChildOf(this).

Reimplemented from Unit.


The documentation for this class was generated from the following file:

Generated on Tue Jan 5 08:26:29 2010 for libqalculate-0.9.7 by  doxygen 1.5.5