Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File 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>

List of all members.

Public Types

typedef pvector< PointerTo<
FileRecord > > 
FileRecords
typedef pvector< PointerTo<
MultifileRecord > > 
MultifileRecords
typedef pvector< HashValVectorHash
typedef pmap< Filename, VectorHashVersionMap
enum  Status { Status_incomplete = 0, Status_complete = 1, Status_decompressed = 2, Status_extracted = 3 }

Public Member Functions

 DownloadDb (void)
 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.

 ~DownloadDb (void)
void output (ostream &out) const
void write (ostream &out) const
void write_version_map (ostream &out) const
bool write_client_db (Filename &file)
bool write_server_db (Filename &file)
int get_client_num_multifiles (void) const
int get_server_num_multifiles (void) const
string get_client_multifile_name (int index) const
string get_server_multifile_name (int index) const
int get_client_multifile_size (string mfname) const
void set_client_multifile_size (string mfname, int size)
int set_client_multifile_delta_size (string mfname, int size)
int get_server_multifile_size (string mfname) const
void set_server_multifile_size (string mfname, int size)
Phase get_client_multifile_phase (string mfname) const
Phase get_server_multifile_phase (string mfname) const
void set_client_multifile_incomplete (string mfname)
void set_client_multifile_complete (string mfname)
void set_client_multifile_decompressed (string mfname)
void set_client_multifile_extracted (string mfname)
int get_server_num_files (string mfname) const
string get_server_file_name (string mfname, int index) const
bool client_multifile_exists (string mfname) const
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_extracted (string mfname) const
HashVal get_client_multifile_hash (string mfname) const
 Return the hash value of the file we are working on.

void set_client_multifile_hash (string mfname, HashVal val)
 Set the hash value of file we are working on.

HashVal get_server_multifile_hash (string mfname) const
 Return the hash value of the server file.

void set_server_multifile_hash (string mfname, HashVal val)
 Set the hash value of file we are working on.

void delete_client_multifile (string mfname)
void add_client_multifile (string server_mfname)
void expand_client_multifile (string mfname)
void create_new_server_db ()
 Used on the server side makefiles to create a new clean server db.

void server_add_multifile (string mfname, Phase phase, int size, int status)
void server_add_file (string mfname, string fname)
Db read_db (Filename &file, bool want_server_info)
Db read_db (Ramfile &file, bool want_server_info)
bool write_db (Filename &file, Db db, bool want_server_info)
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.

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.

bool has_version (const Filename &name) const
 Returns true if the indicated file has version information, false otherwise.

int get_num_versions (const Filename &name) const
 Returns the number of versions stored for the indicated file.

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.

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.

const HashValget_hash (const Filename &name, int version) const
 Returns the MD5 hash associated with the indicated version of the indicated file.


Public Attributes

Db _client_db
Db _server_db

Static Public Attributes

PN_uint32 _magic_number = 0xfeedfeed
PN_uint32 _bogus_magic_number = 0x11111111

Protected Member Functions

void write_version_map (ofstream &write_stream)
bool read_version_map (istream &read_stream)

Protected Attributes

VersionMap _versions
Datagram _master_datagram


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 81 of file downloadDb.h.


Member Typedef Documentation

typedef pvector< PointerTo< FileRecord > > DownloadDb::FileRecords
 

Definition at line 162 of file downloadDb.h.

typedef pvector< PointerTo< MultifileRecord > > DownloadDb::MultifileRecords
 

Definition at line 183 of file downloadDb.h.

typedef pvector<HashVal> DownloadDb::VectorHash
 

Definition at line 226 of file downloadDb.h.

typedef pmap<Filename, VectorHash> DownloadDb::VersionMap
 

Definition at line 227 of file downloadDb.h.


Member Enumeration Documentation

enum DownloadDb::Status
 

Enumeration values:
Status_incomplete 
Status_complete 
Status_decompressed 
Status_extracted 

Definition at line 87 of file downloadDb.h.


Constructor & Destructor Documentation

DownloadDb::DownloadDb void   ) 
 

Primarily used for testing.

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

References _client_db, DownloadDb::Db::_filename, _server_db, and read_db().

DownloadDb::DownloadDb Filename server_file,
Filename client_file
 

Create a download db with these client and server dbs.

Definition at line 83 of file downloadDb.cxx.

References _client_db, and _server_db.

DownloadDb::~DownloadDb void   ) 
 

Definition at line 115 of file downloadDb.cxx.

References _client_db, DownloadDb::Db::_filename, and DownloadDb::Db::write().


Member Function Documentation

void DownloadDb::add_client_multifile string  server_mfname  ) 
 

Definition at line 317 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 1240 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 208 of file downloadDb.cxx.

References _client_db, and DownloadDb::Db::get_multifile_record_named().

bool DownloadDb::client_multifile_decompressed string  mfname  )  const
 

Definition at line 221 of file downloadDb.cxx.

References _server_db, and DownloadDb::Db::get_multifile_record_named().

bool DownloadDb::client_multifile_exists string  mfname  )  const
 

Definition at line 191 of file downloadDb.cxx.

bool DownloadDb::client_multifile_extracted string  mfname  )  const
 

Definition at line 234 of file downloadDb.cxx.

References _client_db.

void DownloadDb::create_new_server_db void   ) 
 

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

Definition at line 451 of file downloadDb.cxx.

void DownloadDb::delete_client_multifile string  mfname  ) 
 

Definition at line 306 of file downloadDb.cxx.

void DownloadDb::expand_client_multifile string  mfname  ) 
 

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

string DownloadDb::get_client_multifile_name int  index  )  const [inline]
 

Definition at line 55 of file downloadDb.I.

References _server_db, DownloadDb::Db::get_multifile_name(), and INLINE.

Phase DownloadDb::get_client_multifile_phase string  mfname  )  const [inline]
 

Definition at line 80 of file downloadDb.I.

References _client_db, DownloadDb::Db::get_multifile_record_named(), and INLINE.

int DownloadDb::get_client_multifile_size string  mfname  )  const [inline]
 

Definition at line 106 of file downloadDb.I.

References _client_db, DownloadDb::Db::_filename, DownloadDb::Db::get_multifile_record_named(), INLINE, and write_client_db().

int DownloadDb::get_client_num_multifiles void   )  const [inline]
 

Definition at line 31 of file downloadDb.I.

References _server_db, DownloadDb::Db::get_num_multifiles(), and INLINE.

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

References _master_datagram, and length.

string DownloadDb::get_server_file_name string  mfname,
int  index
const [inline]
 

Definition at line 239 of file downloadDb.I.

HashVal DownloadDb::get_server_multifile_hash string  mfname  )  const
 

Return the hash value of the server file.

Definition at line 263 of file downloadDb.cxx.

References _client_db, _server_db, DownloadDb::Db::add_multifile_record(), DownloadDb::Db::get_multifile_record_named(), and PT.

string DownloadDb::get_server_multifile_name int  index  )  const [inline]
 

Definition at line 67 of file downloadDb.I.

References _client_db, and DownloadDb::Db::get_multifile_record_named().

Phase DownloadDb::get_server_multifile_phase string  mfname  )  const [inline]
 

Definition at line 92 of file downloadDb.I.

References _client_db, DownloadDb::Db::_filename, DownloadDb::Db::get_multifile_record_named(), INLINE, and write_client_db().

int DownloadDb::get_server_multifile_size string  mfname  )  const [inline]
 

Definition at line 149 of file downloadDb.I.

References _client_db, and Status_incomplete.

int DownloadDb::get_server_num_files string  mfname  )  const [inline]
 

Definition at line 227 of file downloadDb.I.

int DownloadDb::get_server_num_multifiles void   )  const [inline]
 

Definition at line 43 of file downloadDb.I.

References _client_db, DownloadDb::Db::get_multifile_name(), and INLINE.

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

References _master_datagram.

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

References _master_datagram, Datagram::append_data(), Datagram::clear(), DatagramIterator::get_int32(), and PN_int32.

void DownloadDb::output ostream &  out  )  const
 

Definition at line 130 of file downloadDb.cxx.

References _server_db.

DownloadDb::Db DownloadDb::read_db Ramfile file,
bool  want_server_info
 

Definition at line 385 of file downloadDb.cxx.

References _server_db.

DownloadDb::Db DownloadDb::read_db Filename file,
bool  want_server_info
 

Definition at line 346 of file downloadDb.cxx.

Referenced by DownloadDb().

bool DownloadDb::read_version_map istream &  read_stream  )  [protected]
 

Definition at line 1447 of file downloadDb.cxx.

void DownloadDb::server_add_file string  mfname,
string  fname
 

Definition at line 478 of file downloadDb.cxx.

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

Definition at line 464 of file downloadDb.cxx.

void DownloadDb::set_client_multifile_complete string  mfname  )  [inline]
 

Definition at line 188 of file downloadDb.I.

References _server_db, DownloadDb::Db::get_multifile_record_named(), and INLINE.

void DownloadDb::set_client_multifile_decompressed string  mfname  )  [inline]
 

Definition at line 201 of file downloadDb.I.

References _server_db, DownloadDb::Db::get_multifile_record_named(), and INLINE.

int DownloadDb::set_client_multifile_delta_size string  mfname,
int  size
[inline]
 

Definition at line 132 of file downloadDb.I.

References _server_db, DownloadDb::Db::get_multifile_record_named(), and INLINE.

void DownloadDb::set_client_multifile_extracted string  mfname  )  [inline]
 

Definition at line 214 of file downloadDb.I.

void DownloadDb::set_client_multifile_hash string  mfname,
HashVal  val
 

Set the hash value of file we are working on.

Definition at line 277 of file downloadDb.cxx.

void DownloadDb::set_client_multifile_incomplete string  mfname  )  [inline]
 

Definition at line 175 of file downloadDb.I.

References _client_db, DownloadDb::Db::_filename, DownloadDb::Db::get_multifile_record_named(), INLINE, Status_extracted, and write_client_db().

void DownloadDb::set_client_multifile_size string  mfname,
int  size
[inline]
 

Definition at line 118 of file downloadDb.I.

References _server_db, DownloadDb::Db::get_multifile_record_named(), and INLINE.

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

void DownloadDb::set_server_multifile_size string  mfname,
int  size
[inline]
 

Definition at line 162 of file downloadDb.I.

void DownloadDb::write ostream &  out  )  const
 

Definition at line 142 of file downloadDb.cxx.

References _client_db, and write_db().

bool DownloadDb::write_client_db Filename file  ) 
 

Definition at line 166 of file downloadDb.cxx.

References _client_db.

Referenced by get_client_multifile_size(), get_server_multifile_phase(), and set_client_multifile_incomplete().

bool DownloadDb::write_db Filename file,
Db  db,
bool  want_server_info
 

Definition at line 414 of file downloadDb.cxx.

References _server_db.

Referenced by write().

bool DownloadDb::write_server_db Filename file  ) 
 

Definition at line 179 of file downloadDb.cxx.

References Status_complete.

void DownloadDb::write_version_map ofstream &  write_stream  )  [protected]
 

Definition at line 1408 of file downloadDb.cxx.

void DownloadDb::write_version_map ostream &  out  )  const
 

Definition at line 1520 of file downloadDb.cxx.


Member Data Documentation

PN_uint32 DownloadDb::_bogus_magic_number = 0x11111111 [static]
 

Definition at line 39 of file downloadDb.cxx.

Db DownloadDb::_client_db
 

Definition at line 220 of file downloadDb.h.

Referenced by client_multifile_complete(), client_multifile_extracted(), DownloadDb(), get_client_multifile_phase(), get_client_multifile_size(), get_server_multifile_hash(), get_server_multifile_name(), get_server_multifile_phase(), get_server_multifile_size(), get_server_num_multifiles(), set_client_multifile_incomplete(), write(), write_client_db(), and ~DownloadDb().

PN_uint32 DownloadDb::_magic_number = 0xfeedfeed [static]
 

Definition at line 33 of file downloadDb.cxx.

Datagram DownloadDb::_master_datagram [protected]
 

Definition at line 243 of file downloadDb.h.

Referenced by get_num_versions(), has_version(), and insert_new_version().

Db DownloadDb::_server_db
 

Definition at line 221 of file downloadDb.h.

Referenced by client_multifile_decompressed(), DownloadDb(), get_client_multifile_name(), get_client_num_multifiles(), get_server_multifile_hash(), output(), read_db(), set_client_multifile_complete(), set_client_multifile_decompressed(), set_client_multifile_delta_size(), set_client_multifile_size(), and write_db().

VersionMap DownloadDb::_versions [protected]
 

Definition at line 242 of file downloadDb.h.


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:49:28 2003 for Panda by doxygen1.3