OpenStudioCore:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Related Functions | List of all members
openstudio::SIUnit Class Reference

#include <SIUnit.hpp>

+ Inheritance diagram for openstudio::SIUnit:

Public Member Functions

Constructors and Destructors
 SIUnit (const SIExpnt &exponents=SIExpnt(), int scaleExponent=0, const std::string &prettyString="")
 Default constructor. More...
 
 SIUnit (const std::string &scaleAbbreviation, const SIExpnt &exponents=SIExpnt(), const std::string &prettyString="")
 Alternate constructor. More...
 
virtual ~SIUnit ()
 
- Public Member Functions inherited from openstudio::Unit
 Unit (int scaleExponent=0, const std::string &prettyString="")
 Default constructor. More...
 
 Unit (const std::string &scaleAbbreviation, const std::string &prettyString="")
 Constructor using scale abbreviations registered in ScaleFactory. More...
 
virtual ~Unit ()
 
Unit clone () const
 Deep copy constructor. More...
 
Unit cloneToMixed () const
 Deep copy constructor that discards system designation. More...
 
std::vector< std::string > baseUnits () const
 Returns base units already available in Unit. More...
 
bool isBaseUnit (const std::string &baseUnit) const
 Returns true if baseUnit is available in Unit. More...
 
int baseUnitExponent (const std::string &baseUnit) const
 Base unit exponent getter. Returns 0 if baseUnit not present. */. More...
 
void setBaseUnitExponent (const std::string &baseUnit, int exponent)
 Sets baseUnit^exponent. If baseUnit not yet present, is added and return value is true. More...
 
Scale scale () const
 Scale getter. More...
 
bool setScale (int scaleExponent)
 Sets the scale to the one registered in ScaleFactory for 10^scaleExponent. More...
 
bool setScale (const std::string &scaleAbbreviation)
 Sets the scale to the one registered in ScaleFactory under scaleAbbreviation. More...
 
std::string standardString (bool withScale=true) const
 Returns the standard output string for this unit. More...
 
std::string prettyString (bool withScale=true) const
 Returns the preferred output string for this unit. More...
 
void setPrettyString (const std::string &str)
 Setter for prettyString (do not include scale abbreviation). More...
 
std::string print (bool withScale=true) const
 Returns prettyString(withScale) if it exists; otherwise returns standardString(withScale). More...
 
UnitSystem system () const
 Getter for this Unit's system. More...
 
bool operator== (const Unit &rUnit) const
 Equality for units. More...
 
Unitoperator*= (const Unit &rUnit)
 Multiply-assign operator. More...
 
Unitoperator/= (const Unit &rUnit)
 Divide-assign operator. More...
 
Unitpow (int expNum, int expDenom=1, bool okToCallFactory=true)
 Raise Unit to a rational power. More...
 
template<typename T >
cast () const
 Cast to type T. More...
 
template<typename T >
boost::optional< T > optionalCast () const
 Cast to boost::optional<T>. More...
 

Related Functions

(Note that these are not member functions.)

typedef boost::optional< SIUnitOptionalSIUnit
 
typedef std::vector< SIUnitSIUnitVector
 
Create Functions Used by UnitFactory
SIUnit createSIMass ()
 
SIUnit createSILength ()
 
SIUnit createSITime ()
 
SIUnit createSITemperature ()
 
SIUnit createSIElectricCurrent ()
 
SIUnit createSILuminousIntensity ()
 
SIUnit createSIAmountOfSubstance ()
 
SIUnit createSIAngle ()
 
SIUnit createSISolidAngle ()
 
SIUnit createSIPeople ()
 
SIUnit createSICycle ()
 
SIUnit createSICurrency ()
 
SIUnit createSIForce ()
 Newton (N) = kg*m/s^2. More...
 
SIUnit createSIEnergy ()
 Joule (J) = N*m = kg*m^2/s^2. More...
 
SIUnit createSIPower ()
 Watt (W) = J/s = N*m/s = kg*m^2/s^3. More...
 
SIUnit createSIElectricCharge ()
 Coulomb (C) = s*A. More...
 
SIUnit createSIElectricalPotential ()
 Volt (V) = W/A = J/C = kg*m^2/s^3*A. More...
 
SIUnit createSIElectricCapacitance ()
 Farad (F) = C/V = C^2/J = s^4*A^2/kg*m^2. More...
 
SIUnit createSIElectricResistance ()
 Ohm (ohm) = V/A = W/A^2 = kg*m^2/s^3*A^2. More...
 
SIUnit createSIMagneticFlux ()
 Weber (Wb) = J/A = kg*m^2/s^2*A. More...
 
SIUnit createSIMagneticFieldStrength ()
 Tesla (T) = Wb/m^2 = J/m^2*A = kg/s^2*A. More...
 
SIUnit createSIInductance ()
 Henry (H) = Wb/A = s*V/A = kg*m^2/s^2*A^2. More...
 
SIUnit createSILuminousFlux ()
 Lumen (lm) = cd*sr. More...
 
SIUnit createSIIlluminance ()
 Lux (lux or lx) = lm/m^2 = cd*sr/m^2. More...
 
SIUnit createSIFrequency ()
 Hertz (Hz) = cycles/s. More...
 
SIUnit createSIEnergyUseIntensity ()
 J/m^2 = kg/s^2. More...
 
SIUnit createSIPowerDensity ()
 W/m^2 = kg/s^3. More...
 
SIUnit createSIPowerPerPerson ()
 W/person = kg*m^2/s^3*person. More...
 
SIUnit createSIPressure ()
 Pa = N/m^2 = kg/m*s^2. More...
 
SIUnit createSIThermalConductance ()
 W/m^2*K = kg/s^3*K. More...
 
SIUnit createSIThermalResistance ()
 m^2*K/W = s^3*K/kg More...
 
SIUnit createSIHeatCapacity ()
 J/m^2*K = kg/s^2*K. More...
 

Detailed Description

SIUnit is a Unit with baseUnits are fixed by its constructors, see SIExpnt.

setBaseUnitExponent throws an exception if any other string is passed in as a baseUnit. SIUnit.hpp declares related operators and UnitFactory callback functions.

Constructor & Destructor Documentation

openstudio::SIUnit::SIUnit ( const SIExpnt exponents = SIExpnt(),
int  scaleExponent = 0,
const std::string &  prettyString = "" 
)

Default constructor.

Example:

SIUnit myEnergy(SIExpnt(1,2,-2),3,"J");
std::cout << myEnergy; // produces "kJ" 
Parameters
[in]exponentsholds the exponents for each base unit.
[in]scaleExponentexponent for scale. For instance 3 for kilo.
[in]prettyStringoptional string to use in place of standardString.
openstudio::SIUnit::SIUnit ( const std::string &  scaleAbbreviation,
const SIExpnt exponents = SIExpnt(),
const std::string &  prettyString = "" 
)

Alternate constructor.

Specify the abbreviation of the scale, rather than its exponent. Example:

SIUnit myEnergy("k",SIExpnt(1,2,-2),"J");
std::cout << myEnergy; // produces "kJ 
Parameters
[in]scaleAbbreviationis string equal to a scale abbreviation. For instance "k" for kilo.
[in]exponentsholds the exponents for each base unit.
[in]prettyStringoptional string to use in place of standardString.
virtual openstudio::SIUnit::~SIUnit ( )
inlinevirtual

Friends And Related Function Documentation

SIUnit createSIAmountOfSubstance ( )
related
SIUnit createSIAngle ( )
related
SIUnit createSICurrency ( )
related
SIUnit createSICycle ( )
related
SIUnit createSIElectricalPotential ( )
related

Volt (V) = W/A = J/C = kg*m^2/s^3*A.

SIUnit createSIElectricCapacitance ( )
related

Farad (F) = C/V = C^2/J = s^4*A^2/kg*m^2.

SIUnit createSIElectricCharge ( )
related

Coulomb (C) = s*A.

SIUnit createSIElectricCurrent ( )
related
SIUnit createSIElectricResistance ( )
related

Ohm (ohm) = V/A = W/A^2 = kg*m^2/s^3*A^2.

SIUnit createSIEnergy ( )
related

Joule (J) = N*m = kg*m^2/s^2.

SIUnit createSIEnergyUseIntensity ( )
related

J/m^2 = kg/s^2.

That this is measured on an annual basis is implied.

SIUnit createSIForce ( )
related

Newton (N) = kg*m/s^2.

SIUnit createSIFrequency ( )
related

Hertz (Hz) = cycles/s.

Making the distinction between 1/s and cycles/s here mainly to be consistent with the rotations per minute (rpm) designation made elsewhere.

SIUnit createSIHeatCapacity ( )
related

J/m^2*K = kg/s^2*K.

SIUnit createSIIlluminance ( )
related

Lux (lux or lx) = lm/m^2 = cd*sr/m^2.

SIUnit createSIInductance ( )
related

Henry (H) = Wb/A = s*V/A = kg*m^2/s^2*A^2.

SIUnit createSILength ( )
related
SIUnit createSILuminousFlux ( )
related

Lumen (lm) = cd*sr.

SIUnit createSILuminousIntensity ( )
related
SIUnit createSIMagneticFieldStrength ( )
related

Tesla (T) = Wb/m^2 = J/m^2*A = kg/s^2*A.

SIUnit createSIMagneticFlux ( )
related

Weber (Wb) = J/A = kg*m^2/s^2*A.

SIUnit createSIMass ( )
related
SIUnit createSIPeople ( )
related
SIUnit createSIPower ( )
related

Watt (W) = J/s = N*m/s = kg*m^2/s^3.

SIUnit createSIPowerDensity ( )
related

W/m^2 = kg/s^3.

SIUnit createSIPowerPerPerson ( )
related

W/person = kg*m^2/s^3*person.

SIUnit createSIPressure ( )
related

Pa = N/m^2 = kg/m*s^2.

SIUnit createSISolidAngle ( )
related
SIUnit createSITemperature ( )
related
SIUnit createSIThermalConductance ( )
related

W/m^2*K = kg/s^3*K.

SIUnit createSIThermalResistance ( )
related

m^2*K/W = s^3*K/kg

SIUnit createSITime ( )
related
typedef boost::optional<SIUnit> OptionalSIUnit
related
typedef std::vector<SIUnit> SIUnitVector
related