BLE: Update ble::Duration to support default values

pull/13759/head
Vincent Coubard 2020-09-03 12:36:18 +01:00
parent ad40b1b267
commit f7dfc5c9f2
1 changed files with 10 additions and 6 deletions

View File

@ -33,10 +33,11 @@ namespace ble {
* @tparam Min left-bound * @tparam Min left-bound
* @tparam Max right-bound * @tparam Max right-bound
*/ */
template<uint32_t Min, uint32_t Max> template<uint32_t Min, uint32_t Max, uint32_t Default = Min>
struct Range { struct Range {
static const uint32_t MIN = Min; static const uint32_t MIN = Min;
static const uint32_t MAX = Max; static const uint32_t MAX = Max;
static const uint32_t DEFAULT = Default;
}; };
/** /**
@ -111,7 +112,7 @@ struct Duration {
* *
* It is initialized with the minimum value acceptable. * It is initialized with the minimum value acceptable.
*/ */
Duration() : duration(Range::MIN) Duration() : duration(Range::DEFAULT)
{ {
} }
@ -598,11 +599,14 @@ bool operator>(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
#if !defined(DOXYGEN_ONLY) #if !defined(DOXYGEN_ONLY)
template<uint32_t Min, uint32_t Max> template<uint32_t Min, uint32_t Max, uint32_t Default>
const uint32_t Range<Min, Max>::MIN; const uint32_t Range<Min, Max, Default>::MIN;
template<uint32_t Min, uint32_t Max> template<uint32_t Min, uint32_t Max, uint32_t Default>
const uint32_t Range<Min, Max>::MAX; const uint32_t Range<Min, Max, Default>::MAX;
template<uint32_t Min, uint32_t Max, uint32_t Default>
const uint32_t Range<Min, Max, Default>::DEFAULT;
template<typename T, T V> template<typename T, T V>
const T Value<T, V>::VALUE; const T Value<T, V>::VALUE;