39 #ifndef OME_XML_MODEL_PRIMITIVES_QUANTITY_H 40 #define OME_XML_MODEL_PRIMITIVES_QUANTITY_H 42 #include <boost/operators.hpp> 56 template<
class Unit,
typename Value =
double>
57 class Quantity :
private boost::partially_ordered<Quantity<Unit, Value>,
58 boost::equality_comparable<Quantity<Unit, Value>,
59 boost::addable<Quantity<Unit, Value>,
60 boost::subtractable<Quantity<Unit, Value>,
61 boost::dividable2<Quantity<Unit, Value>, Value,
62 boost::multipliable2<Quantity<Unit, Value>, Value,
63 boost::incrementable<Quantity<Unit, Value>,
64 boost::decrementable<Quantity<Unit, Value>>>>>>>>>
78 unit(typename unit_type::enum_value(0))
177 this->value *=
value;
190 this->value /=
value;
203 this->value %=
value;
266 template<
typename Unit,
typename Value>
292 template<
class Unit,
typename Value>
299 return conv(quantity, unit);
302 template<
class Unit,
typename Value>
311 template<
class Unit,
typename Value>
320 template<
class Unit,
typename Value>
328 template<
class Unit,
typename Value>
343 template<
class charT,
class traits,
typename Unit,
typename Value>
344 inline std::basic_ostream<charT,traits>&
345 operator<< (std::basic_ostream<charT,traits>& os,
348 return os << quantity.
getValue() <<
' ' << quantity.getUnit();
358 template<
class charT,
class traits,
typename Unit,
typename Value>
359 inline std::basic_istream<charT,traits>&
364 Unit u(
typename Unit::enum_value(0));
377 #endif // OME_XML_MODEL_PRIMITIVES_QUANTITY_H UnitsElectricPotential enumeration.
Definition: UnitsElectricPotential.h:74
Quantity(const Quantity &quantity)
Copy construct a Quantity.
Definition: Quantity.h:102
bool operator<(const Quantity &quantity) const
Check if the quantity is less than a quantity.
Definition: Quantity.h:323
Quantity & operator*=(const value_type &value)
Multiply the quantity by a value.
Definition: Quantity.h:175
Quantity< Unit, Value > convert(const Quantity< Unit, Value > &quantity, typename Quantity< Unit, Value >::unit_type unit)
Convert quantity to another unit.
Definition: Quantity.h:295
Quantity & operator=(const Quantity &quantity)
Assign the quantity from a quantity.
Definition: Quantity.h:143
~Quantity()
Destructor.
Definition: Quantity.h:110
Quantity & operator/=(const value_type &value)
Divide the quantity by a value.
Definition: Quantity.h:188
Quantity & operator++()
Increment the quantity by one.
Definition: Quantity.h:213
Open Microscopy Environment C++ implementation.
Quantity()
Default construct a Quantity.
Definition: Quantity.h:76
Quantity & operator%=(const value_type &value)
Modulo of the quantity by a value.
Definition: Quantity.h:201
Unit unit_type
The type of a unit.
Definition: Quantity.h:68
Quantity(value_type value, unit_type unit)
Construct a Quantity from a value and unit.
Definition: Quantity.h:89
value_type value
Quantity value.
Definition: Quantity.h:254
Convert a quantity to a different unit.
Definition: Quantity.h:267
Quantity & operator--()
Decrement the quantity by one.
Definition: Quantity.h:225
bool operator==(const Quantity &quantity) const
Check if the quantity is equal to a quantity.
Definition: Quantity.h:331
Quantity & operator+=(const Quantity &quantity)
Add a quantity to the quantity.
Definition: Quantity.h:305
A quantity of a defined unit.
Definition: Quantity.h:57
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &is, Color &color)
Set Color from input stream.
Definition: Color.h:478
Value value_type
The type of a value.
Definition: Quantity.h:70
value_type getValue() const
Get the value for this quantity.
Definition: Quantity.h:120
Quantity & operator-=(const Quantity &quantity)
Subtract a quantity from the quantity.
Definition: Quantity.h:314
unit_type getUnit() const
Get the unit for this quantity.
Definition: Quantity.h:131
unit_type unit
Quantity unit.
Definition: Quantity.h:256