www.pudn.com > MPEG2systemsrc.rar > OPortToFile.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.
*/

/* OPortToFile is an OutputPort that puts bits to a file */
#ifndef oporttofile_h
#define oporttofile_h

#include "OutputPort.H"

// FIX -- CacheSize should be a parameter to the OPortToFile constructor
#define CacheSize 4096

extern "C"
{
#include 
#include 
}

class OPortToFile: public OutputPort
{
public:
  OPortToFile (char*, int);
  virtual ~OPortToFile();
protected:
  virtual void output_bit (char);
  virtual void output_byte (char);
  virtual void output_flush ();
private:
  char buf[8];
  int next_out;
  int fd;
  char	fbuf[CacheSize];
  int   flen;
  int   bufpos;
  void output_byte ();
};

/*
 DOCUMENTATION

 OPortToFile is a subclass of OutputPort.  It provides implementations
 for the three virtual funtions output_bit, output_byte and
 output_flush and, except for constructors, its public interface is
 inherited from the base class.  

 File writes are cached to improve performance.  The current cache size
 is set in the code to 4096.

 Public methods are:

  OPortToFile (char*, int);
    The second (integer) parameter is the text_flag. When set to true
    the port will output char's '0' and '1'.  This is useful for
    debugging.
*/

#endif