Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Duration< Rep, TB, Range, Forever > Struct Template Reference

Duration< Rep, TB, Range, Forever > Struct Template Reference

Model BLE durations. More...

#include <Duration.h>

Public Types

typedef Rep representation_t
 Type of the actual representation.

Public Member Functions

 Duration ()
 Construct a default Duration.
 Duration (Rep v)
 Construct a Duration from an integer value.
template<typename OtherRep , uint32_t OtherTB, typename OtherRange , typename OtherF >
 Duration (Duration< OtherRep, OtherTB, OtherRange, OtherF > other)
 Construct a Duration from another Duration.
template<typename OtherRep , typename OtherRange , typename OtherF >
 Duration (Duration< OtherRep, 1000, OtherRange, OtherF > other_ms, void *=NULL)
 Construct a new Duration from a Duration in milliseconds.
Rep value () const
 Return the duration in TB units.
uint32_t valueInMs () const
 Return the duration in milliseconds.
const Rep * storage () const
 Return a pointer to the value of the duration.

Static Public Member Functions

static Duration min ()
 Return the minimum duration.
static Duration max ()
 Return the maximum duration.
static Duration forever ()
 Return the Duration value meaning forever.

Static Public Attributes

static const uint32_t TIME_BASE = TB
 The time base.
static const Rep MIN = Range::MIN
 Left-bound of the duration range.
static const Rep MAX = Range::MAX
 Right bound of the duration range.

Related Functions

(Note that these are not member functions.)


template<typename DurationOut , typename RepIn , uint32_t TBIn, typename RangeIn , typename FIn >
DurationOut durationCast (Duration< RepIn, TBIn, RangeIn, FIn > duration)
 Cast a duration to another.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
microsecond_t operator+ (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Add two durations together and return the result in microseconds.
template<typename Rep , uint32_t TB, typename Range , typename F >
Duration< Rep, TB, Range, F > operator+ (Duration< Rep, TB, Range, F > lhs, Duration< Rep, TB, Range, F > rhs)
 Add two durations together.
template<typename Rep , uint32_t TB, typename Range , typename F >
Duration< Rep, TB, Range, F > operator* (Duration< Rep, TB, Range, F > lhs, uint32_t rhs)
 Multiply a duration and a positive integer.
template<typename Rep , uint32_t TB, typename Range , typename F >
Duration< Rep, TB, Range, F > operator* (uint32_t lhs, Duration< Rep, TB, Range, F > rhs)
 Multiply a duration and a positive integer.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
bool operator< (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Indicate if the duration lhs is less than the duration rhs.
template<typename Rep , uint32_t Us, typename Range , typename F >
bool operator< (Duration< Rep, Us, Range, F > lhs, Duration< Rep, Us, Range, F > rhs)
 Indicate if the duration lhs is less than the duration rhs.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
bool operator<= (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Indicate if the duration lhs is less than or equal to the duration rhs.
template<typename Rep , uint32_t Us, typename Range >
bool operator<= (Duration< Rep, Us, Range > lhs, Duration< Rep, Us, Range > rhs)
 Indicate if the duration lhs is less than or equal to the duration rhs.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
bool operator== (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Indicate if the duration lhs is equal to the duration rhs.
template<typename Rep , uint32_t Us, typename Range , typename F >
bool operator== (Duration< Rep, Us, Range, F > lhs, Duration< Rep, Us, Range, F > rhs)
 Indicate if the duration lhs is equal to the duration rhs.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
bool operator!= (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Indicate if the duration lhs is not equal to the duration rhs.
template<typename Rep , uint32_t Us, typename Range , typename F >
bool operator!= (Duration< Rep, Us, Range, F > lhs, Duration< Rep, Us, Range, F > rhs)
 Indicate if the duration lhs is not equal to the duration rhs.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
bool operator>= (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Indicate if the duration lhs greater or equal to the duration rhs.
template<typename Rep , uint32_t Us, typename Range , typename F >
bool operator>= (Duration< Rep, Us, Range, F > lhs, Duration< Rep, Us, Range, F > rhs)
 Indicate if the duration lhs greater or equal to the duration rhs.
template<typename RepLHS , uint32_t TBLHS, typename RangeLHS , typename FLHS , typename RepRHS , uint32_t TBRHS, typename RangeRHS , typename FRHS >
bool operator> (Duration< RepLHS, TBLHS, RangeLHS, FLHS > lhs, Duration< RepRHS, TBRHS, RangeRHS, FRHS > rhs)
 Indicate if the duration lhs greater than the duration rhs.
template<typename Rep , uint32_t Us, typename Range , typename F >
bool operator> (Duration< Rep, Us, Range, F > lhs, Duration< Rep, Us, Range, F > rhs)
 Indicate if the duration lhs greater than the duration rhs.

Detailed Description

template<typename Rep, uint32_t TB, typename Range = typename DefaultRange<Rep>::type, typename Forever = void*>
struct ble::Duration< Rep, TB, Range, Forever >

Model BLE durations.

Template Parameters:
RepThe representation type of the duration.
TBThe time base in micro seconds.
RangeClosed interval of the duration
ForeverThe special value (if applicable) that represents a forever duration.

Definition at line 100 of file Duration.h.


Member Typedef Documentation

typedef Rep representation_t

Type of the actual representation.

Definition at line 104 of file Duration.h.


Constructor & Destructor Documentation

Duration (  )

Construct a default Duration.

It is initialized with the minimum value acceptable.

Definition at line 111 of file Duration.h.

Duration ( Rep  v ) [explicit]

Construct a Duration from an integer value.

Parameters:
vThe value of the duration in TIME_BASE units.

Definition at line 120 of file Duration.h.

Duration ( Duration< OtherRep, OtherTB, OtherRange, OtherF >  other )

Construct a Duration from another Duration.

Note:
The operation fail at compile time if there is a loss of precision.
Template Parameters:
OtherRepThe type used to represent the other Duration.
OtherTBThe time base in micro seconds of the other Duration.
OtherRangeThe range of the other Duration.
OtherFThe forever value of the other type.
Parameters:
otherThe Duration used to construct this object.

Definition at line 137 of file Duration.h.

Duration ( Duration< OtherRep, 1000, OtherRange, OtherF >  other_ms,
void *  = NULL 
) [explicit]

Construct a new Duration from a Duration in milliseconds.

Note:
The result of the conversion is rounded up.
Template Parameters:
OtherRepThe representation type used by other_ms.
OtherRangeThe range used by other_ms.
OtherFThe forever value used by other_ms.
Parameters:
other_msThe Duration in millisecond to convert.

Definition at line 155 of file Duration.h.


Member Function Documentation

static Duration forever (  ) [static]

Return the Duration value meaning forever.

Returns:
the Duration value meaning forever.

Definition at line 229 of file Duration.h.

static Duration max (  ) [static]

Return the maximum duration.

Returns:
The maximum duration.

Definition at line 210 of file Duration.h.

static Duration min (  ) [static]

Return the minimum duration.

Returns:
The minimum duration.

Definition at line 200 of file Duration.h.

const Rep* storage (  ) const

Return a pointer to the value of the duration.

Returns:
a pointer to the value of the duration.

Definition at line 220 of file Duration.h.

Rep value (  ) const

Return the duration in TB units.

Returns:
The duration in TB units.

Definition at line 165 of file Duration.h.

uint32_t valueInMs (  ) const

Return the duration in milliseconds.

Returns:
The duration in milliseconds.

Definition at line 175 of file Duration.h.


Friends And Related Function Documentation

DurationOut durationCast ( Duration< RepIn, TBIn, RangeIn, FIn >  duration ) [related]

Cast a duration to another.

Template Parameters:
DurationOutType of the Duration in output.
RepInThe representation type of duration.
TBInThe timebase of duration.
RangeInThe range of duration.
FInThe Forever value of duration.
Parameters:
durationThe duration to convert.
Returns:
The converted duration. It is rounded up if precision is lost.

Definition at line 278 of file Duration.h.

bool operator!= ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Indicate if the duration lhs is not equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is not equal to rhs and false otherwise.

Definition at line 462 of file Duration.h.

bool operator!= ( Duration< Rep, Us, Range, F >  lhs,
Duration< Rep, Us, Range, F >  rhs 
) [related]

Indicate if the duration lhs is not equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is not equal to rhs and false otherwise.

Definition at line 479 of file Duration.h.

Duration< Rep, TB, Range, F > operator* ( Duration< Rep, TB, Range, F >  lhs,
uint32_t  rhs 
) [related]

Multiply a duration and a positive integer.

Parameters:
lhsThe duration.
rhsThe integer.
Returns:
A duration that represents the multiplication of lhs with rhs.

Definition at line 330 of file Duration.h.

Duration< Rep, TB, Range, F > operator* ( uint32_t  lhs,
Duration< Rep, TB, Range, F >  rhs 
) [related]

Multiply a duration and a positive integer.

Parameters:
lhsThe integer.
rhsThe multiplication.
Returns:
A duration that represents the multiplication of lhs with rhs.

Definition at line 346 of file Duration.h.

microsecond_t operator+ ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Add two durations together and return the result in microseconds.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
The result of the addition of the two durations in microseconds.

Definition at line 294 of file Duration.h.

Duration< Rep, TB, Range, F > operator+ ( Duration< Rep, TB, Range, F >  lhs,
Duration< Rep, TB, Range, F >  rhs 
) [related]

Add two durations together.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
The addition of the two durations in input.

Definition at line 311 of file Duration.h.

bool operator< ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Indicate if the duration lhs is less than the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is less than rhs and false otherwise.

Definition at line 363 of file Duration.h.

bool operator< ( Duration< Rep, Us, Range, F >  lhs,
Duration< Rep, Us, Range, F >  rhs 
) [related]

Indicate if the duration lhs is less than the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is less than rhs and false otherwise.

Definition at line 377 of file Duration.h.

bool operator<= ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Indicate if the duration lhs is less than or equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is less than or equal to rhs and false otherwise.

Definition at line 394 of file Duration.h.

bool operator<= ( Duration< Rep, Us, Range lhs,
Duration< Rep, Us, Range rhs 
) [related]

Indicate if the duration lhs is less than or equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is less than or equal to rhs and false otherwise.

Definition at line 411 of file Duration.h.

bool operator== ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Indicate if the duration lhs is equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is equal to rhs and false otherwise.

Definition at line 428 of file Duration.h.

bool operator== ( Duration< Rep, Us, Range, F >  lhs,
Duration< Rep, Us, Range, F >  rhs 
) [related]

Indicate if the duration lhs is equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is equal to rhs and false otherwise.

Definition at line 445 of file Duration.h.

bool operator> ( Duration< Rep, Us, Range, F >  lhs,
Duration< Rep, Us, Range, F >  rhs 
) [related]

Indicate if the duration lhs greater than the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is greater than rhs and false otherwise.

Definition at line 547 of file Duration.h.

bool operator> ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Indicate if the duration lhs greater than the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is greater than rhs and false otherwise.

Definition at line 530 of file Duration.h.

bool operator>= ( Duration< Rep, Us, Range, F >  lhs,
Duration< Rep, Us, Range, F >  rhs 
) [related]

Indicate if the duration lhs greater or equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is greater or equal to rhs and false otherwise.

Definition at line 513 of file Duration.h.

bool operator>= ( Duration< RepLHS, TBLHS, RangeLHS, FLHS >  lhs,
Duration< RepRHS, TBRHS, RangeRHS, FRHS >  rhs 
) [related]

Indicate if the duration lhs greater or equal to the duration rhs.

Parameters:
lhsLeft hand side operand.
rhsRight hand side operand.
Returns:
true if lhs is greater or equal to rhs and false otherwise.

Definition at line 496 of file Duration.h.


Field Documentation

const Rep MAX = Range::MAX [static]

Right bound of the duration range.

Definition at line 193 of file Duration.h.

const Rep MIN = Range::MIN [static]

Left-bound of the duration range.

Definition at line 188 of file Duration.h.

const uint32_t TIME_BASE = TB [static]

The time base.

Definition at line 183 of file Duration.h.