BufferFilter.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Crosswalk team
00004 //
00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.  
00006 // Use of this software is subject to the terms of the Autodesk license agreement 
00007 // provided at the time of installation or download, or which otherwise accompanies 
00008 // this software in either electronic or hard copy form.
00009 //
00010 //***************************************************************************************
00011 
00012 #ifndef _BUFFERFILTER_H_
00013 #define _BUFFERFILTER_H_
00014 
00015 #include <SIBCUtil.h>
00016 #include <SIBCString.h>
00017 
00018 #include "CXSIFilter.h"
00019 
00020 #define BUFFER_FILTER_NAME  "Buffer"
00021 #define BUFFER_FILTER_ID        "buf"
00022 
00023 #ifdef  _PSX2
00024 #define BUFFER_SIZE             (32 * 1024)
00025 #else
00026 #define BUFFER_SIZE             (128 * 1024)
00027 #endif
00029 /* 
00030 * This class will gather up to a certain size of data until it calls its subfilter to
00031 * write or it will read up to a certain size in one go and answer to request until it
00032 * has exhausted the data at which point it will ask its subfilter for more data.
00033 */
00034 class CBufferFilter : public CXSIFilter
00035 {
00036 public:
00040     CBufferFilter();
00044     virtual ~CBufferFilter();
00045 
00050     int Open ( CSIBCString in_szFilename,  _SI_FILE_MODE in_Mode );
00053     int Close ();
00054     
00060     int Read ( SI_Char * out_pBuffer, SI_Long in_lSize );
00066     int Write( SI_Char * in_pBuffer,  SI_Long in_lSize );
00067 
00068 
00072     int Eof();
00076     int Tell();
00077 
00078 
00079 
00080 private:
00081     void    Flush();
00082     void    FillBuffer();
00083 
00084     char    *m_pBuffer;
00085     LONG    m_lPosition;
00086     SI_Long m_lSizeRead;
00087     bool    m_bHeaderSkipped;
00088 };
00089 
00090 #endif