/*
 * class VideoReader
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef VIDEO_READER_HH__
#define VIDEO_READER_HH__

#include "WImage/VideoFile.hh"
#include <fstream>

/** 
 * @addtogroup WImage 
 * @{ */

/**
 * An abstract color video reader. The video is being read putting its 
 * color channels into separate greyscale video objects. 
 */
/*abstract*/
class 
VideoReader: public VideoFile
{
public:
  
  /** Constructor. Only calls the mother class' constructor to initialize
   * the {\em ImageArray} reference. 
   * @param name
   * the file name
   * @param arrays
   * the array of video arrays for the values 
   * @param channels
   * the number of colors 
   * @param from the first frame 
   * @param to the last frame */
  VideoReader (char const *name, VideoArray < coeff > *arrays[], 
               int channels, int from, int to) 
    : VideoFile (name, arrays, channels, to - from) {m_to = to; m_from = from;}

  /** Destructor - does nothing. */
  virtual ~VideoReader (void) {}

  /** Read the video . All steps independent of the file format will be 
   * performed, like testing for file readability etc. 
   * @exception invalid_argument
   * invalid file format
   * @exception ios_base::failure
   * a read error has occured [not supported by all libraries, so eventually 
   * {\em invalid_argument} instead] */
  virtual void read (void);

protected:
  /** Read different file formats (abstract). This is the method to be 
   * implemented for every video file format. It will be called by the
   * {\em read ()} method. 
   * @return 
   * 0 if successful, -1 on read error, -2 on file format error. */
  virtual int readfmt (void) = 0;

  /** the last frame */
  int m_to;
  /** the first frame */
  int m_from;
  
}; /* class VideoReader */

/** @} */

#endif /* VIDEO_READER_HH__ */
