OpenStudio:utilities
Loading...
Searching...
No Matches
openstudio::WhUnit Class Reference

#include <WhUnit.hpp>

+ Inheritance diagram for openstudio::WhUnit:

Related Symbols

(Note that these are not member symbols.)

using OptionalWhUnit = boost::optional<WhUnit>
 
using WhUnitVector = std::vector<WhUnit>
 
Create Functions Used by UnitFactory
WhUnit createWhPower ()
 
WhUnit createWhTime ()
 
WhUnit createWhLength ()
 
WhUnit createWhTemperature ()
 
WhUnit createWhElectricCurrent ()
 
WhUnit createWhLuminousIntensity ()
 
WhUnit createWhAmountOfSubstance ()
 
WhUnit createWhAngle ()
 
WhUnit createWhSolidAngle ()
 
WhUnit createWhPeople ()
 
WhUnit createWhCycle ()
 
WhUnit createWhCurrency ()
 
WhUnit createWhEnergy ()
 
WhUnit createWhElectricalPotential ()
 Volt (V) = W/A.
 
WhUnit createWhElectricResistance ()
 Ohm (ohm) = V/A = W/A^2.
 
WhUnit createWhLuminousFlux ()
 Lumen (lm) = cd*sr.
 
WhUnit createWhIlluminance ()
 Lux (lux or lx) = lm/m^2 = cd*sr/m^2.
 

Constructors and Destructors

 WhUnit (const WhExpnt &exponents=WhExpnt(), int scaleExponent=0, const std::string &prettyString="")
 Default constructor.
 
 WhUnit (const std::string &scaleAbbreviation, const WhExpnt &exponents=WhExpnt(), const std::string &prettyString="")
 Alternate constructor.
 
virtual ~WhUnit () override=default
 

Additional Inherited Members

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

Detailed Description

WhUnit is a Unit with baseUnits W, h, m, K, and people.

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

Constructor & Destructor Documentation

◆ WhUnit() [1/2]

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

Default constructor.

Example:

WhUnit myEnergy(WhExpnt(1,1),3,"Wh");
std::cout << myEnergy; // produces "kWh" 
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.

◆ WhUnit() [2/2]

openstudio::WhUnit::WhUnit ( const std::string & scaleAbbreviation,
const WhExpnt & exponents = WhExpnt(),
const std::string & prettyString = "" )

Alternate constructor.

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

WhUnit myEnergy("k",WhExpnt(1,1),"Wh");
std::cout << myEnergy; // produces "kWh" 
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.

◆ ~WhUnit()

virtual openstudio::WhUnit::~WhUnit ( )
overridevirtualdefault

Friends And Related Symbol Documentation

◆ createWhAmountOfSubstance()

WhUnit createWhAmountOfSubstance ( )
related

◆ createWhAngle()

WhUnit createWhAngle ( )
related

◆ createWhCurrency()

WhUnit createWhCurrency ( )
related

◆ createWhCycle()

WhUnit createWhCycle ( )
related

◆ createWhElectricalPotential()

WhUnit createWhElectricalPotential ( )
related

Volt (V) = W/A.

◆ createWhElectricCurrent()

WhUnit createWhElectricCurrent ( )
related

◆ createWhElectricResistance()

WhUnit createWhElectricResistance ( )
related

Ohm (ohm) = V/A = W/A^2.

◆ createWhEnergy()

WhUnit createWhEnergy ( )
related

◆ createWhIlluminance()

WhUnit createWhIlluminance ( )
related

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

◆ createWhLength()

WhUnit createWhLength ( )
related

◆ createWhLuminousFlux()

WhUnit createWhLuminousFlux ( )
related

Lumen (lm) = cd*sr.

◆ createWhLuminousIntensity()

WhUnit createWhLuminousIntensity ( )
related

◆ createWhPeople()

WhUnit createWhPeople ( )
related

◆ createWhPower()

WhUnit createWhPower ( )
related

◆ createWhSolidAngle()

WhUnit createWhSolidAngle ( )
related

◆ createWhTemperature()

WhUnit createWhTemperature ( )
related

◆ createWhTime()

WhUnit createWhTime ( )
related

◆ OptionalWhUnit

using OptionalWhUnit = boost::optional<WhUnit>
related

◆ WhUnitVector

using WhUnitVector = std::vector<WhUnit>
related