Panda3D
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
DownloadDb Class Reference

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< HashValVectorHash
 
typedef pmap< Filename, VectorHashVersionMap
 

Public Member Functions

 DownloadDb ()
 Primarily used for testing. More...
 
 DownloadDb (Ramfile &server_file, Filename &client_file)
 Create a download db with these client and server dbs. More...
 
 DownloadDb (Filename &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 HashValget_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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DownloadDb() [1/3]

DownloadDb::DownloadDb ( )

Primarily used for testing.

Definition at line 87 of file downloadDb.cxx.

◆ DownloadDb() [2/3]

DownloadDb::DownloadDb ( Ramfile server_file,
Filename client_file 
)
explicit

Create a download db with these client and server dbs.

Definition at line 60 of file downloadDb.cxx.

◆ DownloadDb() [3/3]

DownloadDb::DownloadDb ( Filename server_file,
Filename client_file 
)
explicit

Create a download db with these client and server dbs.

Definition at line 73 of file downloadDb.cxx.

Member Function Documentation

◆ add_version()

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 946 of file downloadDb.cxx.

◆ client_multifile_complete()

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 161 of file downloadDb.cxx.

◆ create_new_server_db()

void DownloadDb::create_new_server_db ( )

Used on the server side makefiles to create a new clean server db.

Definition at line 355 of file downloadDb.cxx.

◆ get_client_multifile_hash()

HashVal DownloadDb::get_client_multifile_hash ( std::string  mfname) const

Return the hash value of the file we are working on.

Definition at line 189 of file downloadDb.cxx.

◆ get_hash()

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 1043 of file downloadDb.cxx.

◆ get_num_versions()

int DownloadDb::get_num_versions ( const Filename name) const

Returns the number of versions stored for the indicated file.

Definition at line 989 of file downloadDb.cxx.

◆ get_server_multifile_hash()

HashVal DownloadDb::get_server_multifile_hash ( std::string  mfname) const

Return the hash value of the server file.

Definition at line 198 of file downloadDb.cxx.

◆ get_version()

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 1022 of file downloadDb.cxx.

◆ has_version()

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 981 of file downloadDb.cxx.

◆ insert_new_version()

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 970 of file downloadDb.cxx.

◆ set_client_multifile_hash()

void DownloadDb::set_client_multifile_hash ( std::string  mfname,
HashVal  val 
)

Set the hash value of file we are working on.

Definition at line 207 of file downloadDb.cxx.

◆ set_num_versions()

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 1003 of file downloadDb.cxx.

◆ set_server_multifile_hash()

void DownloadDb::set_server_multifile_hash ( std::string  mfname,
HashVal  val 
)

Set the hash value of file we are working on.

Definition at line 217 of file downloadDb.cxx.


The documentation for this class was generated from the following files: