inLimbo
TUI Music Player that keeps you in Limbo.
 
Loading...
Searching...
No Matches
SongTree Class Reference

Represents a hierarchical tree structure to store songs by artist, album, disc number, and track number. More...

#include <songmap.hpp>

Public Member Functions

void addSong (const Song &song)
 Adds a song to the tree.
 
void display () const
 Displays all songs in the tree hierarchically.
 
std::vector< SonggetSongsByArtist (const std::string &artist) const
 Retrieves all songs by a specific artist.
 
std::vector< SonggetSongsByAlbum (const std::string &artist, const std::string &album) const
 Retrieves all songs from a specific album by a given artist.
 
std::map< std::string, std::map< std::string, std::map< unsigned int, std::map< unsigned int, Song > > > > returnSongMap ()
 Returns the internal song map.
 
template<class Archive>
void serialize (Archive &ar)
 Serializes the SongTree object.
 
void saveToFile (const std::string &filename) const
 Saves the SongTree to a file.
 
void loadFromFile (const std::string &filename)
 Loads a SongTree from a file.
 

Detailed Description

Represents a hierarchical tree structure to store songs by artist, album, disc number, and track number.

The SongTree class organizes songs in a map structure where the keys are artist names, album titles, disc numbers, and track numbers. The tree structure allows for easy retrieval of songs by artist, album, and track number. Songs can be added to the tree, displayed, and serialized or deserialized from a file.

Member Function Documentation

◆ addSong()

void SongTree::addSong ( const Song & song)
inline

Adds a song to the tree.

This function inserts a Song into the appropriate location in the tree based on its artist, album, disc number, and track number.

Parameters
songThe song to be added to the tree.

◆ display()

void SongTree::display ( ) const
inline

Displays all songs in the tree hierarchically.

This function prints the entire song tree to the console in a human-readable format, displaying the artist, album, disc number, track number, title, and other metadata for each song.

◆ getSongsByAlbum()

std::vector< Song > SongTree::getSongsByAlbum ( const std::string & artist,
const std::string & album ) const
inline

Retrieves all songs from a specific album by a given artist.

This function returns a vector of all songs from a particular album by an artist.

Parameters
artistThe name of the artist whose album's songs are to be retrieved.
albumThe title of the album whose songs are to be retrieved.
Returns
A vector of Song objects from the specified album by the specified artist.

◆ getSongsByArtist()

std::vector< Song > SongTree::getSongsByArtist ( const std::string & artist) const
inline

Retrieves all songs by a specific artist.

This function returns a vector of all songs by a given artist, organized by album, disc number, and track number.

Parameters
artistThe name of the artist whose songs are to be retrieved.
Returns
A vector of Song objects by the specified artist.

◆ loadFromFile()

void SongTree::loadFromFile ( const std::string & filename)
inline

Loads a SongTree from a file.

This function loads the serialized SongTree object from a binary file.

Parameters
filenameThe name of the file to load the SongTree from.
Exceptions
std::runtime_errorIf the file cannot be opened for loading.

◆ returnSongMap()

std::map< std::string, std::map< std::string, std::map< unsigned int, std::map< unsigned int, Song > > > > SongTree::returnSongMap ( )
inline

Returns the internal song map.

This function returns the entire nested map structure containing all the songs.

Returns
The nested map structure of songs.

◆ saveToFile()

void SongTree::saveToFile ( const std::string & filename) const
inline

Saves the SongTree to a file.

This function saves the serialized SongTree object to a binary file.

Parameters
filenameThe name of the file to save the SongTree to.
Exceptions
std::runtime_errorIf the file cannot be opened for saving.

◆ serialize()

template<class Archive>
void SongTree::serialize ( Archive & ar)
inline

Serializes the SongTree object.

This function serializes the SongTree object into a binary format for storage or transmission.

Parameters
arThe archive object used for serialization.

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