code::ProgressiveFileReader Class Reference

Inheritance diagram for code::ProgressiveFileReader:

code::ProgressiveReader List of all members.

Detailed Description

Implements the ProgressiveReader interface on local files.

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


Public Member Functions

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

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::ProgressiveFileReader::ProgressiveFileReader ( const URL url  ) 

virtual code::ProgressiveFileReader::~ProgressiveFileReader (  )  [virtual]


Member Function Documentation

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

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::ProgressiveFileReader::readNext ( Buffer dataBuf,
size_t *  bytes_read 
) [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.

Implements code::ProgressiveReader.


Member Data Documentation

URL code::ProgressiveReader::url [protected, inherited]


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