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

panda/src/downloader/extractor.h

Go to the documentation of this file.
00001 // Filename: extractor.h
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 #ifndef EXTRACTOR_H
00019 #define EXTRACTOR_H
00020 
00021 #include "pandabase.h"
00022 #include "filename.h"
00023 #include "buffer.h"
00024 #include "multifile.h"
00025 #include "pointerTo.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : Extractor
00029 // Description : This class automatically extracts the contents of a
00030 //               Multifile to the current directory (or to a specified
00031 //               directory) in the background.
00032 //
00033 //               It is designed to limit its use of system resources
00034 //               and run unobtrusively in the background.  After
00035 //               specifying the files you wish to extract via repeated
00036 //               calls to request_subfile(), begin the process by
00037 //               calling run() repeatedly.  Each call to run()
00038 //               extracts another small portion of the Multifile.
00039 //               Call run() whenever you have spare cycles until run()
00040 //               returns EU_success.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDAEXPRESS Extractor {
00043 PUBLISHED:
00044   Extractor();
00045   ~Extractor();
00046 
00047   bool set_multifile(const Filename &multifile_name);
00048   void set_extract_dir(const Filename &extract_dir);
00049 
00050   void reset();
00051 
00052   bool request_subfile(const Filename &subfile_name);
00053   int request_all_subfiles();
00054 
00055   int step();
00056   float get_progress(void) const;
00057 
00058   bool run();
00059 
00060 private:
00061   Filename _multifile_name;
00062   Multifile _multifile;
00063 
00064   Filename _extract_dir;
00065 
00066   typedef pvector<int> Requests;
00067   Requests _requests;
00068   size_t _requests_total_length;
00069   
00070   bool _initiated;
00071 
00072   // These are used only while processing.
00073   int _request_index;
00074   int _subfile_index;
00075   size_t _subfile_pos;
00076   size_t _subfile_length;
00077   size_t _total_bytes_extracted;
00078   istream *_read;
00079   ofstream _write;
00080   Filename _subfile_filename;
00081 };
00082 
00083 #include "extractor.I"
00084 
00085 #endif

Generated on Fri May 2 00:36:46 2003 for Panda by doxygen1.3