From eb2b49b8a079cee99d608ea60d20f51582e3d48e Mon Sep 17 00:00:00 2001 From: Mike Goslin Date: Fri, 13 Oct 2000 19:29:25 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/downloader/downloadDb.cxx | 28 ++++++++++++++++++++++++--- panda/src/downloader/downloadDb.h | 8 ++++++++ panda/src/putil/vector_ulong.cxx | 11 +++++++++++ panda/src/putil/vector_ulong.h | 30 +++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 panda/src/putil/vector_ulong.cxx create mode 100644 panda/src/putil/vector_ulong.h diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index cce1b1c84c..96d5e6b212 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -911,9 +911,31 @@ output(ostream &out) const { out << " FileRecord: " << _name << " version: " << _version << endl; } - - - +//////////////////////////////////////////////////////////////////// +// Function: DownloadDb::add_version +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void DownloadDb:: +add_version(const Filename &name, ulong hash, int version) { + int name_code = atoi(name.get_fullpath().c_str()); + _versions[name_code][version] = hash; +} + +//////////////////////////////////////////////////////////////////// +// Function: DownloadDb::get_version +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +int DownloadDb:: +get_version(const Filename &name, ulong hash) { + int name_code = atoi(name.get_fullpath().c_str()); + vector_ulong ulvec = _versions[name_code]; + vector_ulong::iterator i = find(ulvec.begin(), ulvec.end(), hash); + if (i != ulvec.end()) + return (ulvec.begin() - i); + return -1; +} diff --git a/panda/src/downloader/downloadDb.h b/panda/src/downloader/downloadDb.h index 2145754c4f..d9502840d9 100644 --- a/panda/src/downloader/downloadDb.h +++ b/panda/src/downloader/downloadDb.h @@ -17,6 +17,7 @@ #include #include #include +#include /* @@ -193,6 +194,13 @@ public: // Magic number for knowing this is a download Db static PN_uint32 _magic_number; + typedef vector vector_ulong; + typedef map VersionMap; + void add_version(const Filename &name, ulong hash, int version); + int get_version(const Filename &name, ulong hash); + +protected: + VersionMap _versions; }; INLINE ostream &operator << (ostream &out, const DownloadDb &dldb) { diff --git a/panda/src/putil/vector_ulong.cxx b/panda/src/putil/vector_ulong.cxx new file mode 100644 index 0000000000..cdca10cc49 --- /dev/null +++ b/panda/src/putil/vector_ulong.cxx @@ -0,0 +1,11 @@ +// Filename: vector_ulong.cxx +// Created by: drose (10May00) +// +//////////////////////////////////////////////////////////////////// + +#include "vector_ulong.h" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma implementation +#endif diff --git a/panda/src/putil/vector_ulong.h b/panda/src/putil/vector_ulong.h new file mode 100644 index 0000000000..4af5750a28 --- /dev/null +++ b/panda/src/putil/vector_ulong.h @@ -0,0 +1,30 @@ +// Filename: vector_ulong.h +// Created by: drose (10May00) +// +//////////////////////////////////////////////////////////////////// + +#ifndef VECTOR_ULONG_H +#define VECTOR_ULONG_H + +#include + +#include + +//////////////////////////////////////////////////////////////////// +// Class : vector_ushort +// Description : A vector of ushorts. This class is defined once here, +// and exported to PANDA.DLL; other packages that want +// to use a vector of this type (whether they need to +// export it or not) should include this header file, +// rather than defining the vector again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, std::vector) +typedef vector vector_ulong; + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma interface +#endif + +#endif