libqalculate-5.4.0
AliasUnit Class Reference

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

#include <Unit.h>

Inheritance diagram for AliasUnit:
Unit ExpressionItem AliasUnit_Composite

Public Member Functions

 AliasUnit (std::string cat_, std::string name_, std::string plural_, std::string singular_, std::string title_, Unit *alias, std::string relation="1", int exp=1, std::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 std::string expression () const
 
virtual std::string inverseExpression () const
 
virtual std::string uncertainty (bool *is_relative=NULL) const
 
virtual void setExpression (std::string relation)
 
virtual void setInverseExpression (std::string inverse)
 
virtual void setUncertainty (std::string standard_uncertainty, bool is_relative=false)
 
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 mixWithBase () const
 
virtual int mixWithBaseMinimum () const
 
virtual void setMixWithBase (int combine_priority=1)
 
virtual void setMixWithBaseMinimum (int combine_minimum)
 
virtual int subtype () const
 
virtual bool isChildOf (Unit *u) const
 
virtual bool isParentOf (Unit *u) const
 
virtual bool hasNonlinearExpression () const
 
virtual bool hasNonlinearRelationTo (Unit *u) const
 
virtual bool hasApproximateExpression (bool check_variables=false, bool ignore_high_precision_intervals=false) const
 
virtual bool hasApproximateRelationTo (Unit *u, bool check_variables=false, bool ignore_high_precision_intervals=false) const
 
virtual bool containsRelativeTo (Unit *u) const
 
virtual bool hasNonlinearRelationToBase () const
 
virtual bool hasApproximateRelationToBase (bool check_variables=false, bool ignore_high_precision_intervals=false) const
 
- Public Member Functions inherited from Unit
 Unit (std::string cat_, std::string name_, std::string plural_="", std::string singular_="", std::string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true)
 
 Unit (const Unit *unit)
 
bool isSIUnit () const
 
void setAsSIUnit ()
 
void setSystem (std::string s_system)
 
const std::string & system () const
 
bool useWithPrefixesByDefault () const
 
int maxPreferredPrefix () const
 
int minPreferredPrefix () const
 
int defaultPrefix () const
 
void setUseWithPrefixesByDefault (bool use_with_prefixes)
 
void setMaxPreferredPrefix (int exp)
 
void setMinPreferredPrefix (int exp)
 
void setDefaultPrefix (int exp)
 
bool isCurrency () const
 
const std::string & countries () const
 
void setCountries (std::string country_names)
 
virtual std::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 std::string print (const PrintOptions &po, bool format=false, int tagtype=0, bool input=false, bool plural=true) const
 
virtual const std::string & plural (bool return_singular_if_no_plural=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const std::string & singular (bool return_abbreviation_if_no_singular=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const std::string & abbreviation (bool return_singular_if_no_abbreviation=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual bool isUsedByOtherUnits () const
 
virtual int type () const
 
bool convert (Unit *u, MathStructure &mvalue, MathStructure &exp) const
 
bool convert (Unit *u, MathStructure &mvalue) const
 
MathStructure convert (Unit *u, bool *converted=NULL) const
 
- Public Member Functions inherited from ExpressionItem
 ExpressionItem (std::string cat_, std::string name_, std::string title_="", std::string descr_="", bool is_local=true, bool is_builtin=false, bool is_active=true)
 
virtual bool destroy ()
 
bool isRegistered () const
 
void setRegistered (bool is_registered)
 For internal use.
 
virtual const std::string & name (bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const std::string & referenceName () const
 
virtual const ExpressionNamepreferredName (bool abbreviation=false, bool use_unicode=false, bool plural=false, bool reference=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const ExpressionNamepreferredInputName (bool abbreviation=false, bool use_unicode=false, bool plural=false, bool reference=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const ExpressionNamepreferredDisplayName (bool abbreviation=false, bool use_unicode=false, bool plural=false, bool reference=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const ExpressionNamegetName (size_t index) const
 
virtual void setName (const ExpressionName &ename, size_t index=1, bool force=true)
 
virtual void setName (std::string sname, size_t index, bool force=true)
 
virtual void addName (const ExpressionName &ename, size_t index=0, bool force=true)
 
virtual void addName (std::string sname, size_t index=0, bool force=true)
 
virtual size_t countNames () const
 
virtual void clearNames ()
 
virtual void clearNonReferenceNames ()
 
virtual void removeName (size_t index)
 
virtual size_t hasName (const std::string &sname, bool case_sensitive=true) const
 
virtual size_t hasNameCaseSensitive (const std::string &sname) const
 
virtual const ExpressionNamefindName (int abbreviation=-1, int use_unicode=-1, int plural=-1, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual const std::string & title (bool return_name_if_no_title=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
 
virtual void setTitle (std::string title_)
 
virtual const std::string & description () const
 
virtual void setDescription (std::string descr_)
 
virtual const std::string & category () const
 
virtual void setCategory (std::string cat_)
 
virtual bool hasChanged () const
 
virtual void setChanged (bool has_changed)
 
virtual bool isLocal () const
 
virtual bool setLocal (bool is_local=true, int will_be_active=-1)
 
virtual bool isBuiltin () const
 
virtual bool isApproximate () const
 
virtual void setApproximate (bool is_approx=true)
 
virtual int precision () const
 
virtual void setPrecision (int prec)
 
virtual bool isActive () const
 
virtual void setActive (bool is_active)
 
virtual bool isHidden () const
 
virtual void setHidden (bool is_hidden)
 
virtual int refcount () const
 
virtual void ref ()
 
virtual void unref ()
 
virtual void ref (ExpressionItem *o)
 
virtual void unref (ExpressionItem *o)
 
virtual ExpressionItemgetReferencer (size_t index=1) const
 
virtual bool changeReference (ExpressionItem *o_from, ExpressionItem *o_to)
 
virtual int id () const
 

Protected Attributes

std::string svalue
 
std::string sinverse
 
std::string suncertainty
 
bool b_relative_uncertainty
 
int i_exp
 
int i_mix
 
int i_mix_min
 
Unito_unit
 
- Protected Attributes inherited from Unit
std::string ssystem
 
std::string scountries
 
bool b_si
 
unsigned short b_use_with_prefixes
 
- Protected Attributes inherited from ExpressionItem
std::string scat
 
std::string stitle
 
std::string sdescr
 
bool b_local
 
bool b_changed
 
bool b_builtin
 
bool b_approx
 
bool b_active
 
bool b_registered
 
bool b_hidden
 
bool b_destroyed
 
int i_ref
 
int i_precision
 
std::vector< ExpressionItem * > v_refs
 
std::vector< ExpressionNamenames
 

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 '\x' is replaced by the quantity of the base unit and '\y' 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

◆ baseExponent()

virtual int AliasUnit::baseExponent ( int exp = 1) const
virtual

Reimplemented from Unit.

◆ baseUnit()

virtual Unit * AliasUnit::baseUnit ( ) const
virtual

Reimplemented from Unit.

◆ containsRelativeTo()

virtual bool AliasUnit::containsRelativeTo ( Unit * u) const
virtual

Reimplemented from Unit.

◆ convertFromBaseUnit() [1/3]

virtual MathStructure AliasUnit::convertFromBaseUnit ( ) const
virtual

Reimplemented from Unit.

◆ convertFromBaseUnit() [2/3]

virtual MathStructure & AliasUnit::convertFromBaseUnit ( MathStructure & mvalue) const
virtual

Reimplemented from Unit.

◆ convertFromBaseUnit() [3/3]

virtual MathStructure & AliasUnit::convertFromBaseUnit ( MathStructure & mvalue,
MathStructure & mexp ) const
virtual

Reimplemented from Unit.

◆ convertToBaseUnit() [1/3]

virtual MathStructure AliasUnit::convertToBaseUnit ( ) const
virtual

Reimplemented from Unit.

◆ convertToBaseUnit() [2/3]

virtual MathStructure & AliasUnit::convertToBaseUnit ( MathStructure & mvalue) const
virtual

Reimplemented from Unit.

◆ convertToBaseUnit() [3/3]

virtual MathStructure & AliasUnit::convertToBaseUnit ( MathStructure & mvalue,
MathStructure & mexp ) const
virtual

Reimplemented from Unit.

◆ copy()

virtual ExpressionItem * AliasUnit::copy ( ) const
virtual

Reimplemented from Unit.

◆ hasApproximateRelationTo()

virtual bool AliasUnit::hasApproximateRelationTo ( Unit * u,
bool check_variables = false,
bool ignore_high_precision_intervals = false ) const
virtual

Reimplemented from Unit.

◆ hasApproximateRelationToBase()

virtual bool AliasUnit::hasApproximateRelationToBase ( bool check_variables = false,
bool ignore_high_precision_intervals = false ) const
virtual

Reimplemented from Unit.

◆ hasNonlinearRelationTo()

virtual bool AliasUnit::hasNonlinearRelationTo ( Unit * u) const
virtual

Reimplemented from Unit.

◆ hasNonlinearRelationToBase()

virtual bool AliasUnit::hasNonlinearRelationToBase ( ) const
virtual

Reimplemented from Unit.

◆ isChildOf()

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.

◆ isParentOf()

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.

◆ set()

virtual void AliasUnit::set ( const ExpressionItem * item)
virtual

Reimplemented from Unit.

◆ setExpression()

virtual void AliasUnit::setExpression ( std::string relation)
virtual

Sets the relation expression.

◆ setInverseExpression()

virtual void AliasUnit::setInverseExpression ( std::string inverse)
virtual

Sets the inverse relation expression.

◆ subtype()

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.


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