Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Extractor Class Reference

This class automatically extracts the contents of a Multifile to the current directory (or to a specified directory) in the background. More...

#include <extractor.h>

List of all members.

Public Member Functions

 Extractor ()
 ~Extractor ()
bool set_multifile (const Filename &multifile_name)
 Specifies the filename of the Multifile that the Extractor will read.

void set_extract_dir (const Filename &extract_dir)
 Specifies the directory into which all extracted subfiles will be written.

void reset ()
 Interrupts the Extractor in the middle of its business and makes it ready to accept a new list of subfiles to extract.

bool request_subfile (const Filename &subfile_name)
 Requests a particular subfile to be extracted when step() or run() is called.

int request_all_subfiles ()
 Requests all subfiles in the Multifile to be extracted.

int step ()
 After all of the requests have been made via request_file() or request_all_subfiles(), call step() repeatedly until it stops returning EU_ok.

float get_progress (void) const
 Returns the fraction of the Multifile extracted so far.

bool run ()
 A convenience function to extract the Multifile all at once, when you don't care about doing it in the background.


Private Types

typedef pvector< int > Requests

Private Attributes

Filename _multifile_name
Multifile _multifile
Filename _extract_dir
Requests _requests
size_t _requests_total_length
bool _initiated
int _request_index
int _subfile_index
size_t _subfile_pos
size_t _subfile_length
size_t _total_bytes_extracted
istream * _read
ofstream _write
Filename _subfile_filename


Detailed Description

This class automatically extracts the contents of a Multifile to the current directory (or to a specified directory) in the background.

It is designed to limit its use of system resources and run unobtrusively in the background. After specifying the files you wish to extract via repeated calls to request_subfile(), begin the process by calling run() repeatedly. Each call to run() extracts another small portion of the Multifile. Call run() whenever you have spare cycles until run() returns EU_success.

Definition at line 59 of file extractor.h.


Member Typedef Documentation

typedef pvector<int> Extractor::Requests [private]
 

Definition at line 83 of file extractor.h.


Constructor & Destructor Documentation

Extractor::Extractor  ) 
 

Definition at line 37 of file extractor.cxx.

References reset().

Extractor::~Extractor  ) 
 

Definition at line 49 of file extractor.cxx.

References _multifile, _multifile_name, multifile_name, Multifile::open_read(), and reset().


Member Function Documentation

float Extractor::get_progress void   )  const
 

Returns the fraction of the Multifile extracted so far.

Definition at line 278 of file extractor.cxx.

int Extractor::request_all_subfiles  ) 
 

Requests all subfiles in the Multifile to be extracted.

Returns the number requested.

Definition at line 152 of file extractor.cxx.

References _initiated, _read, _total_bytes_extracted, and NULL.

bool Extractor::request_subfile const Filename subfile_name  ) 
 

Requests a particular subfile to be extracted when step() or run() is called.

Returns true if the subfile exists, false otherwise.

Definition at line 131 of file extractor.cxx.

References _initiated, _request_index, _subfile_index, _subfile_length, and _subfile_pos.

void Extractor::reset  ) 
 

Interrupts the Extractor in the middle of its business and makes it ready to accept a new list of subfiles to extract.

Definition at line 104 of file extractor.cxx.

References _multifile.

Referenced by Extractor(), and ~Extractor().

bool Extractor::run  ) 
 

A convenience function to extract the Multifile all at once, when you don't care about doing it in the background.

First, call request_file() or request_all_files() to specify the files you would like to extract, then call run() to do the extraction. Also see step() for when you would like the extraction to happen as a background task.

Definition at line 314 of file extractor.cxx.

void Extractor::set_extract_dir const Filename extract_dir  ) 
 

Specifies the directory into which all extracted subfiles will be written.

Relative paths of subfiles within the Multifile will be written as relative paths to this directory.

Definition at line 87 of file extractor.cxx.

References _initiated, and _write.

bool Extractor::set_multifile const Filename multifile_name  ) 
 

Specifies the filename of the Multifile that the Extractor will read.

Returns true on success, false if the mulifile name is invalid.

Definition at line 66 of file extractor.cxx.

References _extract_dir.

int Extractor::step  ) 
 

After all of the requests have been made via request_file() or request_all_subfiles(), call step() repeatedly until it stops returning EU_ok.

step() extracts the next small unit of data from the Multifile. Returns EU_ok if progress is continuing, EU_error_abort if there is a problem, or EU_success when the last piece has been extracted.

Also see run().

Definition at line 190 of file extractor.cxx.

References _read, _request_index, _write, and NULL.


Member Data Documentation

Filename Extractor::_extract_dir [private]
 

Definition at line 81 of file extractor.h.

Referenced by set_multifile().

bool Extractor::_initiated [private]
 

Definition at line 87 of file extractor.h.

Referenced by request_all_subfiles(), request_subfile(), and set_extract_dir().

Multifile Extractor::_multifile [private]
 

Definition at line 79 of file extractor.h.

Referenced by reset(), and ~Extractor().

Filename Extractor::_multifile_name [private]
 

Definition at line 78 of file extractor.h.

Referenced by ~Extractor().

istream* Extractor::_read [private]
 

Definition at line 95 of file extractor.h.

Referenced by request_all_subfiles(), and step().

int Extractor::_request_index [private]
 

Definition at line 90 of file extractor.h.

Referenced by request_subfile(), and step().

Requests Extractor::_requests [private]
 

Definition at line 84 of file extractor.h.

size_t Extractor::_requests_total_length [private]
 

Definition at line 85 of file extractor.h.

Filename Extractor::_subfile_filename [private]
 

Definition at line 97 of file extractor.h.

int Extractor::_subfile_index [private]
 

Definition at line 91 of file extractor.h.

Referenced by request_subfile().

size_t Extractor::_subfile_length [private]
 

Definition at line 93 of file extractor.h.

Referenced by request_subfile().

size_t Extractor::_subfile_pos [private]
 

Definition at line 92 of file extractor.h.

Referenced by request_subfile().

size_t Extractor::_total_bytes_extracted [private]
 

Definition at line 94 of file extractor.h.

Referenced by request_all_subfiles().

ofstream Extractor::_write [private]
 

Definition at line 96 of file extractor.h.

Referenced by set_extract_dir(), and step().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:50:35 2003 for Panda by doxygen1.3