/*
 * (c) 2005 Research Group Dr. Fuhrmann, University of Karlsruhe, Germany
 * All rights reserved.
 *
 * Author:
 *         Roman Krenicky
 *
 * $Id: vdrepg_interface.h,v 1.12 2005/11/23 17:51:35 kutzner Exp $
 *
 */

/*
  vdrepg_interface.h
  created: 1.12.2004
  last change: 9.7.2005
*/
/*! @file
    interface to the EPG data of the (main) vdr
*/

#ifndef _VDREPG_INTERFACE_H
#define _VDREPG_INTERFACE_H

#include "globalheader.h"

#include <list>
#include <epg.h>
#include "epgtypes.h"
#include "blockentry.h"
extern "C"
{
  #include <time.h>
}


/*! provides the plugin with access to the EPG database of the vdr
*/
class vdrepg_interface
{
  private:
   time_t block_starttime (time_t time, time_t some_starttime,
                           time_t block_size);
   bool incomplete_block (const cEvent **event, time_t from, time_t block_size,
                          time_t hole_size, float min_coverage);
   const cEvent* pick_random_block (const cSchedules *schedules,
                                    time_t block_size, blockentry *block,
                                    const cSchedule **schedulepp);
   void dump_epgdata (epgdata *data, const cEvent *event, time_t to);


  public:
   vdrepg_interface (void);
   ~vdrepg_interface (void);
   epgdata* get_epg (const epgchannel &channel, time_t from, time_t to,
                     bool complete_only=true, time_t hole_size=0,
                     float min_coverage=1);
   bool put_epg (const epgchannel &channel, const epgdata &data,
                 bool *isnew=NULL);
   epgdata* get_next_complete_block (const blockentry &last, time_t block_size,
                                     blockentry *next,
                                     time_t hole_size, float min_coverage);
   bool block_is_incomplete (const epgchannel &channel, time_t from,
                             time_t block_size,
                             time_t hole_size, float min_coverage);
   list<blockentry>* get_incomplete_blocks (time_t from, time_t block_size,
                                        unsigned int block_count,
                                        time_t hole_size, float min_coverage);
   bool channel_is_present (const epgchannel &channel);
   list<epgchannel>* get_channels (void);
}; // vdrepg_interface


#endif // _VDREPG_INTERFACE_H
