|
FNSS C++ library
C++ API for the Fast Network Simulation Setup (FNSS) toolchain
|
#include <quantity.h>
Public Member Functions | |
| Quantity (const double &value_, const std::string &unit_, const MeasurementUnit &converter_) | |
| Quantity (const double &value_, const MeasurementUnit &converter_) | |
| Quantity (const std::string &str, const MeasurementUnit &converter_) | |
| Quantity (const MeasurementUnit &converter_) | |
| void | fromString (const std::string &str) |
| std::string | toString (const std::string &separator="") const |
| void | convert (const std::string &unit) |
| double | getValue () const |
| void | setValue (const double &value) |
| std::string | getUnit () const |
| void | setUnit (const std::string &unit) |
| const MeasurementUnit & | getMeasurementUnit () const |
| Quantity & | operator= (const Quantity &other) |
| bool | operator< (const Quantity &other) const |
| bool | operator<= (const Quantity &other) const |
| bool | operator> (const Quantity &other) const |
| bool | operator>= (const Quantity &other) const |
| bool | operator== (const Quantity &other) const |
Models a quantity and allows for conversions between measurement units of the same type.
| fnss::Quantity::Quantity | ( | const double & | value_, |
| const std::string & | unit_, | ||
| const MeasurementUnit & | converter_ | ||
| ) |
Constructor with explicit numerical value and unit.
| value | the numeric value of the quantity. |
| unit | the value of the quantity's unit. |
| converter | the MeasurementUnit object used for conversions. The object is not copied, only the reference is stored. |
| fnss::Quantity::Quantity | ( | const double & | value_, |
| const MeasurementUnit & | converter_ | ||
| ) |
Constructor with explicit numerical value.
The unit is assigned to the base of this->converter. Mainly declared to avoid calls of the type Quantity(0, someUnit) that would otherwise match the string constructor.
| value | the numeric value of the quantity. |
| converter | the MeasurementUnit object used for conversions. The object is not copied, only the reference is stored. |
| fnss::Quantity::Quantity | ( | const std::string & | str, |
| const MeasurementUnit & | converter_ | ||
| ) |
Constructor that parses a string to obtain the numerical value and unit.
If not provided in the input, the unit is assumed to be the base of this->converter.
| str | the std::string to be parsed for value and unit data. |
| converter | the MeasurementUnit object used for conversions. The object is not copied, only the reference is stored. |
| fnss::Quantity::Quantity | ( | const MeasurementUnit & | converter_ | ) |
Constructor.
| converter | the MeasurementUnit object used for conversions. The object is not copied, only the reference is stored. |
| void fnss::Quantity::convert | ( | const std::string & | unit | ) |
Convert to the specified unit(eg. from GB/s to Tb/h).
| unit | the unit to convert to. |
| void fnss::Quantity::fromString | ( | const std::string & | str | ) |
Parse a string to obtain the numerical value and unit. The previously stored data is discarded.
| str | the std::string to be parsed for value and unit data. |
| const MeasurementUnit & fnss::Quantity::getMeasurementUnit | ( | ) | const |
Get a const reference to the MeasurementUnit object that is using for conversions.
const reference to the MeasurementUnit object being used. | std::string fnss::Quantity::getUnit | ( | ) | const |
Get method for the unit of the quantity.
| double fnss::Quantity::getValue | ( | ) | const |
Get method for the numerical value of the quantity.
| bool fnss::Quantity::operator< | ( | const Quantity & | other | ) | const |
Comparison operator that takes into account the quantity's measurement unit.
| bool fnss::Quantity::operator<= | ( | const Quantity & | other | ) | const |
Comparison operator that takes into account the quantity's measurement unit.
Assignment operator.
Throws an exception if the MeasurementUnit reference of the other object has a different base from the MeasurementUnit reference of .
| bool fnss::Quantity::operator== | ( | const Quantity & | other | ) | const |
Comparison operator that takes into account the quantity's measurement unit.
| bool fnss::Quantity::operator> | ( | const Quantity & | other | ) | const |
Comparison operator that takes into account the quantity's measurement unit.
| bool fnss::Quantity::operator>= | ( | const Quantity & | other | ) | const |
Comparison operator that takes into account the quantity's measurement unit.
| void fnss::Quantity::setUnit | ( | const std::string & | unit | ) |
Set method for the unit of the quantity.
| unit | the unit to set. |
| void fnss::Quantity::setValue | ( | const double & | value | ) |
Set method for the numerical value of the quantity.
| value | the numerical value to set. |
| std::string fnss::Quantity::toString | ( | const std::string & | separator = "" | ) | const |
Obtain a string representation of the object(eg. "5 GB/s").
If not provided in the input, the unit is assumed to be the base of this->converter.
| separator | the std::the separator to insert between value and unit. |
std::string representation of the object.
1.8.6