knowL: Knowledge Libraries
Loading...
Searching...
No Matches
knowCore::Unit Class Reference

#include <Unit.h>

Classes

struct  Private
 

Public Types

enum class  Prefix {
  Yotta , Zetta , Exa , Peta ,
  Tera , Giga , Mega , Kilo ,
  Hecto , Deca , Base , Deci ,
  Centi , Milli , Micro , Nano ,
  Pico , Femto , Atto , Zepto ,
  Yocto
}
 

Public Member Functions

 Unit (const Unit &_unit)
 
Unitoperator= (const Unit &_unit)
 
QString symbol () const
 
QString name () const
 
knowCore::Uri uri () const
 
Unit base () const
 
QList< UnitderivedUnits () const
 
bool operator== (const Unit &_unit) const
 
bool isValid () const
 
cres_qresult< Unitoperator/ (const Unit &_unit) const
 
cres_qresult< Unitoperator* (const Unit &_unit) const
 
qreal scale () const
 

Static Public Member Functions

static Unit empty ()
 
static QString prefixSymbol (Prefix p)
 
static QString prefixName (Prefix p)
 
static qreal prefixScale (Prefix p)
 
static QList< UnitbaseUnits ()
 
static cres_qresult< UnitbySymbol (const QString &_symbol)
 
static cres_qresult< UnitbyName (const QString &_name)
 
static cres_qresult< UnitbyUri (const knowCore::Uri &_symbol)
 

Friends

class UnitRegistration
 

Detailed Description

Define a Unit following the International System of Units and the http://www.w3.org/2007/ont/unit# ontology.

Member Function Documentation

◆ base()

Unit Unit::base ( ) const
Returns
if the base of the unit, i.e., for millimetre, return metre, for millimetre/second return metre/second

◆ baseUnits()

QList< Unit > Unit::baseUnits ( )
static
Returns
all base units

◆ byName()

cres_qresult< Unit > Unit::byName ( const QString & _name)
static
Returns
unit given a name

◆ bySymbol()

cres_qresult< Unit > Unit::bySymbol ( const QString & _symbol)
static
Returns
unit given a symbol

◆ byUri()

cres_qresult< Unit > Unit::byUri ( const knowCore::Uri & _symbol)
static
Returns
unit given a uri

◆ derivedUnits()

QList< Unit > Unit::derivedUnits ( ) const
Returns
all derived units

◆ isValid()

bool Unit::isValid ( ) const
Returns
true if valid

◆ name()

QString Unit::name ( ) const
Returns
the name of the unit (i.e. metre, second...)

◆ operator*()

cres_qresult< Unit > Unit::operator* ( const Unit & _unit) const
Returns
the unit obtained from multiplying two units, or an error if the unit does not exists

◆ operator/()

cres_qresult< Unit > Unit::operator/ ( const Unit & _unit) const
Returns
the unit obtained from dividing two units, or an error if the unit does not exists

◆ operator==()

bool Unit::operator== ( const Unit & _unit) const
Returns
true if two units are identical

◆ prefixName()

QString Unit::prefixName ( Prefix p)
static

The name corresponding to the prefix.

◆ prefixScale()

qreal Unit::prefixScale ( Prefix p)
static

The scale corresponding to the prefix.

◆ prefixSymbol()

QString Unit::prefixSymbol ( Prefix p)
static

The symbol corresponding to the prefix.

◆ scale()

qreal Unit::scale ( ) const
Returns
the scale of the unit in relation to the base, i.e. how much to multiply a value express in this unit to obtain the value in the base unit ( value in this is equal to scale * value in the base). For millimetre this will return 1e-3.

◆ symbol()

QString Unit::symbol ( ) const
Returns
the symbol that correspond to this unit (i.e. m, mm, m/s, mm^2, km^2...)

◆ uri()

knowCore::Uri Unit::uri ( ) const
Returns
the URI of this unit, either from the http://qudt.org/vocab/unit or from http://askco.re/unit# ontologies).

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