pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Pandora::SkipTracker Class Reference

A class to manage Pandora skips. More...

#include <pandorastation.h>

Inheritance diagram for Pandora::SkipTracker:
Inheritance graph
[legend]
Collaboration diagram for Pandora::SkipTracker:
Collaboration graph
[legend]

Public Member Functions

 SkipTracker (int limit, int interv)
 Construct a skip tracker. More...
 
bool canSkip (time_t *when)
 Check if (and when) a skip is available. More...
 
bool skip (time_t *when=nullptr)
 Check if a skip is available, and record one if it is. More...
 
void setLimit (int limit)
 

Private Member Functions

void purge ()
 Remove expired skips from the front of the list. More...
 

Private Attributes

size_t skip_limit
 The limit on the number of skips. More...
 
time_t interval
 The duration over which the limit applies. More...
 

Detailed Description

A class to manage Pandora skips.

Constructor & Destructor Documentation

◆ SkipTracker()

Pandora::SkipTracker::SkipTracker ( int  limit,
int  interv 
)

Construct a skip tracker.

The tracker is a simple linked list.

When a skip occurs, the time of its expiration is added to the list. When checks are done, the front time is checked; if that time is past, it is removed. Skips are allowed when the size of the list is below the skip limit.

Parameters
limitThe number of skips to allow.
intervThe duration over which the limit applies.

Member Function Documentation

◆ canSkip()

bool Pandora::SkipTracker::canSkip ( time_t *  when)

Check if (and when) a skip is available.

Parameters
whenIf non-null, is set on return to the time at which the next skip is allowed.
Returns
True if a skip is allowed, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ purge()

void Pandora::SkipTracker::purge ( void  )
inlineprivate

Remove expired skips from the front of the list.

Here is the caller graph for this function:

◆ setLimit()

void Pandora::SkipTracker::setLimit ( int  limit)
inline
Here is the caller graph for this function:

◆ skip()

bool Pandora::SkipTracker::skip ( time_t *  when = nullptr)

Check if a skip is available, and record one if it is.

Parameters
whenIf non-null, is set on return to the time at which the next skip is allowed.
Returns
True if a skip happened, false if it was not allowed.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ interval

time_t Pandora::SkipTracker::interval
private

The duration over which the limit applies.

◆ skip_limit

size_t Pandora::SkipTracker::skip_limit
private

The limit on the number of skips.


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