/*
 * castreader.c: a class that reads cast from database
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */
#include "castreader.h"
#include "tools.h"

static char sqlCast[] = "SELECT vdr_Type.name role, vdr_Person.firstname, "
	"vdr_Person.name FROM vdr_Cast LEFT JOIN vdr_Type ON vdr_Cast.role=vdr_Type.rowid "
	"LEFT JOIN vdr_Person ON vdr_Cast.person=vdr_Person.rowid WHERE vdr_Cast.Media=%d";


cCastReader::cCastReader(int media)
{_ 
  asprintf(&sql, sqlCast, media);
  Init();
}

cCastReader::~cCastReader() 
{_
  SLDEBUG("# destructor of cCastReader");
  free(sql);
}

cMenuCastItem * cCastReader::Read()
{_
  cMenuCastItem * pGI = new cMenuCastItem();
  cDataInfo	DatInf[] = {
	  { cDataInfo::TEXT, (char *)&(pGI->role) - (char *)pGI },
	  { cDataInfo::TEXT, (char *)&(pGI->fname) - (char *)pGI },
	  { cDataInfo::TEXT, (char *)&(pGI->name) - (char *)pGI },
	  { cDataInfo::UNKNOWN, 0 }
     };
  return Super::Read(pGI, DatInf);	
}
