Panda3D
Loading...
Searching...
No Matches
extractor.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file extractor.h
10 * @author mike
11 * @date 1997-01-09
12 */
13
14#ifndef EXTRACTOR_H
15#define EXTRACTOR_H
16
17#include "pandabase.h"
18#include "filename.h"
19#include "buffer.h"
20#include "multifile.h"
21#include "pointerTo.h"
22#include "vector_int.h"
23
24/**
25 * This class automatically extracts the contents of a Multifile to the
26 * current directory (or to a specified directory) in the background.
27 *
28 * It is designed to limit its use of system resources and run unobtrusively
29 * in the background. After specifying the files you wish to extract via
30 * repeated calls to request_subfile(), begin the process by calling run()
31 * repeatedly. Each call to run() extracts another small portion of the
32 * Multifile. Call run() whenever you have spare cycles until run() returns
33 * EU_success.
34 */
35class EXPCL_PANDA_DOWNLOADER Extractor {
36PUBLISHED:
37 Extractor();
38 ~Extractor();
39
40 bool set_multifile(const Filename &multifile_name);
41 void set_extract_dir(const Filename &extract_dir);
42
43 void reset();
44
45 bool request_subfile(const Filename &subfile_name);
47
48 int step();
49 PN_stdfloat get_progress() const;
50
51 bool run();
52
53PUBLISHED:
54 MAKE_PROPERTY(progress, get_progress);
55
56private:
57 Filename _multifile_name;
58 PT(Multifile) _multifile;
59
60 Filename _extract_dir;
61
62 typedef vector_int Requests;
63 Requests _requests;
64 size_t _requests_total_length;
65
66 bool _initiated;
67
68 // These are used only while processing.
69 int _request_index;
70 int _subfile_index;
71 size_t _subfile_pos;
72 size_t _subfile_length;
73 size_t _total_bytes_extracted;
74 std::istream *_read;
75 pofstream _write;
76 Filename _subfile_filename;
77};
78
79#include "extractor.I"
80
81#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void reset()
Interrupts the Extractor in the middle of its business and makes it ready to accept a new list of sub...
Definition extractor.cxx:64
bool run()
A convenience function to extract the Multifile all at once, when you don't care about doing it in th...
void set_extract_dir(const Filename &extract_dir)
Specifies the directory into which all extracted subfiles will be written.
Definition extractor.cxx:55
bool set_multifile(const Filename &multifile_name)
Specifies the filename of the Multifile that the Extractor will read.
Definition extractor.cxx:43
bool request_subfile(const Filename &subfile_name)
Requests a particular subfile to be extracted when step() or run() is called.
Definition extractor.cxx:83
get_progress
Returns the fraction of the Multifile extracted so far.
Definition extractor.h:54
int request_all_subfiles()
Requests all subfiles in the Multifile to be extracted.
Definition extractor.cxx:98
int step()
After all of the requests have been made via request_file() or request_all_subfiles(),...
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
A file that contains a set of files.
Definition multifile.h:37
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.