FNSS ns-3 adapter
ns-3 adapter for the Fast Network Simulation Setup (FNSS) toolchain
 All Classes Files Functions Typedefs Pages
quantity.h
1 #ifndef QUANTITY_H
2 #define QUANTITY_H
3 
4 #include "measurement-unit.h"
5 
6 #include <string>
7 
8 namespace fnss {
9 
16 class Quantity {
17 public:
26  Quantity(const double &value, const std::string &unit,
27  const MeasurementUnit &converter);
28 
40  Quantity(const double &value, const MeasurementUnit &converter);
41 
52  Quantity(const std::string &str, const MeasurementUnit &converter);
53 
60  Quantity(const MeasurementUnit &converter);
61 
68  void fromString(const std::string &str);
69 
80  std::string toString(const std::string &separator="") const;
81 
87  void convert(const std::string &unit);
88 
94  double getValue() const;
95 
101  void setValue(const double &value);
102 
108  std::string getUnit() const;
109 
115  void setUnit(const std::string &unit);
116 
123  const MeasurementUnit& getMeasurementUnit() const;
124 
132  Quantity& operator=(const Quantity &other);
133 
137  bool operator<(const Quantity &other) const;
138 
142  bool operator<=(const Quantity &other) const;
143 
147  bool operator>(const Quantity &other) const;
148 
152  bool operator>=(const Quantity &other) const;
153 
157  bool operator==(const Quantity &other) const;
158 
159 private:
160  double value; //The numerical value of the quantity.
161  std::string unit; //The measurement unit of the quantity.
162  const MeasurementUnit &converter; //The "type" of the unit, used for
163  //comparisons and conversions.
164 };
165 
166 } //namespace
167 
168 #endif //QUANTITY_H
void fromString(const std::string &str)
Definition: quantity.cpp:29
Definition: measurement-unit.h:10
bool operator>=(const Quantity &other) const
Definition: quantity.cpp:93
void setValue(const double &value)
Definition: quantity.cpp:52
double getValue() const
Definition: quantity.cpp:48
void setUnit(const std::string &unit)
Definition: quantity.cpp:60
bool operator>(const Quantity &other) const
Definition: quantity.cpp:88
Quantity(const double &value, const std::string &unit, const MeasurementUnit &converter)
Definition: quantity.cpp:7
std::string toString(const std::string &separator="") const
Definition: quantity.cpp:37
const MeasurementUnit & getMeasurementUnit() const
Definition: quantity.cpp:64
std::string getUnit() const
Definition: quantity.cpp:56
bool operator<=(const Quantity &other) const
Definition: quantity.cpp:83
bool operator<(const Quantity &other) const
Definition: quantity.cpp:78
void convert(const std::string &unit)
Definition: quantity.cpp:43
Quantity & operator=(const Quantity &other)
Definition: quantity.cpp:68
bool operator==(const Quantity &other) const
Definition: quantity.cpp:98
Definition: quantity.h:16