LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
An interval (duration, length, distance) between two quantity points. More...
#include "intervals.h"
Public Types | |
using | category_base_t = details::WithCategory< Cat > |
using | traits_t = typename category_base_t::traits_t |
Traits of the category. More... | |
template<typename OC , typename Type = void> | |
using | enable_if_compatible_t = std::enable_if_t< category_base_t::template category_compatible_with< OC >(), Type > |
using | interval_t = Interval< Q, Cat > |
This type. More... | |
Types from the base quantity | |
using | quantity_t = Q |
Quantity the interval is based on. More... | |
using | category_t = typename category_base_t::category_t |
Quantity the interval is based on. More... | |
template<typename R > | |
using | scaled_quantity_t = rescale< quantity_t, R > |
A quantity in the same unit, but possibly a different scale. More... | |
using | value_t = typename quantity_t::value_t |
Type of the stored value. More... | |
using | unit_t = typename quantity_t::unit_t |
Description of the scaled unit. More... | |
using | baseunit_t = typename quantity_t::baseunit_t |
Description of the unscaled unit. More... | |
template<typename OQ , typename OI > | |
using | other_interval_t = Interval< OQ, category_t > |
An interval based on a different quantity but with the same category. More... | |
Public Member Functions | |
Interval ()=default | |
Constructor: value is left uninitialized. More... | |
constexpr | Interval (value_t v) |
Constructor: takes a value in the intended representation. More... | |
template<typename... Args> | |
constexpr | Interval (Quantity< Args... > const &q) |
Constructor: converts from a quantity. More... | |
template<typename IV , typename std::enable_if_t< is_interval_v< IV >> * = nullptr> | |
constexpr | Interval (IV iv) |
Constructor: converts from another interval. More... | |
constexpr quantity_t const & | quantity () const |
Returns the value of the interval as a quantity. More... | |
constexpr | operator value_t () const |
Conversion to the base quantity. More... | |
template<typename IV > | |
constexpr IV | convertInto () const |
Convert this interval into the specified one. More... | |
Asymmetric operand arithmetic operations | |
These arithmetic operations take care of preserving the interval unit through them. Not all possible (or reasonable) operations are supported yet. Some operations that may be symmetric (like multiplication by a scalar) are implemented as free functions rather than methods.
| |
constexpr interval_t | operator+ (interval_t const other) const |
constexpr interval_t | operator- (interval_t const other) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, value_t > | operator/ (Interval< OQ, OC > const denom) const |
Division by an interval, returns a pure number. More... | |
template<typename R > | |
interval_t & | operator+= (scaled_quantity_t< R > const other) |
Add a quantity (possibly converted) to this one. More... | |
template<typename OQ , typename OC > | |
enable_if_compatible_t< Interval< OQ, OC >, interval_t & > | operator+= (Interval< OQ, OC > const other) |
Add the other interval (possibly converted) to this one. More... | |
template<typename R > | |
interval_t & | operator-= (scaled_quantity_t< R > const other) |
Subtract a quantity (possibly converted) from this one. More... | |
template<typename OQ , typename OC > | |
enable_if_compatible_t< Interval< OQ, OC >, interval_t & > | operator-= (Interval< OQ, OC > const other) |
Subtract the other interval (possibly converted) from this one. More... | |
template<typename T > | |
interval_t & | operator*= (T factor) |
Scale this interval by a factor. More... | |
template<typename T > | |
interval_t & | operator/= (T factor) |
Scale the interval dividing it by a quotient. More... | |
constexpr interval_t | operator+ () const |
Returns an interval with same value. More... | |
constexpr interval_t | operator- () const |
Returns an interval with same value but the sign flipped. More... | |
constexpr interval_t | abs () const |
Returns an interval with the absolute value of this one. More... | |
Comparisons. | |
Comparisons with plain numbers are managed by implicit conversion. More care is needed for quantities. Comparisons between two quantity instances
Value storage types are compared according to C++ rules. | |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, bool > | operator== (Interval< OQ, OC > const other) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, bool > | operator!= (Interval< OQ, OC > const other) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, bool > | operator>= (Interval< OQ, OC > const other) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, bool > | operator> (Interval< OQ, OC > const other) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, bool > | operator<= (Interval< OQ, OC > const other) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t< Interval< OQ, OC >, bool > | operator< (Interval< OQ, OC > const other) const |
Static Public Member Functions | |
template<typename U > | |
static interval_t | castFrom (U value) |
Returns a new interval initialized with the specified value. More... | |
static constexpr category_t | category () |
Returns an instance of the category of this object. More... | |
static constexpr bool | hasCategoryName () |
Returns whether this category has a name. More... | |
static std::string | categoryName () |
Returns the name of the category of this object. More... | |
Access to the scaled unit. | |
template<typename OU > | |
static constexpr bool | sameBaseUnitAs () |
Returns whether objects of type OU have the same base unit as this. More... | |
template<typename OU > | |
static constexpr bool | sameUnitAs () |
Returns whether objects of type OU have same unit and scale as this. More... | |
template<typename OC > | |
static constexpr bool | same_category_as () |
Returns whether the type OC belongs to category_t . More... | |
template<typename OC > | |
static constexpr bool | same_category_as (OC const &) |
Returns whether the type OC belongs to category_t . More... | |
template<typename OC > | |
static constexpr bool | category_compatible_with () |
Returns whether OC has a category compatible with this one. More... | |
template<typename OC > | |
static constexpr bool | category_compatible_with (OC const &) |
Returns whether OC has a category compatible with this one. More... | |
An interval (duration, length, distance) between two quantity points.
Q | quantity the interval is based on |
An interval shares most of the concepts of a Quantity
, but it interacts only with other intervals rather than with bare Quantity
objects, with the exception of construction. In this sense, the relation between Interval
and Quantity
is similar to the one between Quantity
and its base type (Quantity::value_t
).
In addition, an interval can be added to a quantity point (Point
) to translate it, and it can be obtained as difference between two quantity points.
Definition at line 106 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::baseunit_t = typename quantity_t::baseunit_t |
Description of the unscaled unit.
Definition at line 140 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::category_base_t = details::WithCategory<Cat> |
Definition at line 108 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::category_t = typename category_base_t::category_t |
Quantity the interval is based on.
The category this point belongs to.
Definition at line 127 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::enable_if_compatible_t = std::enable_if_t<category_base_t::template category_compatible_with<OC>(), Type> |
Definition at line 115 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::interval_t = Interval<Q, Cat> |
This type.
Definition at line 118 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::other_interval_t = Interval<OQ, category_t> |
An interval based on a different quantity but with the same category.
Definition at line 144 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::quantity_t = Q |
Quantity the interval is based on.
The category this point belongs to.
Definition at line 124 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::scaled_quantity_t = rescale<quantity_t, R> |
A quantity in the same unit, but possibly a different scale.
Definition at line 131 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::traits_t = typename category_base_t::traits_t |
Traits of the category.
Definition at line 111 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::unit_t = typename quantity_t::unit_t |
Description of the scaled unit.
Definition at line 137 of file intervals.h.
using util::quantities::concepts::Interval< Q, Cat >::value_t = typename quantity_t::value_t |
Type of the stored value.
Definition at line 134 of file intervals.h.
|
explicitdefault |
Constructor: value is left uninitialized.
|
inlineexplicit |
Constructor: takes a value in the intended representation.
Definition at line 155 of file intervals.h.
|
inline |
Constructor: converts from a quantity.
OQ | type of the quantity |
q | quantity to be converted from |
The quantity is required to be in the same unit as this interval (unit scale may differ). The value in q
is converted from its native scale into the one of this interval.
Definition at line 168 of file intervals.h.
|
inline |
Constructor: converts from another interval.
I | type of the other interval |
iv | interval to be converted from |
Intervals are required to be in the same unit (unit scale may differ). The value in iv
is converted from its native scale into the one of this interval.
Definition at line 181 of file intervals.h.
|
inline |
Returns an interval with the absolute value of this one.
Definition at line 336 of file intervals.h.
References util::quantities::concepts::Interval< Q, Cat >::abs().
Referenced by util::quantities::concepts::Interval< Q, Cat >::abs().
|
inlinestatic |
Returns a new interval initialized with the specified value.
U | type to initialize the quantity with |
value | the value to initialize the interval with |
Interval
object initialized with value
The value
is cast into value_t
via static_cast()
.
Definition at line 420 of file intervals.h.
References value.
|
staticinherited |
Returns an instance of the category of this object.
Definition at line 1190 of file intervals.h.
|
staticinherited |
Returns whether OC
has a category compatible with this one.
Definition at line 1213 of file intervals.h.
|
staticinherited |
Returns whether OC
has a category compatible with this one.
Definition at line 1220 of file intervals.h.
|
staticinherited |
Returns the name of the category of this object.
Definition at line 1234 of file intervals.h.
|
inline |
Convert this interval into the specified one.
Definition at line 406 of file intervals.h.
|
staticinherited |
Returns whether this category has a name.
Definition at line 1227 of file intervals.h.
|
inlineexplicit |
|
inline |
Definition at line 367 of file intervals.h.
References util::quantities::concepts::operator!=(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Scale this interval by a factor.
Definition at line 315 of file intervals.h.
|
inline |
Returns an interval sum of this and other
(must have exactly the same unit and scale).
Definition at line 263 of file intervals.h.
References util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Returns an interval with same value.
Definition at line 330 of file intervals.h.
|
inline |
Add a quantity (possibly converted) to this one.
Definition at line 285 of file intervals.h.
References lar::dump::operator+=().
|
inline |
Add the other
interval (possibly converted) to this one.
Definition at line 293 of file intervals.h.
References lar::dump::operator+=(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Returns an interval difference of this and other
(must have exactly the same unit and scale).
Definition at line 270 of file intervals.h.
References util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Returns an interval with same value but the sign flipped.
Definition at line 333 of file intervals.h.
|
inline |
Subtract a quantity (possibly converted) from this one.
Definition at line 300 of file intervals.h.
|
inline |
Subtract the other
interval (possibly converted) from this one.
Definition at line 308 of file intervals.h.
References util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Division by an interval, returns a pure number.
Definition at line 277 of file intervals.h.
References util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Scale the interval dividing it by a quotient.
Definition at line 323 of file intervals.h.
|
inline |
Definition at line 395 of file intervals.h.
References util::quantities::concepts::operator<(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Definition at line 388 of file intervals.h.
References util::quantities::concepts::operator<=(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Definition at line 360 of file intervals.h.
References util::quantities::concepts::operator==(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Definition at line 381 of file intervals.h.
References util::quantities::concepts::operator>(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Definition at line 374 of file intervals.h.
References util::quantities::concepts::operator>=(), and util::quantities::concepts::Interval< Q, Cat >::quantity().
|
inline |
Returns the value of the interval as a quantity.
Definition at line 185 of file intervals.h.
References value.
Referenced by util::quantities::concepts::Interval< Q, Cat >::operator!=(), util::quantities::concepts::operator*(), util::quantities::concepts::Interval< Q, Cat >::operator+(), util::quantities::concepts::Point< Q, Cat, IV >::operator+(), util::quantities::concepts::Interval< Q, Cat >::operator+=(), util::quantities::concepts::Point< Q, Cat, IV >::operator+=(), util::quantities::concepts::Interval< Q, Cat >::operator-(), util::quantities::concepts::Point< Q, Cat, IV >::operator-(), util::quantities::concepts::Interval< Q, Cat >::operator-=(), util::quantities::concepts::Point< Q, Cat, IV >::operator-=(), util::quantities::concepts::Interval< Q, Cat >::operator/(), util::quantities::concepts::operator/(), util::quantities::concepts::Interval< Q, Cat >::operator<(), util::quantities::concepts::operator<<(), util::quantities::concepts::Interval< Q, Cat >::operator<=(), util::quantities::concepts::Interval< Q, Cat >::operator==(), util::quantities::concepts::Interval< Q, Cat >::operator>(), util::quantities::concepts::Interval< Q, Cat >::operator>=(), and util::quantities::concepts::to_string().
|
staticinherited |
Returns whether the type OC
belongs to category_t
.
Definition at line 1198 of file intervals.h.
|
staticinherited |
Returns whether the type OC
belongs to category_t
.
Definition at line 1205 of file intervals.h.
|
inlinestatic |
Returns whether objects of type OU
have the same base unit as this.
Definition at line 214 of file intervals.h.
|
inlinestatic |
Returns whether objects of type OU
have same unit and scale as this.
Definition at line 221 of file intervals.h.