Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
Lollipop Class Reference

Increment administration object with 'none' value default. More...

#include <cs_Lollipop.h>

Public Member Functions

 Lollipop (uint16_t m)
 
 Lollipop (uint16_t v, uint16_t m)
 
 Lollipop (const Lollipop &l)=default
 
bool operator< (const Lollipop &other)
 
Lollipopoperator++ ()
 
Lollipop operator++ (int)
 

Static Public Member Functions

static uint16_t next (uint16_t currentValue, uint16_t maxValue)
 Return the next value given the current value. More...
 
static bool isNewer (uint16_t previousValue, uint16_t currentValue, uint16_t maxValue)
 Returns true when current value is newer than previous value. More...
 

Private Attributes

uint16_t val
 
uint16_t max
 

Detailed Description

Increment administration object with 'none' value default.

Once operator ++ is called, this->val will never be equal to 0 again.

Lollipop will roll over after max value.

uint8_t max = 10; Lollipop l(max); Lollipop r(max);

if r.max != l.max, false is returned. if r.val and l.val are in range [1,..max], the expression l < r is true iff. r.val is in the range [(l.val+1)max, ..., (l.val+max/2) max]

else, if l.val == 0, l<r is true else, if r.val == 0, l<r is false.

E.g.

Lollipop(8,10) < Lollipop(

Warning: max == 0, 1 and 255 don't work as expected.

Constructor & Destructor Documentation

◆ Lollipop() [1/3]

Lollipop::Lollipop ( uint16_t  m)
inline

◆ Lollipop() [2/3]

Lollipop::Lollipop ( uint16_t  v,
uint16_t  m 
)
inline

◆ Lollipop() [3/3]

Lollipop::Lollipop ( const Lollipop l)
default

Member Function Documentation

◆ isNewer()

static bool Lollipop::isNewer ( uint16_t  previousValue,
uint16_t  currentValue,
uint16_t  maxValue 
)
inlinestatic

Returns true when current value is newer than previous value.

This is always false when currentValue is 0. This is true when previousValue is 0.

◆ next()

static uint16_t Lollipop::next ( uint16_t  currentValue,
uint16_t  maxValue 
)
inlinestatic

Return the next value given the current value.

Rolls over at maxValue and skips 0.

◆ operator++() [1/2]

Lollipop & Lollipop::operator++ ( )
inline

◆ operator++() [2/2]

Lollipop Lollipop::operator++ ( int  )
inline

◆ operator<()

bool Lollipop::operator< ( const Lollipop other)
inline

Member Data Documentation

◆ max

uint16_t Lollipop::max
private

◆ val

uint16_t Lollipop::val
private

The documentation for this class was generated from the following file: