ad_physics
RatioValueValidInputRange.hpp
Go to the documentation of this file.
1 /*
2  * ----------------- BEGIN LICENSE BLOCK ---------------------------------
3  *
4  * Copyright (C) 2018-2020 Intel Corporation
5  *
6  * SPDX-License-Identifier: MIT
7  *
8  * ----------------- END LICENSE BLOCK -----------------------------------
9  */
10 
18 #pragma once
19 
20 #include <cmath>
21 #include <limits>
23 #include "spdlog/fmt/ostr.h"
24 #include "spdlog/spdlog.h"
25 
38 inline bool withinValidInputRange(::ad::physics::RatioValue const &input, bool const logErrors = true)
39 {
40  // check for generic numeric limits of the type
41  bool inValidInputRange = input.isValid() && (std::numeric_limits<::ad::physics::RatioValue>::lowest() <= input)
43  if (!inValidInputRange && logErrors)
44  {
45  spdlog::error("withinValidInputRange(::ad::physics::RatioValue)>> {} out of numerical limits [{}, {}]",
46  input,
49  }
50  return inValidInputRange;
51 }
std::numeric_limits<::ad::physics::RatioValue >::max
static inline ::ad::physics::RatioValue max()
Definition: RatioValue.hpp:508
ad::physics::RatioValue
DataType RatioValue.
Definition: RatioValue.hpp:59
ad::physics::RatioValue::isValid
bool isValid() const
Definition: RatioValue.hpp:382
withinValidInputRange
bool withinValidInputRange(::ad::physics::RatioValue const &input, bool const logErrors=true)
check if the given RatioValue is within valid input range
Definition: RatioValueValidInputRange.hpp:38
RatioValue.hpp
std::numeric_limits<::ad::physics::RatioValue >::lowest
static inline ::ad::physics::RatioValue lowest()
Definition: RatioValue.hpp:501