Panda3D
|
A listing of files within multifiles for management of client-side synchronization with a server-provided set of files. More...
#include "downloadDb.h"
Classes | |
class | Db |
class | FileRecord |
class | MultifileRecord |
Public Types | |
typedef pvector< PT(FileRecord) > | FileRecords |
typedef pvector< PT(MultifileRecord) > | MultifileRecords |
enum | Status { Status_incomplete = 0, Status_complete = 1, Status_decompressed = 2, Status_extracted = 3 } |
typedef pvector< HashVal > | VectorHash |
typedef pmap< Filename, VectorHash > | VersionMap |
Public Member Functions | |
DownloadDb () | |
Primarily used for testing. | |
DownloadDb (Ramfile &server_file, Filename &client_file) | |
Create a download db with these client and server dbs. | |
DownloadDb (Filename &server_file, Filename &client_file) | |
Create a download db with these client and server dbs. | |
void | add_client_multifile (string server_mfname) |
void | add_version (const Filename &name, const HashVal &hash, int version) |
Appends a new version of the file onto the end of the list, or changes the hash associated with a version previously added. | |
bool | client_multifile_complete (string mfname) const |
A multifile is complete when it is completely downloaded. | |
bool | client_multifile_decompressed (string mfname) const |
bool | client_multifile_exists (string mfname) const |
bool | client_multifile_extracted (string mfname) const |
void | create_new_server_db () |
Used on the server side makefiles to create a new clean server db. | |
void | delete_client_multifile (string mfname) |
void | expand_client_multifile (string mfname) |
HashVal | get_client_multifile_hash (string mfname) const |
Return the hash value of the file we are working on. | |
string | get_client_multifile_name (int index) const |
Phase | get_client_multifile_phase (string mfname) const |
int | get_client_multifile_size (string mfname) const |
int | get_client_num_multifiles () const |
const HashVal & | get_hash (const Filename &name, int version) const |
Returns the MD5 hash associated with the indicated version of the indicated file. | |
int | get_num_versions (const Filename &name) const |
Returns the number of versions stored for the indicated file. | |
string | get_server_file_name (string mfname, int index) const |
HashVal | get_server_multifile_hash (string mfname) const |
Return the hash value of the server file. | |
string | get_server_multifile_name (int index) const |
Phase | get_server_multifile_phase (string mfname) const |
int | get_server_multifile_size (string mfname) const |
int | get_server_num_files (string mfname) const |
int | get_server_num_multifiles () const |
int | get_version (const Filename &name, const HashVal &hash) const |
Returns the version number of this particular file, determined by looking up the hash generated from the file. | |
bool | has_version (const Filename &name) const |
Returns true if the indicated file has version information, false otherwise. | |
void | insert_new_version (const Filename &name, const HashVal &hash) |
Inserts a new version 1 copy of the file, sliding all the other versions up by one. | |
void | output (ostream &out) const |
Db | read_db (Filename &file, bool want_server_info) |
Db | read_db (Ramfile &file, bool want_server_info) |
void | server_add_file (string mfname, string fname) |
void | server_add_multifile (string mfname, Phase phase, int size, int status) |
void | set_client_multifile_complete (string mfname) |
void | set_client_multifile_decompressed (string mfname) |
int | set_client_multifile_delta_size (string mfname, int size) |
void | set_client_multifile_extracted (string mfname) |
void | set_client_multifile_hash (string mfname, HashVal val) |
Set the hash value of file we are working on. | |
void | set_client_multifile_incomplete (string mfname) |
void | set_client_multifile_size (string mfname, int size) |
void | set_num_versions (const Filename &name, int num_versions) |
Reduces the number of versions of a particular file stored in the ddb by throwing away all versions higher than the indicated index. | |
void | set_server_multifile_hash (string mfname, HashVal val) |
Set the hash value of file we are working on. | |
void | set_server_multifile_size (string mfname, int size) |
void | write (ostream &out) const |
bool | write_client_db (Filename &file) |
bool | write_db (Filename &file, Db db, bool want_server_info) |
bool | write_server_db (Filename &file) |
void | write_version_map (ostream &out) const |
Public Attributes | |
Db | _client_db |
Db | _server_db |
Static Public Attributes | |
static PN_uint32 | _bogus_magic_number = 0x11111111 |
static PN_uint32 | _magic_number = 0xfeedfeed |
Protected Member Functions | |
bool | read_version_map (StreamReader &sr) |
void | write_version_map (StreamWriter &sw) |
Protected Attributes | |
VersionMap | _versions |
A listing of files within multifiles for management of client-side synchronization with a server-provided set of files.
This class manages one copy of the database for the client, representing the files on the client system, and another copy for the server, representing the files the server has available.
Definition at line 67 of file downloadDb.h.
Primarily used for testing.
Definition at line 89 of file downloadDb.cxx.
DownloadDb::DownloadDb | ( | Ramfile & | server_file, |
Filename & | client_file | ||
) |
Create a download db with these client and server dbs.
Definition at line 58 of file downloadDb.cxx.
DownloadDb::DownloadDb | ( | Filename & | server_file, |
Filename & | client_file | ||
) |
Create a download db with these client and server dbs.
Definition at line 73 of file downloadDb.cxx.
void DownloadDb::add_version | ( | const Filename & | name, |
const HashVal & | hash, | ||
int | version | ||
) |
Appends a new version of the file onto the end of the list, or changes the hash associated with a version previously added.
Note: version numbers start at 1
Definition at line 1070 of file downloadDb.cxx.
bool DownloadDb::client_multifile_complete | ( | string | mfname | ) | const |
A multifile is complete when it is completely downloaded.
Note: it may already be decompressed or extracted and it is still complete
Definition at line 178 of file downloadDb.cxx.
void DownloadDb::create_new_server_db | ( | ) |
Used on the server side makefiles to create a new clean server db.
Definition at line 399 of file downloadDb.cxx.
HashVal DownloadDb::get_client_multifile_hash | ( | string | mfname | ) | const |
Return the hash value of the file we are working on.
Definition at line 212 of file downloadDb.cxx.
const HashVal & DownloadDb::get_hash | ( | const Filename & | name, |
int | version | ||
) | const |
Returns the MD5 hash associated with the indicated version of the indicated file.
Definition at line 1182 of file downloadDb.cxx.
int DownloadDb::get_num_versions | ( | const Filename & | name | ) | const |
Returns the number of versions stored for the indicated file.
Definition at line 1120 of file downloadDb.cxx.
HashVal DownloadDb::get_server_multifile_hash | ( | string | mfname | ) | const |
Return the hash value of the server file.
Definition at line 223 of file downloadDb.cxx.
int DownloadDb::get_version | ( | const Filename & | name, |
const HashVal & | hash | ||
) | const |
Returns the version number of this particular file, determined by looking up the hash generated from the file.
Returns -1 if the version number cannot be determined.
Definition at line 1159 of file downloadDb.cxx.
bool DownloadDb::has_version | ( | const Filename & | name | ) | const |
Returns true if the indicated file has version information, false otherwise.
Some files recorded in the database may not bother to track versions.
Definition at line 1109 of file downloadDb.cxx.
void DownloadDb::insert_new_version | ( | const Filename & | name, |
const HashVal & | hash | ||
) |
Inserts a new version 1 copy of the file, sliding all the other versions up by one.
Definition at line 1096 of file downloadDb.cxx.
void DownloadDb::set_client_multifile_hash | ( | string | mfname, |
HashVal | val | ||
) |
Set the hash value of file we are working on.
Definition at line 234 of file downloadDb.cxx.
void DownloadDb::set_num_versions | ( | const Filename & | name, |
int | num_versions | ||
) |
Reduces the number of versions of a particular file stored in the ddb by throwing away all versions higher than the indicated index.
Definition at line 1137 of file downloadDb.cxx.
void DownloadDb::set_server_multifile_hash | ( | string | mfname, |
HashVal | val | ||
) |
Set the hash value of file we are working on.
Definition at line 246 of file downloadDb.cxx.