/*
 * cdda_conf.h: The music playlist manager
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: cdda_playlist.h,v 1.1.1.2 2005/06/27 13:34:02 cm Exp $
 */

#ifndef __CDDAPLAYLIST_H
#define __CDDAPLAYLIST_H

#include <vdr/tools.h>
#include "cdda_lib.h"

enum ePlaylistType { ptSingle, ptAll , ptProgram };

class cCddaPlaylistItem : public cListObject {
  private:
    unsigned char key;
    cCddaPlaylistItem *prev, *next;
  public:
    cCddaPlaylistItem(unsigned char Key = 0);
    ~cCddaPlaylistItem();
    unsigned char GetKey(void) { return key; };
    unsigned char SetKey(unsigned char key);
    cCddaPlaylistItem *Prev(void) const { return prev; }
    cCddaPlaylistItem *Next(void) const { return next; }
};

class cCddaPlaylist : private cList<cCddaPlaylistItem> , public cReferenceCounter {
  private:
    ePlaylistType playlistType;
    cCddaPlaylistItem *po_currentItem;
  public:
    cCddaPlaylist();
    ~cCddaPlaylist();
    cCddaPlaylistItem *Previous(cCddaPlaylistItem *item = NULL, bool set = false);
    cCddaPlaylistItem *Next(cCddaPlaylistItem *item = NULL, bool set = false);
    bool SetCurrent(int index);
    cCddaPlaylistItem *GetCurrent(void);
    cCddaPlaylistItem *First(void) { return cList<cCddaPlaylistItem>::First(); };
    cCddaPlaylistItem *Last(void) { return cList<cCddaPlaylistItem>::Last(); };
    cCddaPlaylistItem *Get(int index) { return cList<cCddaPlaylistItem>::Get(index); };
    cCddaPlaylistItem *GetByKey(unsigned int key);
    int GetNumTracks(void) { return cList<cCddaPlaylistItem>::Count(); };
    cCddaPlaylistItem *Add(void);
    bool Remove(int index);
    void Clear(void);
    bool Load(unsigned int start, unsigned int first, unsigned int last);
    ePlaylistType GetType(void) { return playlistType; };
    ePlaylistType SetType(ePlaylistType type);
};

#endif
