Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CompositeUnit Class Reference

A unit consisting of a number of other units. More...

#include <Unit.h>

Inheritance diagram for CompositeUnit:

Unit ExpressionItem List of all members.

Public Member Functions

 CompositeUnit (string cat_, string name_, string title_="", string base_expression_="", bool is_local=true, bool is_builtin=false, bool is_active=true)
 CompositeUnit (const CompositeUnit *unit)
virtual ExpressionItemcopy () const
virtual void set (const ExpressionItem *item)
virtual void add (Unit *u, int exp=1, Prefix *prefix=NULL)
virtual Unitget (size_t index, int *exp=NULL, Prefix **prefix=NULL) const
virtual void setExponent (size_t index, int exp)
virtual void setPrefix (size_t index, Prefix *prefix)
virtual size_t countUnits () const
virtual size_t find (Unit *u) const
virtual void del (size_t index)
virtual string print (bool plural_, bool short_, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
virtual int subtype () const
virtual bool containsRelativeTo (Unit *u) const
virtual MathStructure generateMathStructure (bool make_division=false) const
virtual void setBaseExpression (string base_expression_)
virtual void clear ()

Protected Attributes

string sshort
vector< AliasUnit_Composite * > units

Detailed Description

A unit consisting of a number of other units.

Composite units are defined by a unit expression with multiple units. Composite units often have an alias unit associated with them, as they do not have a reference name on their own. For example, a joule is defined as an alias defined in relation to a composite unit defined as "Newton * meter".

The names of composite units is only used to reference the unit in definitions of other units. They can not be used in expressions.

Composite units is definited as a composition of units. The units, with prefixes and exponents, can either be added one by one with add() or parsed from an expression (ex. "cm^3/g) with setBaseExpression().


Member Function Documentation

virtual void CompositeUnit::add Unit u,
int  exp = 1,
Prefix prefix = NULL
[virtual]
 

Adds a sub/base unit with specified exponent and an optional prefix.

Parameters:
u Unit.
exp Exponent.
prefix Prefix.

virtual void CompositeUnit::clear  )  [virtual]
 

Removes all sub/base units.

virtual bool CompositeUnit::containsRelativeTo Unit u  )  const [virtual]
 

If this unit contains a sub/base unit with a relation to the specified unit.

virtual size_t CompositeUnit::countUnits  )  const [virtual]
 

Returns the number of sub/base units

virtual MathStructure CompositeUnit::generateMathStructure bool  make_division = false  )  const [virtual]
 

Creates a MathStructure with the sub/base units of the unit.

virtual Unit* CompositeUnit::get size_t  index,
int *  exp = NULL,
Prefix **  prefix = NULL
const [virtual]
 

Retrieves information about a sub/base unit

Parameters:
index Index starting at 1.
[out] exp Exponent.
[out] prefix Prefix.
Returns:
Sub/base unit (AliasUnit_Composite::firstBaseUnit()).

virtual string CompositeUnit::print bool  plural_,
bool  short_,
bool  use_unicode = false,
bool(*)(const char *, void *)  can_display_unicode_string_function = NULL,
void *  can_display_unicode_string_arg = NULL
const [virtual]
 

Prints out the sub/base units with prefixes and exponents. This is the representation of the unit in expressions.

Reimplemented from Unit.

virtual int CompositeUnit::subtype  )  const [virtual]
 

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

Returns:
UnitSubtype.

Reimplemented from Unit.


The documentation for this class was generated from the following file:
Generated on 17 Jun 2007 for libqalculate-0.9.6 by doxygen 1.4.3