#include <Unit.h>
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 ExpressionItem * | copy () const |
virtual void | set (const ExpressionItem *item) |
virtual void | add (Unit *u, int exp=1, Prefix *prefix=NULL) |
virtual Unit * | get (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 |
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().
virtual Unit* CompositeUnit::get | ( | size_t | index, | |
int * | exp = NULL , |
|||
Prefix ** | prefix = NULL | |||
) | const [virtual] |
Retrieves information about a sub/base unit
index | Index starting at 1. | |
[out] | exp | Exponent. |
[out] | prefix | Prefix. |
virtual size_t CompositeUnit::countUnits | ( | ) | const [virtual] |
Returns the number of sub/base units
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.
Reimplemented from Unit.
virtual bool CompositeUnit::containsRelativeTo | ( | Unit * | u | ) | const [virtual] |
If this unit contains a sub/base unit with a relation to the specified unit.
virtual MathStructure CompositeUnit::generateMathStructure | ( | bool | make_division = false |
) | const [virtual] |
Creates a MathStructure with the sub/base units of the unit.
virtual void CompositeUnit::clear | ( | ) | [virtual] |
Removes all sub/base units.