code::ProgressiveReader Class Reference

Inheritance diagram for code::ProgressiveReader:

code::CompleteFileReader code::ProgressiveFileReader List of all members.

Detailed Description

This interface allows for reading a file as it is arriving.

Author:
Lakshman
Version:
Id
code_ProgressiveReader.h,v 1.6 2009/06/02 20:17:39 lakshman Exp
See also:
ProgressiveFileReader

CompressedFileReader


Public Member Functions

 ProgressiveReader (const URL &url)
virtual ~ProgressiveReader ()
virtual bool readNext (Buffer *dataBuf, size_t *bytes_read)=0
 Progressive readers, on successive calls to this method will read further and further into the file.

Static Public Member Functions

static SmartPtr< ProgressiveReadergetReader (const URL &url)
 return a ProgressiveReader that can handle this file.

Protected Attributes

URL url


Constructor & Destructor Documentation

code::ProgressiveReader::ProgressiveReader ( const URL url  ) 

virtual code::ProgressiveReader::~ProgressiveReader (  )  [inline, virtual]


Member Function Documentation

static SmartPtr<ProgressiveReader> code::ProgressiveReader::getReader ( const URL url  )  [static]

return a ProgressiveReader that can handle this file.

Currently, the implementation assumes that if a file is compressed, it should be read using the CompleteFileReader else using the ProgressiveFileReader.

virtual bool code::ProgressiveReader::readNext ( Buffer dataBuf,
size_t *  bytes_read 
) [pure virtual]

Progressive readers, on successive calls to this method will read further and further into the file.

Parameters:
dataBuf the Buffer to be modified with this method call dataBuf should be initialized to a reasonable size e.g: 1MB
bytes_read will be filled in with the number of bytes of dataBuf that have been filled in.
Returns:
isComplete whether or not this method should be called again to get more data
Example code:
    size_t tot_bytes = 0;

read the file ...
    bool complete = false;
    do {
read bytes
      size_t bytes_read = 0;
      complete = reader->readNext( &dataBuf , &bytes_read );

notify handlers
      if ( bytes_read > 0 ){
do something with the data
      }

update running total
      tot_bytes += bytes_read;
    } while ( !complete );
  }
do something with tot_bytes
  

Note that if the file is being filled in (in real-time), even if the readNext returns complete on one call, a subsequent call may return valid data (more data may have arrived in the intermediate time). Knowledge of when the file is complete is external, such as through knowing the file format.

Implemented in code::ProgressiveFileReader, and code::CompleteFileReader.


Member Data Documentation

URL code::ProgressiveReader::url [protected]


Generated on Fri May 4 13:40:13 2012 for WDSS-IIw2 by  doxygen 1.4.7