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

A class to average ratings. More...

#include <ratings.h>

Public Member Functions

void add (Rating rating)
 Add mote data to the average. More...
 
float operator() (Rating default_value=Rating::UNRATED)
 Return the average as a star-rating float. More...
 
double rating (Rating default_value=Rating::UNRATED)
 Return the average as a rating-range double. More...
 
unsigned sum () const
 Retrieve the sum of the ratings in the average. More...
 
unsigned items () const
 Retrieve the number of items included in the average. More...
 

Private Attributes

unsigned count = 0
 Number of ratings being averaged. More...
 
unsigned total = 0
 Total of enumeration values being averaged. More...
 

Detailed Description

A class to average ratings.

Member Function Documentation

◆ add()

void RatingAverager::add ( Rating  rating)
inline

Add mote data to the average.

Parameters
ratingThe rating to add. If UNRATED, the rating is ignored.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ items()

unsigned RatingAverager::items ( ) const
inline

Retrieve the number of items included in the average.

Here is the caller graph for this function:

◆ operator()()

float RatingAverager::operator() ( Rating  default_value = Rating::UNRATED)
inline

Return the average as a star-rating float.

Parameters
default_valueValue to return if no values were included in the average.
Returns
A floating point average in the star-rating range.
Here is the call graph for this function:

◆ rating()

double RatingAverager::rating ( Rating  default_value = Rating::UNRATED)
inline

Return the average as a rating-range double.

Parameters
default_valueValue to return if no values were included in the average.
Returns
A floating point average across the ratings enumeration values.
Here is the caller graph for this function:

◆ sum()

unsigned RatingAverager::sum ( ) const
inline

Retrieve the sum of the ratings in the average.

Here is the caller graph for this function:

Member Data Documentation

◆ count

unsigned RatingAverager::count = 0
private

Number of ratings being averaged.

◆ total

unsigned RatingAverager::total = 0
private

Total of enumeration values being averaged.


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