pianod2
multisource multiuser scriptable networked music player
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Tuner::Tuner Class Reference

Tuner maintains a set of playlists and their inclusion or exclusion from the current mix, and can push it to the sources on demand (before getting random songs); this allows multiple mixes to exist. More...

#include <tuner.h>

Inheritance diagram for Tuner::Tuner:
Inheritance graph
[legend]
Collaboration diagram for Tuner::Tuner:
Collaboration graph
[legend]

Classes

struct  Callbacks
 
struct  MixItem
 

Public Member Functions

virtual const Parsnip::Parser::DefinitionsgetParserDefinitions () override
 Retrieve the parser definitions handled by the interpreter. More...
 
 Tuner (PianodService *service)
 Create a new tuner and load known playlists. More...
 
 ~Tuner ()
 Destroy the tuner and release resources. More...
 
void updatePlaylists ()
 Update the list of playlists known by the tuner. More...
 
bool includedInMix (const PianodPlaylist *playlist)
 Check if a playlist is included in the mix. More...
 
SongList getRandomTracks (PianodPlaylist *from, const UserList &users)
 Acquire some random tracks utilizing the currently-selected randomization mode. More...
 
void purge (const Media::Source *const source)
 Remove a source from the playlist list in preparation for its removal. More...
 
void pushPlaylistSelections (Media::Source *const source=nullptr)
 Push the current playlist selections to the playlists/sources in preparation for getting random songs. More...
 
bool recalculatePlaylists ()
 Recalculate the playlists based on current users and autotune settings. More...
 
bool empty (const Media::Source *const source) const
 Check for enabled playlists in the mix. More...
 
bool automatic () const
 
void automatic (bool automatic_playlists)
 Set or clear automatic playlist selection. More...
 
UserList getAutotuneUsers () const
 Get a list of users to consider for autotuning with the current service and autotuning mode. More...
 
Response assembleStatus () const
 Send current state information. More...
 
- Public Member Functions inherited from PianodInterpreter
virtual void registerInterpreter (PianodDispatcher &dispatcher)
 Register the interpreter with a dispatcher. More...
 
const HelpList getHelp (const std::vector< std::string > &search, std::set< std::string > *option_parsers)
 Search the interpreter's definitions for any definitions matching search criteria. More...
 

Static Public Member Functions

static UserList getApplicableUsers (const AutotuneSettings &settings, const PianodService *service)
 Get a list of users applicable to autotuning. More...
 
- Static Public Member Functions inherited from PianodInterpreter
static bool optionIs (const Parsnip::Data &options, const char *name, const char *expected)
 Check if a string value exists and is case-blind equal to a particular value. More...
 
template<typename ValueType , typename LookupType >
static ValueType optionalValue (const Parsnip::Data &options, const char *name, const LookupType &lookup, const ValueType default_value)
 Retrieve the ID of a string value. More...
 

Public Attributes

CallbackManager< Tuner, Callbackscallback
 

Protected Member Functions

PianodPlaylistgetRandomPlaylist (const PianodPlaylist *criteria)
 Choose a random playlist (for mixing via playlist). More...
 

Private Types

using MixMap = std::unordered_map< std::string, MixItem >
 

Private Member Functions

virtual bool authorizedCommand (Parsnip::Parser::CommandId command, PianodConnection &conn) override
 Check whether a command is authorized. More...
 
virtual ResponseCollector handleCommand (Parsnip::Parser::CommandId command, const Parsnip::Data &options, PianodConnection &conn) override
 Command handler. More...
 
void sourcesChanged (const Media::Source *const)
 Register a new source by adding its playlists to those known. More...
 

Private Attributes

PianodServiceservice
 
MixMap mix
 
bool automatic_mode = false
 
bool anyone_listening = false
 
Media::SelectionMethod random_selection_method = Media::SelectionMethod::Song
 
AutotuneSettings autotune
 

Additional Inherited Members

- Public Types inherited from PianodInterpreter
using HelpList = PianodDispatcher::HelpList
 
- Protected Types inherited from PianodInterpreter
using StringVector = std::vector< std::string >
 
- Static Protected Attributes inherited from PianodInterpreter
static const Parsnip::Data EmptyDictionary {Parsnip::Data::Dictionary}
 An empty dictionary, often used as a default with Parsnip::Data::getOr. More...
 
static const StringVector EmptyStringVector
 An empty string vector, often used as a default with Parsnip::Data::getOr. More...
 

Detailed Description

Tuner maintains a set of playlists and their inclusion or exclusion from the current mix, and can push it to the sources on demand (before getting random songs); this allows multiple mixes to exist.

The tuner also performs autotuning (automatic playlist selection).

Member Typedef Documentation

◆ MixMap

using Tuner::Tuner::MixMap = std::unordered_map<std::string, MixItem>
private

Constructor & Destructor Documentation

◆ Tuner()

Tuner::Tuner::Tuner ( PianodService svc)

Create a new tuner and load known playlists.

Parameters
svcThe service with which the tuner will be associated.

◆ ~Tuner()

Tuner::Tuner::~Tuner ( )

Destroy the tuner and release resources.

Member Function Documentation

◆ assembleStatus()

Response Tuner::Tuner::assembleStatus ( ) const

Send current state information.

Here is the caller graph for this function:

◆ authorizedCommand()

bool Tuner::Tuner::authorizedCommand ( Parsnip::Parser::CommandId  command_id,
PianodConnection context 
)
overrideprivatevirtual

Check whether a command is authorized.

Parameters
command_idThe command requesting execution.
contextConnection details, including authentication state and privileges.
Returns
True if allowed, false otherwise.

Implements PianodInterpreter.

Here is the call graph for this function:

◆ automatic() [1/2]

bool Tuner::Tuner::automatic ( ) const
inline
Here is the caller graph for this function:

◆ automatic() [2/2]

void Tuner::Tuner::automatic ( bool  automatic_playlists)

Set or clear automatic playlist selection.

Parameters
automatic_playlistsTrue to enable, false otherwise.

◆ empty()

bool Tuner::Tuner::empty ( const Media::Source *const  source) const

Check for enabled playlists in the mix.

Parameters
sourceIf not-null, consider only playlists from specified source.
Returns
True if no matching enabled playlists are found, false otherwise.
Here is the caller graph for this function:

◆ getApplicableUsers()

UserList Tuner::Tuner::getApplicableUsers ( const AutotuneSettings settings,
const PianodService service 
)
static

Get a list of users applicable to autotuning.

Parameters
settingsThe autotuning mode settings.
serviceThe football service to search for user logins.
Returns
A list of users matching the autotune settings.
Here is the call graph for this function:

◆ getAutotuneUsers()

UserList Tuner::Tuner::getAutotuneUsers ( ) const

Get a list of users to consider for autotuning with the current service and autotuning mode.

Here is the caller graph for this function:

◆ getParserDefinitions()

const Parsnip::Parser::Definitions & Tuner::Tuner::getParserDefinitions ( )
overridevirtual

Retrieve the parser definitions handled by the interpreter.

Returns
Parser definitions.

Implements PianodInterpreter.

Here is the call graph for this function:

◆ getRandomPlaylist()

PianodPlaylist * Tuner::Tuner::getRandomPlaylist ( const PianodPlaylist criteria)
protected

Choose a random playlist (for mixing via playlist).

Parameters
criteriaSpecifies which playlists to choose from: which source, and single, mix, everything.
Returns
The single playlist chosen.
Here is the call graph for this function:

◆ getRandomTracks()

SongList Tuner::Tuner::getRandomTracks ( PianodPlaylist from,
const UserList users 
)

Acquire some random tracks utilizing the currently-selected randomization mode.

Parameters
fromA playlist or a metaplaylist from which to choose music.
usersThe users present, for biasing selections.
Returns
Some random tracks for play.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleCommand()

ResponseCollector Tuner::Tuner::handleCommand ( Parsnip::Parser::CommandId  command_id,
const Parsnip::Data parameters,
PianodConnection context 
)
overrideprivatevirtual

Command handler.

Parameters
command_idCommand to execute.
parametersCommand parameters.
contextConnection details, including authentication state and privileges.
Returns
Data or success/failure indications.
Exceptions
CommandErroror other exception if an error occurs.

Implements PianodInterpreter.

Here is the call graph for this function:

◆ includedInMix()

bool Tuner::Tuner::includedInMix ( const PianodPlaylist playlist)

Check if a playlist is included in the mix.

Parameters
playlistThe playlist whose status to check.
Returns
True if the playlist is in the mix, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ purge()

void Tuner::Tuner::purge ( const Media::Source *const  source)

Remove a source from the playlist list in preparation for its removal.

◆ pushPlaylistSelections()

void Tuner::Tuner::pushPlaylistSelections ( Media::Source *const  source = nullptr)

Push the current playlist selections to the playlists/sources in preparation for getting random songs.

Parameters
sourceIf null, pushes all playlists. Otherwise, only pushes those belonging to the source.

◆ recalculatePlaylists()

bool Tuner::Tuner::recalculatePlaylists ( )

Recalculate the playlists based on current users and autotune settings.

Returns
true if playlists changed, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sourcesChanged()

void Tuner::Tuner::sourcesChanged ( const Media::Source * const  )
private

Register a new source by adding its playlists to those known.

◆ updatePlaylists()

void Tuner::Tuner::updatePlaylists ( )

Update the list of playlists known by the tuner.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ anyone_listening

bool Tuner::Tuner::anyone_listening = false
private

◆ automatic_mode

bool Tuner::Tuner::automatic_mode = false
private

◆ autotune

AutotuneSettings Tuner::Tuner::autotune
private

◆ callback

CallbackManager<Tuner, Callbacks> Tuner::Tuner::callback

◆ mix

MixMap Tuner::Tuner::mix
private

◆ random_selection_method

Media::SelectionMethod Tuner::Tuner::random_selection_method = Media::SelectionMethod::Song
private

◆ service

PianodService* Tuner::Tuner::service
private

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