Go to the documentation of this file.
25 #include "spdlog/fmt/ostr.h"
26 #include "spdlog/spdlog.h"
39 #define AD_PHYSICS_DURATION_THROWS_EXCEPTION 1
41 #if SAFE_DATATYPES_EXPLICIT_CONVERSION
45 #define _AD_PHYSICS_DURATION_EXPLICIT_CONVERSION_ explicit
50 #define _AD_PHYSICS_DURATION_EXPLICIT_CONVERSION_
59 class DurationSquared;
93 : mDuration(std::numeric_limits<double>::quiet_NaN())
103 : mDuration(iDuration)
174 return (mDuration > other.mDuration) &&
operator!=(other);
190 return (mDuration < other.mDuration) &&
operator!=(other);
206 return ((mDuration > other.mDuration) ||
operator==(other));
222 return ((mDuration < other.mDuration) ||
operator==(other));
239 Duration const result(mDuration + other.mDuration);
258 mDuration += other.mDuration;
277 Duration const result(mDuration - other.mDuration);
296 mDuration -= other.mDuration;
327 Duration const result(mDuration * scalar);
344 Duration const scalarDuration(scalar);
345 Duration const result(
operator/(scalarDuration));
365 double const result = mDuration / other.mDuration;
405 auto const valueClass = std::fpclassify(mDuration);
406 return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (
cMinValue <= mDuration)
420 spdlog::info(
"ensureValid(::ad::physics::Duration)>> {} value out of range", *
this);
421 #if (AD_PHYSICS_DURATION_THROWS_EXCEPTION == 1)
422 throw std::out_of_range(
"Duration value out of range");
438 spdlog::info(
"ensureValid(::ad::physics::Duration)>> {} value is zero", *
this);
439 #if (AD_PHYSICS_DURATION_THROWS_EXCEPTION == 1)
440 throw std::out_of_range(
"Duration value is zero");
491 return value.operator*(other);
502 inline ::ad::physics::Duration
fabs(const ::ad::physics::Duration other)
522 static inline ::ad::physics::Duration
lowest()
524 return ::ad::physics::Duration::getMin();
529 static inline ::ad::physics::Duration
max()
531 return ::ad::physics::Duration::getMax();
537 static inline ::ad::physics::Duration
epsilon()
539 return ::ad::physics::Duration::getPrecision();
548 #ifndef GEN_GUARD_AD_PHYSICS_DURATION
549 #define GEN_GUARD_AD_PHYSICS_DURATION
570 return os << double(_value);
582 return to_string(
static_cast<double>(value));
585 #endif // GEN_GUARD_AD_PHYSICS_DURATION
#define _AD_PHYSICS_DURATION_EXPLICIT_CONVERSION_
Enable/Disable explicit conversion. Currently set to "implicit conversion allowed".
Definition: Duration.hpp:50
void ensureValidNonZero() const
ensure that the Duration is valid and non zero
Definition: Duration.hpp:433
Duration & operator+=(const Duration &other)
standard arithmetic operator
Definition: Duration.hpp:254
namespace ad
Definition: Acceleration.hpp:30
Duration operator*(const double &scalar) const
standard arithmetic operator
Definition: Duration.hpp:324
Duration()
default constructor
Definition: Duration.hpp:92
static inline ::ad::physics::Duration lowest()
Definition: Duration.hpp:522
static Duration getMax()
get maximum valid Duration (i.e. cMaxValue)
Definition: Duration.hpp:456
static const double cMinValue
constant defining the minimum valid Duration value (used in isValid())
Definition: Duration.hpp:73
void ensureValid() const
ensure that the Duration is valid
Definition: Duration.hpp:416
bool operator>(const Duration &other) const
standard comparison operator
Definition: Duration.hpp:170
Duration & operator=(const Duration &other)=default
standard assignment operator
DataType DurationSquared.
Definition: DurationSquared.hpp:67
static inline ::ad::physics::Duration max()
Definition: Duration.hpp:529
bool operator>=(const Duration &other) const
standard comparison operator
Definition: Duration.hpp:202
static const double cPrecisionValue
constant defining the assumed Duration value accuracy (used in comparison operator==(),...
Definition: Duration.hpp:84
Duration operator-=(const Duration &other)
standard arithmetic operator
Definition: Duration.hpp:292
Duration operator/(const double &scalar) const
standard arithmetic operator
Definition: Duration.hpp:342
Duration operator+(const Duration &other) const
standard arithmetic operator
Definition: Duration.hpp:235
bool operator<=(const Duration &other) const
standard comparison operator
Definition: Duration.hpp:218
double operator/(const Duration &other) const
standard arithmetic operator
Definition: Duration.hpp:361
Duration operator-() const
standard arithmetic operator
Definition: Duration.hpp:377
DurationSquared operator*(const Duration &other) const
standard arithmetic operator
static const double cMaxValue
constant defining the maximum valid Duration value (used in isValid())
Definition: Duration.hpp:78
static inline ::ad::physics::Duration epsilon()
Definition: Duration.hpp:537
static Duration getMin()
get minimum valid Duration (i.e. cMinValue)
Definition: Duration.hpp:448
bool operator<(const Duration &other) const
standard comparison operator
Definition: Duration.hpp:186
inline ::ad::physics::Weight fabs(const ::ad::physics::Weight other)
overload of the std::fabs for Weight
Definition: Weight.hpp:480
inline ::ad::physics::Acceleration fabs(const ::ad::physics::Acceleration other)
overload of the std::fabs for Acceleration
Definition: Acceleration.hpp:481
_AD_PHYSICS_DURATION_EXPLICIT_CONVERSION_ Duration(double const iDuration)
standard constructor
Definition: Duration.hpp:102
std::string to_string(::ad::physics::Acceleration const &value)
overload of the std::to_string for Acceleration
Definition: Acceleration.hpp:559
DataType Duration.
Definition: Duration.hpp:67
bool isValid() const
Definition: Duration.hpp:403
static Duration getPrecision()
get assumed accuracy of Duration (i.e. cPrecisionValue)
Definition: Duration.hpp:464
inline ::ad::physics::Duration operator*(const double &other, ::ad::physics::Duration const &value)
standard arithmetic operator
Definition: Duration.hpp:489
bool operator!=(const Duration &other) const
standard comparison operator
Definition: Duration.hpp:156
bool operator==(const Duration &other) const
standard comparison operator
Definition: Duration.hpp:142
std::ostream & operator<<(std::ostream &os, Acceleration const &_value)
standard ostream operator
Definition: Acceleration.hpp:547
Duration operator-(const Duration &other) const
standard arithmetic operator
Definition: Duration.hpp:273