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. More... | |
DownloadDb (Filename &server_file, Filename &client_file) | |
Create a download db with these client and server dbs. More... | |
DownloadDb (Ramfile &server_file, Filename &client_file) | |
Create a download db with these client and server dbs. More... | |
void | add_client_multifile (std::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. More... | |
bool | client_multifile_complete (std::string mfname) const |
A multifile is complete when it is completely downloaded. More... | |
bool | client_multifile_decompressed (std::string mfname) const |
bool | client_multifile_exists (std::string mfname) const |
bool | client_multifile_extracted (std::string mfname) const |
void | create_new_server_db () |
Used on the server side makefiles to create a new clean server db. More... | |
void | delete_client_multifile (std::string mfname) |
void | expand_client_multifile (std::string mfname) |
HashVal | get_client_multifile_hash (std::string mfname) const |
Return the hash value of the file we are working on. More... | |
std::string | get_client_multifile_name (int index) const |
Phase | get_client_multifile_phase (std::string mfname) const |
int | get_client_multifile_size (std::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. More... | |
int | get_num_versions (const Filename &name) const |
Returns the number of versions stored for the indicated file. More... | |
std::string | get_server_file_name (std::string mfname, int index) const |
HashVal | get_server_multifile_hash (std::string mfname) const |
Return the hash value of the server file. More... | |
std::string | get_server_multifile_name (int index) const |
Phase | get_server_multifile_phase (std::string mfname) const |
int | get_server_multifile_size (std::string mfname) const |
int | get_server_num_files (std::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. More... | |
bool | has_version (const Filename &name) const |
Returns true if the indicated file has version information, false otherwise. More... | |
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. More... | |
void | output (std::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 (std::string mfname, std::string fname) |
void | server_add_multifile (std::string mfname, Phase phase, int size, int status) |
void | set_client_multifile_complete (std::string mfname) |
void | set_client_multifile_decompressed (std::string mfname) |
int | set_client_multifile_delta_size (std::string mfname, int size) |
void | set_client_multifile_extracted (std::string mfname) |
void | set_client_multifile_hash (std::string mfname, HashVal val) |
Set the hash value of file we are working on. More... | |
void | set_client_multifile_incomplete (std::string mfname) |
void | set_client_multifile_size (std::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. More... | |
void | set_server_multifile_hash (std::string mfname, HashVal val) |
Set the hash value of file we are working on. More... | |
void | set_server_multifile_size (std::string mfname, int size) |
void | write (std::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 (std::ostream &out) const |
Public Attributes | |
Db | _client_db |
Db | _server_db |
Static Public Attributes | |
static uint32_t | _bogus_magic_number = 0x11111111 |
static uint32_t | _magic_number = 0xfeedfeed |
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 62 of file downloadDb.h.
typedef pvector< PT(FileRecord) > DownloadDb::FileRecords |
Definition at line 142 of file downloadDb.h.
typedef pvector< PT(MultifileRecord) > DownloadDb::MultifileRecords |
Definition at line 163 of file downloadDb.h.
typedef pvector<HashVal> DownloadDb::VectorHash |
Definition at line 202 of file downloadDb.h.
typedef pmap<Filename, VectorHash> DownloadDb::VersionMap |
Definition at line 203 of file downloadDb.h.
enum DownloadDb::Status |
Definition at line 67 of file downloadDb.h.
DownloadDb::DownloadDb | ( | ) |
Primarily used for testing.
Definition at line 86 of file downloadDb.cxx.
Create a download db with these client and server dbs.
Definition at line 59 of file downloadDb.cxx.
Create a download db with these client and server dbs.
Definition at line 72 of file downloadDb.cxx.
DownloadDb::~DownloadDb | ( | ) |
Definition at line 95 of file downloadDb.cxx.
void DownloadDb::add_client_multifile | ( | std::string | server_mfname | ) |
Definition at line 233 of file downloadDb.cxx.
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 945 of file downloadDb.cxx.
bool DownloadDb::client_multifile_complete | ( | std::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 160 of file downloadDb.cxx.
bool DownloadDb::client_multifile_decompressed | ( | std::string | mfname | ) | const |
Definition at line 169 of file downloadDb.cxx.
bool DownloadDb::client_multifile_exists | ( | std::string | mfname | ) | const |
Definition at line 151 of file downloadDb.cxx.
bool DownloadDb::client_multifile_extracted | ( | std::string | mfname | ) | const |
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 354 of file downloadDb.cxx.
void DownloadDb::delete_client_multifile | ( | std::string | mfname | ) |
Definition at line 226 of file downloadDb.cxx.
void DownloadDb::expand_client_multifile | ( | std::string | mfname | ) |
Definition at line 246 of file downloadDb.cxx.
HashVal DownloadDb::get_client_multifile_hash | ( | std::string | mfname | ) | const |
Return the hash value of the file we are working on.
Definition at line 188 of file downloadDb.cxx.
|
inline |
Definition at line 33 of file downloadDb.I.
|
inline |
Definition at line 50 of file downloadDb.I.
|
inline |
Definition at line 68 of file downloadDb.I.
|
inline |
Definition at line 17 of file downloadDb.I.
Returns the MD5 hash associated with the indicated version of the indicated file.
Definition at line 1042 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 988 of file downloadDb.cxx.
|
inline |
Definition at line 161 of file downloadDb.I.
HashVal DownloadDb::get_server_multifile_hash | ( | std::string | mfname | ) | const |
Return the hash value of the server file.
Definition at line 197 of file downloadDb.cxx.
|
inline |
Definition at line 41 of file downloadDb.I.
|
inline |
Definition at line 58 of file downloadDb.I.
|
inline |
Definition at line 99 of file downloadDb.I.
|
inline |
Definition at line 153 of file downloadDb.I.
|
inline |
Definition at line 25 of file downloadDb.I.
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 1021 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 980 of file downloadDb.cxx.
Inserts a new version 1 copy of the file, sliding all the other versions up by one.
Definition at line 969 of file downloadDb.cxx.
void DownloadDb::output | ( | std::ostream & | out | ) | const |
Definition at line 106 of file downloadDb.cxx.
DownloadDb::Db DownloadDb::read_db | ( | Filename & | file, |
bool | want_server_info | ||
) |
Definition at line 254 of file downloadDb.cxx.
DownloadDb::Db DownloadDb::read_db | ( | Ramfile & | file, |
bool | want_server_info | ||
) |
Definition at line 295 of file downloadDb.cxx.
void DownloadDb::server_add_file | ( | std::string | mfname, |
std::string | fname | ||
) |
Definition at line 373 of file downloadDb.cxx.
void DownloadDb::server_add_multifile | ( | std::string | mfname, |
Phase | phase, | ||
int | size, | ||
int | status | ||
) |
Definition at line 363 of file downloadDb.cxx.
|
inline |
Definition at line 126 of file downloadDb.I.
|
inline |
Definition at line 135 of file downloadDb.I.
|
inline |
Definition at line 86 of file downloadDb.I.
|
inline |
Definition at line 144 of file downloadDb.I.
void DownloadDb::set_client_multifile_hash | ( | std::string | mfname, |
HashVal | val | ||
) |
Set the hash value of file we are working on.
Definition at line 206 of file downloadDb.cxx.
|
inline |
Definition at line 117 of file downloadDb.I.
|
inline |
Definition at line 76 of file downloadDb.I.
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 1002 of file downloadDb.cxx.
void DownloadDb::set_server_multifile_hash | ( | std::string | mfname, |
HashVal | val | ||
) |
Set the hash value of file we are working on.
Definition at line 216 of file downloadDb.cxx.
|
inline |
Definition at line 108 of file downloadDb.I.
void DownloadDb::write | ( | std::ostream & | out | ) | const |
Definition at line 114 of file downloadDb.cxx.
bool DownloadDb::write_client_db | ( | Filename & | file | ) |
Definition at line 134 of file downloadDb.cxx.
Definition at line 322 of file downloadDb.cxx.
bool DownloadDb::write_server_db | ( | Filename & | file | ) |
Definition at line 143 of file downloadDb.cxx.
void DownloadDb::write_version_map | ( | std::ostream & | out | ) | const |
Definition at line 1129 of file downloadDb.cxx.
|
static |
Definition at line 201 of file downloadDb.h.
Db DownloadDb::_client_db |
Definition at line 196 of file downloadDb.h.
|
static |
Definition at line 200 of file downloadDb.h.
Db DownloadDb::_server_db |
Definition at line 197 of file downloadDb.h.