瀏覽代碼

*** empty log message ***

Mike Goslin 25 年之前
父節點
當前提交
eb2b49b8a0

+ 24 - 2
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;
+}
 
 
 

+ 8 - 0
panda/src/downloader/downloadDb.h

@@ -17,6 +17,7 @@
 #include <vector>
 #include <string>
 #include <pointerTo.h>
+#include <map>
 
 
 /*
@@ -193,6 +194,13 @@ public:
   // Magic number for knowing this is a download Db
   static PN_uint32 _magic_number;  
 
+  typedef vector<unsigned long> vector_ulong;
+  typedef map<int, vector_ulong> 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) {

+ 11 - 0
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

+ 30 - 0
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 <pandabase.h>
+
+#include <vector>
+
+////////////////////////////////////////////////////////////////////
+//       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<unsigned long>)
+typedef vector<unsigned long> vector_ulong;
+
+// Tell GCC that we'll take care of the instantiation explicitly here.
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#endif