www.pudn.com > MPEG2systemsrc.rar > IPortFromFile.H
/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved.
*
* Usage Restrictions
*
* License is granted to copy, to use, and to make and to use derivative
* works for research and evaluation purposes only.
*
* Disclaimer of Warranty
*
* These software programs are available to the user without any license
* fee or royalty on an "as is" basis. Tektronix Inc. disclaims any and
* all warranties, whether express, implied, or statuary, including any
* implied warranties or merchantability or of fitness for a particular
* purpose. In no event shall the copyright-holder be liable for any
* incidental, punitive, or consequential damages of any kind whatsoever
* arising from the use of these programs.
*
* This disclaimer of warranty extends to the user of these programs and
* user's customers, employees, agents, transferees, successors, and
* assigns.
*
* The Tektronix Inc. does not represent or warrant that the programs
* furnished hereunder are free of infringement of any third-party
* patents.
*/
/* IPortFromFile is an InputPort that reads from a file */
#ifndef iportfromfile_h
#define iportfromfile_h
#include "InputPort.H"
// FIX -- CacheSize should be specified in the constructor call.
#define CacheSize 4096
#define CYCLE 1
#define NOCYCLE 2
class IPortFromFile : public InputPort
{
public:
IPortFromFile (char*, int);
protected:
virtual char input_bit ();
virtual char input_byte ();
private:
int cycle_flag;
char* file_name;
int fd;
char fbuf[CacheSize];
int flen;
int bufpos;
char byte;
int pos;
int inc_bit ();
char bit2char ();
};
/*
DOCUMENTATION
IPortFromFile is a subclass of InputPort. It provides
implementations for the two virtual funtions input_bit and input_byte
and, except for constructors, its public interface is inherited from
the base class. The port can be used in a CYCLE or NOCYCLE modes.
When in CYCLE mode the port will loop back to the beginning of the
file when the EOF is encountered, thus providing a ongoing stream of
bits. When in NOCYCLE mode the port will call sys_halt when the EOF
is reached.
File reads are cached to improve performance. The current cache size
is set in the code to 4096.
Public methods are:
IPortFromFile (char*, int);
The second (integer) parameter is the cycle flag (either CYCLE or
NOCYCLE).
*/
#endif