SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Attributes | Friends | List of all members
LimitedCounter< StoreType, Limit > Class Template Reference

#include <limitedcounter.h>

Public Member Functions

 LimitedCounter ()
 
 LimitedCounter (StoreType value)
 
void operator= (const LimitedCounter &rhs)
 
LimitedCounteroperator++ ()
 
LimitedCounter operator++ (int)
 
LimitedCounteroperator+= (const uint32_t rhs)
 
StoreType value () const
 

Private Attributes

StoreType m_counter
 

Friends

LimitedCounter operator- (const LimitedCounter lhs, const LimitedCounter &rhs)
 

Detailed Description

template<typename StoreType, uint32_t Limit>
class LimitedCounter< StoreType, Limit >

Definition at line 24 of file limitedcounter.h.

Constructor & Destructor Documentation

◆ LimitedCounter() [1/2]

template<typename StoreType , uint32_t Limit>
LimitedCounter< StoreType, Limit >::LimitedCounter ( )
inline

Definition at line 27 of file limitedcounter.h.

27  :
28  m_counter(0)
29  {}
StoreType m_counter

◆ LimitedCounter() [2/2]

template<typename StoreType , uint32_t Limit>
LimitedCounter< StoreType, Limit >::LimitedCounter ( StoreType  value)
inline

Definition at line 31 of file limitedcounter.h.

31  :
32  m_counter(value < Limit ? value : Limit - 1)
33  {}
StoreType value() const
StoreType m_counter

Member Function Documentation

◆ operator++() [1/2]

template<typename StoreType , uint32_t Limit>
LimitedCounter& LimitedCounter< StoreType, Limit >::operator++ ( )
inline

Definition at line 39 of file limitedcounter.h.

References LimitedCounter< StoreType, Limit >::m_counter.

39  {
40  m_counter++;
41  if (m_counter >= Limit) {
42  m_counter = 0;
43  }
44  return *this;
45  }
StoreType m_counter

◆ operator++() [2/2]

template<typename StoreType , uint32_t Limit>
LimitedCounter LimitedCounter< StoreType, Limit >::operator++ ( int  )
inline

Definition at line 47 of file limitedcounter.h.

References LimitedCounter< StoreType, Limit >::m_counter.

47  {
48  LimitedCounter temp = *this ;
49  m_counter++;
50  if (m_counter >= Limit) {
51  m_counter = 0;
52  }
53  return temp;
54  }
StoreType m_counter

◆ operator+=()

template<typename StoreType , uint32_t Limit>
LimitedCounter& LimitedCounter< StoreType, Limit >::operator+= ( const uint32_t  rhs)
inline

Definition at line 56 of file limitedcounter.h.

References LimitedCounter< StoreType, Limit >::m_counter.

56  {
57  m_counter += rhs;
58  if (m_counter >= Limit) {
59  m_counter -= Limit;
60  }
61  return *this;
62  }
StoreType m_counter

◆ operator=()

template<typename StoreType , uint32_t Limit>
void LimitedCounter< StoreType, Limit >::operator= ( const LimitedCounter< StoreType, Limit > &  rhs)
inline

Definition at line 35 of file limitedcounter.h.

References LimitedCounter< StoreType, Limit >::m_counter.

35  {
36  m_counter = rhs.m_counter;
37  }
StoreType m_counter

◆ value()

template<typename StoreType , uint32_t Limit>
StoreType LimitedCounter< StoreType, Limit >::value ( ) const
inline

Definition at line 64 of file limitedcounter.h.

References LimitedCounter< StoreType, Limit >::m_counter.

64 { return m_counter; }
StoreType m_counter

Friends And Related Function Documentation

◆ operator-

template<typename StoreType , uint32_t Limit>
LimitedCounter operator- ( const LimitedCounter< StoreType, Limit >  lhs,
const LimitedCounter< StoreType, Limit > &  rhs 
)
friend

Definition at line 66 of file limitedcounter.h.

67  {
68  LimitedCounter result;
69 
70  if (lhs.m_counter < rhs.m_counter) {
71  result.m_counter = Limit - lhs.m_counter + rhs.m_counter + 1;
72  } else {
73  result.m_counter = lhs.m_counter - rhs.m_counter;
74  }
75 
76  return result;
77  }
StoreType m_counter

Member Data Documentation

◆ m_counter

template<typename StoreType , uint32_t Limit>
StoreType LimitedCounter< StoreType, Limit >::m_counter
private

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