Panda3D
Loading...
Searching...
No Matches
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.
 
 DownloadDb (Filename &server_file, Filename &client_file)
 Create a download db with these client and server dbs.
 
 DownloadDb (Ramfile &server_file, Filename &client_file)
 Create a download db with these client and server dbs.
 
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.
 
bool client_multifile_complete (std::string mfname) const
 A multifile is complete when it is completely downloaded.
 
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.
 
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.
 
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.
 
int get_num_versions (const Filename &name) const
 Returns the number of versions stored for the indicated file.
 
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.
 
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.
 
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 (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.
 
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.
 
void set_server_multifile_hash (std::string mfname, HashVal val)
 Set the hash value of file we are working on.
 
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.

Member Typedef Documentation

◆ FileRecords

Definition at line 142 of file downloadDb.h.

◆ MultifileRecords

Definition at line 163 of file downloadDb.h.

◆ VectorHash

Definition at line 202 of file downloadDb.h.

◆ VersionMap

Definition at line 203 of file downloadDb.h.

Member Enumeration Documentation

◆ Status

enum DownloadDb::Status

Definition at line 67 of file downloadDb.h.

Constructor & Destructor Documentation

◆ DownloadDb() [1/3]

DownloadDb::DownloadDb ( )

Primarily used for testing.

Definition at line 85 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 58 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 71 of file downloadDb.cxx.

◆ ~DownloadDb()

DownloadDb::~DownloadDb ( )

Definition at line 94 of file downloadDb.cxx.

Member Function Documentation

◆ add_client_multifile()

void DownloadDb::add_client_multifile ( std::string server_mfname)

Definition at line 232 of file downloadDb.cxx.

◆ 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 944 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 159 of file downloadDb.cxx.

◆ client_multifile_decompressed()

bool DownloadDb::client_multifile_decompressed ( std::string mfname) const

Definition at line 168 of file downloadDb.cxx.

◆ client_multifile_exists()

bool DownloadDb::client_multifile_exists ( std::string mfname) const

Definition at line 150 of file downloadDb.cxx.

◆ client_multifile_extracted()

bool DownloadDb::client_multifile_extracted ( std::string mfname) const

Definition at line 177 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 353 of file downloadDb.cxx.

◆ delete_client_multifile()

void DownloadDb::delete_client_multifile ( std::string mfname)

Definition at line 225 of file downloadDb.cxx.

◆ expand_client_multifile()

void DownloadDb::expand_client_multifile ( std::string mfname)

Definition at line 245 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 187 of file downloadDb.cxx.

◆ get_client_multifile_name()

std::string DownloadDb::get_client_multifile_name ( int index) const
inline

Definition at line 33 of file downloadDb.I.

◆ get_client_multifile_phase()

Phase DownloadDb::get_client_multifile_phase ( std::string mfname) const
inline

Definition at line 50 of file downloadDb.I.

◆ get_client_multifile_size()

int DownloadDb::get_client_multifile_size ( std::string mfname) const
inline

Definition at line 68 of file downloadDb.I.

◆ get_client_num_multifiles()

int DownloadDb::get_client_num_multifiles ( ) const
inline

Definition at line 17 of file downloadDb.I.

◆ 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 1041 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 987 of file downloadDb.cxx.

◆ get_server_file_name()

std::string DownloadDb::get_server_file_name ( std::string mfname,
int index ) const
inline

Definition at line 161 of file downloadDb.I.

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

◆ get_server_multifile_name()

std::string DownloadDb::get_server_multifile_name ( int index) const
inline

Definition at line 41 of file downloadDb.I.

◆ get_server_multifile_phase()

Phase DownloadDb::get_server_multifile_phase ( std::string mfname) const
inline

Definition at line 58 of file downloadDb.I.

◆ get_server_multifile_size()

int DownloadDb::get_server_multifile_size ( std::string mfname) const
inline

Definition at line 99 of file downloadDb.I.

◆ get_server_num_files()

int DownloadDb::get_server_num_files ( std::string mfname) const
inline

Definition at line 153 of file downloadDb.I.

◆ get_server_num_multifiles()

int DownloadDb::get_server_num_multifiles ( ) const
inline

Definition at line 25 of file downloadDb.I.

◆ 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 1020 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 979 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 968 of file downloadDb.cxx.

◆ output()

void DownloadDb::output ( std::ostream & out) const

Definition at line 105 of file downloadDb.cxx.

◆ read_db() [1/2]

DownloadDb::Db DownloadDb::read_db ( Filename & file,
bool want_server_info )

Definition at line 253 of file downloadDb.cxx.

◆ read_db() [2/2]

DownloadDb::Db DownloadDb::read_db ( Ramfile & file,
bool want_server_info )

Definition at line 294 of file downloadDb.cxx.

◆ server_add_file()

void DownloadDb::server_add_file ( std::string mfname,
std::string fname )

Definition at line 372 of file downloadDb.cxx.

◆ server_add_multifile()

void DownloadDb::server_add_multifile ( std::string mfname,
Phase phase,
int size,
int status )

Definition at line 362 of file downloadDb.cxx.

◆ set_client_multifile_complete()

void DownloadDb::set_client_multifile_complete ( std::string mfname)
inline

Definition at line 126 of file downloadDb.I.

◆ set_client_multifile_decompressed()

void DownloadDb::set_client_multifile_decompressed ( std::string mfname)
inline

Definition at line 135 of file downloadDb.I.

◆ set_client_multifile_delta_size()

int DownloadDb::set_client_multifile_delta_size ( std::string mfname,
int size )
inline

Definition at line 86 of file downloadDb.I.

◆ set_client_multifile_extracted()

void DownloadDb::set_client_multifile_extracted ( std::string mfname)
inline

Definition at line 144 of file downloadDb.I.

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

◆ set_client_multifile_incomplete()

void DownloadDb::set_client_multifile_incomplete ( std::string mfname)
inline

Definition at line 117 of file downloadDb.I.

◆ set_client_multifile_size()

void DownloadDb::set_client_multifile_size ( std::string mfname,
int size )
inline

Definition at line 76 of file downloadDb.I.

◆ 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 1001 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 215 of file downloadDb.cxx.

◆ set_server_multifile_size()

void DownloadDb::set_server_multifile_size ( std::string mfname,
int size )
inline

Definition at line 108 of file downloadDb.I.

◆ write()

void DownloadDb::write ( std::ostream & out) const

Definition at line 113 of file downloadDb.cxx.

◆ write_client_db()

bool DownloadDb::write_client_db ( Filename & file)

Definition at line 133 of file downloadDb.cxx.

◆ write_db()

bool DownloadDb::write_db ( Filename & file,
Db db,
bool want_server_info )

Definition at line 321 of file downloadDb.cxx.

◆ write_server_db()

bool DownloadDb::write_server_db ( Filename & file)

Definition at line 142 of file downloadDb.cxx.

◆ write_version_map()

void DownloadDb::write_version_map ( std::ostream & out) const

Definition at line 1128 of file downloadDb.cxx.

Member Data Documentation

◆ _bogus_magic_number

uint32_t DownloadDb::_bogus_magic_number = 0x11111111
static

Definition at line 201 of file downloadDb.h.

◆ _client_db

Db DownloadDb::_client_db

Definition at line 196 of file downloadDb.h.

◆ _magic_number

uint32_t DownloadDb::_magic_number = 0xfeedfeed
static

Definition at line 200 of file downloadDb.h.

◆ _server_db

Db DownloadDb::_server_db

Definition at line 197 of file downloadDb.h.


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