forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp3dDownload.I
More file actions
executable file
·159 lines (145 loc) · 6.01 KB
/
p3dDownload.I
File metadata and controls
executable file
·159 lines (145 loc) · 6.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Filename: p3dDownload.I
// Created by: drose (11Jun09)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_url
// Access: Public
// Description: Returns the URL that we are querying.
////////////////////////////////////////////////////////////////////
const string &P3DDownload::
get_url() const {
return _url;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::set_instance
// Access: Public
// Description: Specifies the particular P3DInstance that is
// responsible for downloading this object.
////////////////////////////////////////////////////////////////////
inline void P3DDownload::
set_instance(P3DInstance *instance) {
_instance = instance;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_instance
// Access: Public
// Description: Returns the particular P3DInstance that is
// responsible for downloading this object.
////////////////////////////////////////////////////////////////////
inline P3DInstance *P3DDownload::
get_instance() const {
return _instance;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_download_progress
// Access: Public
// Description: Returns an indication of the progress through the
// download file, 0.0 to 1.0. Returns 1.0 if the size
// of the file is not known.
////////////////////////////////////////////////////////////////////
inline double P3DDownload::
get_download_progress() const {
if (_total_expected_data == 0) {
return 1.0;
}
return (double)_total_data / (double)_total_expected_data;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::is_download_progress_known
// Access: Public
// Description: Returns true if the download progress is known, or
// false if it is unknown because the server hasn't told
// us the total size it will be feeding us. If this is
// false, get_download_progress() will generally always
// return 1.0; use get_total_bytes() to measure progress
// in this case.
////////////////////////////////////////////////////////////////////
inline bool P3DDownload::
is_download_progress_known() const {
return _progress_known;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_total_data
// Access: Public
// Description: Returns the total number of bytes downloaded so far.
////////////////////////////////////////////////////////////////////
inline size_t P3DDownload::
get_total_data() const {
return _total_data;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::set_total_expected_data
// Access: Public
// Description: Sets the total number of bytes expected to be
// downloaded. This is used to compute the progress.
// Normally, this can be set from the download server,
// but there may be cases when the download server
// doesn't accurately report it.
////////////////////////////////////////////////////////////////////
inline void P3DDownload::
set_total_expected_data(size_t expected_data) {
_total_expected_data = expected_data;
_progress_known = true;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_download_finished
// Access: Public
// Description: Returns true if the download has finished, either
// successfully or otherwise, or false if it is still in
// progress.
////////////////////////////////////////////////////////////////////
inline bool P3DDownload::
get_download_finished() const {
return _status != P3D_RC_in_progress;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_download_success
// Access: Public
// Description: Returns true if the download has finished
// successfully, or false if it is still in progress or
// if it has failed.
////////////////////////////////////////////////////////////////////
inline bool P3DDownload::
get_download_success() const {
return _status == P3D_RC_done;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_download_terminated
// Access: Public
// Description: Returns true if the download has failed because the
// instance is about to be shut down, or false if it
// hasn't failed, or failed for some other reason.
////////////////////////////////////////////////////////////////////
inline bool P3DDownload::
get_download_terminated() const {
return _status == P3D_RC_shutdown;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::set_download_id
// Access: Public
// Description: Called only by P3DInstance to set a unique ID for
// this particular download object.
////////////////////////////////////////////////////////////////////
inline void P3DDownload::
set_download_id(int download_id) {
_download_id = download_id;
}
////////////////////////////////////////////////////////////////////
// Function: P3DDownload::get_download_id
// Access: Public
// Description: Returns the unique ID set by the P3DInstance.
////////////////////////////////////////////////////////////////////
inline int P3DDownload::
get_download_id() const {
return _download_id;
}