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))
185 this->value *=
value;
198 this->value /=
value;
211 this->value %=
value;
276 unit_type
unit)
const;
298 template<
class Unit,
typename Value>
303 return convert<Quantity<Unit, Value> >(quantity,
unit).
getValue();
313 template<
class charT,
class traits,
typename Unit,
typename Value>
314 inline std::basic_ostream<charT,traits>&
315 operator<< (std::basic_ostream<charT,traits>& os,
318 return os << quantity.
getValue() <<
' ' << quantity.getUnit();
328 template<
class charT,
class traits,
typename Unit,
typename Value>
329 inline std::basic_istream<charT,traits>&
334 Unit u(
typename Unit::enum_value(0));
347 #endif // OME_XML_MODEL_PRIMITIVES_QUANTITY_H 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:246
Quantity & operator*=(const value_type &value)
Multiply the quantity by a value.
Definition: Quantity.h:183
value_type convert_value(const Quantity &quantity, unit_type unit) const
Convert a quantity to a specific unit.
Definition: Quantity.h:300
Quantity & operator=(const Quantity &quantity)
Assign the quantity from a quantity.
Definition: Quantity.h:143
~Quantity()
Destructor.
Definition: Quantity.h:110
UnitsElectricPotential enumeration.
Definition: ElectricPotentialQuantity.h:68
Quantity & operator/=(const value_type &value)
Divide the quantity by a value.
Definition: Quantity.h:196
Quantity & operator++()
Increment the quantity by one.
Definition: Quantity.h:221
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:209
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
unit_type getUnit() const
Get the unit for this quantity.
Definition: Quantity.h:131
Quantity & operator-=(const Quantity &quantity)
Subtract a quantity from the quantity.
Definition: Quantity.h:170
value_type value
Quantity value.
Definition: Quantity.h:279
bool operator==(const Quantity &quantity) const
Check if the quantity is equal to a quantity.
Definition: Quantity.h:261
Quantity & operator--()
Decrement the quantity by one.
Definition: Quantity.h:233
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:479
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)
Add a quantity to the quantity.
Definition: Quantity.h:157
unit_type unit
Quantity unit.
Definition: Quantity.h:281