OpenStudio:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Static Public Member Functions | Related Functions | List of all members
openstudio::IPUnit Class Reference

#include <IPUnit.hpp>

+ Inheritance diagram for openstudio::IPUnit:

Public Member Functions

Constructors and Destructors
 IPUnit (const IPExpnt &exponents=IPExpnt(), int scaleExponent=0, const std::string &prettyString="")
 Default constructor. More...
 
 IPUnit (const std::string &scaleAbbreviation, const IPExpnt &exponents=IPExpnt(), const std::string &prettyString="")
 Alternate constructor. More...
 
virtual ~IPUnit ()
 
Mathematical Operators
void lbmToLbf ()
 Convert any non-zero lb_m exponent to lb_f. More...
 
void lbfToLbm ()
 Convert any non-zero lb_f exponent to lb_m. More...
 
- 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...
 

Static Public Member Functions

static double gc ()
 

Related Functions

(Note that these are not member functions.)

typedef std::vector< IPUnitIPUnitVector
 
typedef boost::optional< IPUnitOptionalIPUnit
 
Create Functions Used by UnitFactory
IPUnit createIPMass ()
 
IPUnit createIPLength ()
 
IPUnit createIPTime ()
 
IPUnit createIPTemperature ()
 
IPUnit createIPElectricCurrent ()
 
IPUnit createIPLuminousIntensity ()
 
IPUnit createIPAmountOfSubstance ()
 
IPUnit createIPAngle ()
 
IPUnit createIPSolidAngle ()
 
IPUnit createIPPeople ()
 
IPUnit createIPForce ()
 lb_f is preferred over equivalent using lb_m. More...
 
IPUnit createIPEnergy ()
 ft*lb_f is preferred over equivalent using lb_m. More...
 
IPUnit createIPPower ()
 ft*lb_f/s is preferred over equivalent using lb_m. More...
 
IPUnit createIPElectricCharge ()
 Coulomb (C) = s*A. More...
 
IPUnit createIPLuminousFlux ()
 Lumen (lm) = cd*sr. More...
 
IPUnit createIPIlluminance ()
 Foot-candles (fc) = lm/ft^2 = cd*sr/ft^2. More...
 
IPUnit createIPFrequency ()
 Hertz (Hz) = cycles/s. More...
 

Detailed Description

IPUnit is a Unit with baseUnits fixed by its constructors, see IPExpnt.

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

Constructor & Destructor Documentation

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

Default constructor.

Example:

IPUnit myEnergy(IPExpnt(0,1,0,0,1));
std::cout << myEnergy; // produces "ft*lb_f" 
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::IPUnit::IPUnit ( const std::string &  scaleAbbreviation,
const IPExpnt exponents = IPExpnt(),
const std::string &  prettyString = "" 
)

Alternate constructor.

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

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::IPUnit::~IPUnit ( )
inlinevirtual

Member Function Documentation

static double openstudio::IPUnit::gc ( )
static
void openstudio::IPUnit::lbfToLbm ( )

Convert any non-zero lb_f exponent to lb_m.

void openstudio::IPUnit::lbmToLbf ( )

Convert any non-zero lb_m exponent to lb_f.

Friends And Related Function Documentation

IPUnit createIPAmountOfSubstance ( )
related
IPUnit createIPAngle ( )
related
IPUnit createIPElectricCharge ( )
related

Coulomb (C) = s*A.

IPUnit createIPElectricCurrent ( )
related
IPUnit createIPEnergy ( )
related

ft*lb_f is preferred over equivalent using lb_m.

IPUnit createIPForce ( )
related

lb_f is preferred over equivalent using lb_m.

IPUnit createIPFrequency ( )
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.

IPUnit createIPIlluminance ( )
related

Foot-candles (fc) = lm/ft^2 = cd*sr/ft^2.

IPUnit createIPLength ( )
related
IPUnit createIPLuminousFlux ( )
related

Lumen (lm) = cd*sr.

IPUnit createIPLuminousIntensity ( )
related
IPUnit createIPMass ( )
related
IPUnit createIPPeople ( )
related
IPUnit createIPPower ( )
related

ft*lb_f/s is preferred over equivalent using lb_m.

IPUnit createIPSolidAngle ( )
related
IPUnit createIPTemperature ( )
related
IPUnit createIPTime ( )
related
typedef std::vector<IPUnit> IPUnitVector
related
typedef boost::optional<IPUnit> OptionalIPUnit
related