Forráskód Böngészése

*** empty log message ***

David Rose 25 éve
szülő
commit
0124053db8

+ 16 - 0
panda/src/pnmimage/pnmFileType.cxx

@@ -7,6 +7,8 @@
 
 #include <string_utils.h>
 #include <executionEnvironment.h>
+#include <bamReader.h>
+#include <bamWriter.h>
 
 bool PNMFileType::_did_init_pnm = false;
 TypeHandle PNMFileType::_type_handle;
@@ -152,3 +154,17 @@ init_pnm() {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileType::write_datagram
+//       Access: Public, Virtual
+//  Description: Fills the indicated datagram up with a binary
+//               representation of the current object, in preparation
+//               for writing to a Bam file.
+//
+//               None of the particular PNMFileType objects store any
+//               extra data--at least, not yet--so we just define this
+//               up here to do nothing.
+////////////////////////////////////////////////////////////////////
+void PNMFileType::
+write_datagram(BamWriter *, Datagram &) {
+}

+ 13 - 3
panda/src/pnmimage/pnmFileType.h

@@ -11,6 +11,7 @@
 #include "pnmimage_base.h"
 
 #include <typeHandle.h>
+#include <typedWriteable.h>
 
 class PNMReader;
 class PNMWriter;
@@ -21,7 +22,7 @@ class PNMWriter;
 //               represent particular image file types that PNMImage
 //               supports.
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA PNMFileType : public TypedObject {
+class EXPCL_PANDA PNMFileType : public TypedWriteable {
 protected:
   PNMFileType();
 
@@ -47,14 +48,23 @@ protected:
 private:
   static bool _did_init_pnm;
 
+
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory(void);
+  virtual void write_datagram(BamWriter *writer, Datagram &datagram); 
+
+protected:
+  static TypedWriteable *make_PNMFileType(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;
   }
   static void init_type() {
-    TypedObject::init_type();
+    TypedWriteable::init_type();
     register_type(_type_handle, "PNMFileType",
-                  TypedObject::get_class_type());
+                  TypedWriteable::get_class_type());
   }
   virtual TypeHandle get_type() const {
     return get_class_type();

+ 23 - 2
panda/src/pnmimage/pnmFileTypeRegistry.cxx

@@ -67,7 +67,7 @@ get_num_types() const {
 ////////////////////////////////////////////////////////////////////
 PNMFileType *PNMFileTypeRegistry::
 get_type(int n) const {
-  nassertr(n >= 0 && n < _types.size(), NULL);
+  nassertr(n >= 0 && n < (int)_types.size(), NULL);
   return _types[n];
 }
 
@@ -143,6 +143,25 @@ get_type_from_magic_number(const string &magic_number) const {
   return NULL;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeRegistry::get_type_by_handle
+//       Access: Public
+//  Description: Returns the PNMFileType instance stored in the
+//               registry for the given TypeHandle, e.g. as retrieved
+//               by a previous call to get_type() on the type
+//               instance.
+////////////////////////////////////////////////////////////////////
+PNMFileType *PNMFileTypeRegistry::
+get_type_by_handle(TypeHandle handle) const {
+  Handles::const_iterator hi;
+  hi = _handles.find(handle);
+  if (hi != _handles.end()) {
+    return (*hi).second;
+  }
+
+  return (PNMFileType *)NULL;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PNMFileTypeRegistry::write_types
 //       Access: Public
@@ -183,7 +202,8 @@ write_types(ostream &out, int indent_level) const {
 void PNMFileTypeRegistry::
 register_type(PNMFileType *type) {
   // Make sure we haven't already registered this type.
-  if (find(_types.begin(), _types.end(), type) != _types.end()) {
+  Handles::iterator hi = _handles.find(type->get_type());
+  if (hi != _handles.end()) {
     pnmimage_cat.warning()
       << "Attempt to register PNMFileType " << type->get_name() 
       << " (" << type->get_type() << ") more than once.\n";
@@ -191,6 +211,7 @@ register_type(PNMFileType *type) {
   }
 
   _types.push_back(type);
+  _handles.insert(Handles::value_type(type->get_type(), type));
 
   // Collect the unique extensions associated with the type.
   set<string> unique_extensions;

+ 4 - 2
panda/src/pnmimage/pnmFileTypeRegistry.h

@@ -10,8 +10,6 @@
 
 #include <typeHandle.h>
 
-#include <stdio.h>
-
 class PNMFileType;
 
 ////////////////////////////////////////////////////////////////////
@@ -33,6 +31,7 @@ public:
 
   PNMFileType *get_type_from_extension(const string &filename) const;
   PNMFileType *get_type_from_magic_number(const string &magic_number) const;
+  PNMFileType *get_type_by_handle(TypeHandle handle) const;
 
   void write_types(ostream &out, int indent_level = 0) const;
 
@@ -47,6 +46,9 @@ private:
   typedef map<string, Types> Extensions;
   Extensions _extensions;
 
+  typedef map<TypeHandle, PNMFileType *> Handles;
+  Handles _handles;
+
   bool _requires_sort;
 
   static PNMFileTypeRegistry *_global_ptr;

+ 15 - 0
panda/src/pnmimagetypes/config_pnmimagetypes.cxx

@@ -109,6 +109,7 @@ ConfigureFn(config_pnmimagetypes) {
       << "Invalid img-header-type: " << img_header_type_str << "\n";
   }
 
+  // Register each type with the PNMFileTypeRegistry.
   PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_ptr();
 
   tr->register_type(new PNMFileTypePNM);
@@ -123,4 +124,18 @@ ConfigureFn(config_pnmimagetypes) {
 #ifdef HAVE_JPEG
   tr->register_type(new PNMFileTypeJPG);
 #endif
+
+  // Also register with the Bam reader.
+  PNMFileTypePNM::register_with_read_factory();
+  PNMFileTypeSGI::register_with_read_factory();
+  PNMFileTypeAlias::register_with_read_factory();
+  PNMFileTypeRadiance::register_with_read_factory();
+  PNMFileTypeTIFF::register_with_read_factory();
+  PNMFileTypeYUV::register_with_read_factory();
+  PNMFileTypeIMG::register_with_read_factory();
+  PNMFileTypeSoftImage::register_with_read_factory();
+  PNMFileTypeBMP::register_with_read_factory();
+#ifdef HAVE_JPEG
+  PNMFileTypeJPG::register_with_read_factory();
+#endif
 }

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeAlias.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypeAlias.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 // Since Alias image files don't have a magic number, we'll make a
 // little sanity check on the size of the image.  If either the width
 // or height is larger than this, it must be bogus.
@@ -373,3 +376,32 @@ write_row(xel *row_data, xelval *) {
 }
 
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeAlias::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeAlias::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeAlias);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeAlias::make_PNMFileTypeAlias
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeAlias::
+make_PNMFileTypeAlias(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeAlias.h

@@ -49,6 +49,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeAlias(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeBMP.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypeBMP.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 static const char * const extensions[] = {
   "bmp"
 };
@@ -118,3 +121,32 @@ make_writer(FILE *file, bool owns_file) {
   return new Writer(this, file, owns_file);
 }
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeBMP::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeBMP::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeBMP);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeBMP::make_PNMFileTypeBMP
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeBMP::
+make_PNMFileTypeBMP(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeBMP.h

@@ -62,6 +62,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeBMP(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeIMG.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypeIMG.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 // Since raw image files don't have a magic number, we'll make a little
 // sanity check on the size of the image.  If either the width or height is
 // larger than this, it must be bogus.
@@ -332,3 +335,32 @@ write_row(xel *row_data, xelval *) {
 }
 
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeIMG::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeIMG::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeIMG);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeIMG::make_PNMFileTypeIMG
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeIMG::
+make_PNMFileTypeIMG(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeIMG.h

@@ -49,6 +49,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeIMG(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeJPG.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypeJPG.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 static const char * const extensions[] = {
   "jpg", "jpeg"
 };
@@ -119,3 +122,32 @@ make_writer(FILE *file, bool owns_file) {
   return new Writer(this, file, owns_file);
 }
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeJPG::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeJPG::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeJPG);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeJPG::make_PNMFileTypeJPG
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeJPG::
+make_PNMFileTypeJPG(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeJPG.h

@@ -75,6 +75,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeJPG(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypePNM.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypePNM.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 extern "C" {
 #include "../pnm/pnm.h"
 #include "../pnm/ppm.h"
@@ -316,3 +319,32 @@ write_row(xel *row_data, xelval *) {
 
   return true;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypePNM::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypePNM::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypePNM);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypePNM::make_PNMFileTypePNM
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypePNM::
+make_PNMFileTypePNM(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 8 - 0
panda/src/pnmimagetypes/pnmFileTypePNM.h

@@ -58,6 +58,14 @@ public:
     int _pnm_format;
   };
 
+
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypePNM(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeRadiance.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypeRadiance.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 extern "C" {
   #include  "color.h"
   #include  "resolu.h"
@@ -335,3 +338,32 @@ write_row(xel *row_data, xelval *) {
 
   return true;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeRadiance::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeRadiance::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeRadiance);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeRadiance::make_PNMFileTypeRadiance
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeRadiance::
+make_PNMFileTypeRadiance(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeRadiance.h

@@ -52,6 +52,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeRadiance(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeSGI.cxx

@@ -7,6 +7,9 @@
 #include "config_pnmimagetypes.h"
 #include "sgi.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 static const char * const extensions[] = {
   "rgb", "rgba", "sgi"
 };
@@ -122,3 +125,32 @@ make_writer(FILE *file, bool owns_file) {
   return new Writer(this, file, owns_file);
 }
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeSGI::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeSGI::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeSGI);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeSGI::make_PNMFileTypeSGI
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeSGI::
+make_PNMFileTypeSGI(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeSGI.h

@@ -97,6 +97,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeSGI(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx

@@ -6,6 +6,9 @@
 #include "pnmFileTypeSoftImage.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 static const float imageVersionNumber = 3.0;
 static const int imageCommentLength = 80;
 static const char imageComment[imageCommentLength+1] =
@@ -745,3 +748,32 @@ write_row(xel *row_data, xelval *alpha_data) {
 }
 
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeSoftImage::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeSoftImage::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeSoftImage);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeSoftImage::make_PNMFileTypeSoftImage
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeSoftImage::
+make_PNMFileTypeSoftImage(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeSoftImage.h

@@ -56,6 +56,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeSoftImage(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 36 - 0
panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx

@@ -6,6 +6,13 @@
 #include "pnmFileTypeTIFF.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
+// Tiff will want to re-typedef these things.
+#define int32 tiff_int32
+#define uint32 tiff_uint32
+
 extern "C" {
 #include "../pnm/ppmcmap.h"
 #include "../tiff/tiff.h"
@@ -777,3 +784,32 @@ write_data(xel *array, xelval *alpha) {
 
   return _y_size;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeTIFF::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeTIFF::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeTIFF);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeTIFF::make_PNMFileTypeTIFF
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeTIFF::
+make_PNMFileTypeTIFF(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeTIFF.h

@@ -61,6 +61,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeTIFF(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 32 - 0
panda/src/pnmimagetypes/pnmFileTypeYUV.cxx

@@ -51,6 +51,9 @@
 #include "pnmFileTypeYUV.h"
 #include "config_pnmimagetypes.h"
 
+#include <pnmFileTypeRegistry.h>
+#include <bamReader.h>
+
 /* x must be signed for the following to work correctly */
 #define limit(x) (xelval)(((x>0xffffff)?0xff0000:((x<=0xffff)?0:x&0xff0000))>>16)
 
@@ -381,3 +384,32 @@ write_row(xel *row_data, xelval *) {
 }
 
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeYUV::register_with_read_factory
+//       Access: Public, Static
+//  Description: Registers the current object as something that can be
+//               read from a Bam file.
+////////////////////////////////////////////////////////////////////
+void PNMFileTypeYUV::
+register_with_read_factory() {
+  BamReader::get_factory()->
+    register_factory(get_class_type(), make_PNMFileTypeYUV);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMFileTypeYUV::make_PNMFileTypeYUV
+//       Access: Protected, Static
+//  Description: This method is called by the BamReader when an object
+//               of this type is encountered in a Bam file; it should
+//               allocate and return a new object with all the data
+//               read.
+//
+//               In the case of the PNMFileType objects, since these
+//               objects are all shared, we just pull the object from
+//               the registry.
+////////////////////////////////////////////////////////////////////
+TypedWriteable *PNMFileTypeYUV::
+make_PNMFileTypeYUV(const FactoryParams &params) {
+  return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
+}

+ 7 - 0
panda/src/pnmimagetypes/pnmFileTypeYUV.h

@@ -57,6 +57,13 @@ public:
   };
 
 
+  // The TypedWriteable interface follows.
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWriteable *make_PNMFileTypeYUV(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 31 - 6
panda/src/putil/bamReader.cxx

@@ -239,12 +239,23 @@ read_object(void)
 ////////////////////////////////////////////////////////////////////
 //     Function: BamReader::read_pointer
 //       Access: Public
-//  Description: Utility function provided to correctly read in objects
-//               from the Datagram source, that any other object contains
-//               pointers to.  Will correctly handle all circular references
-//               Any caller of this function should pass a pointer to itself
-//               because the pointer request will be stored and completed
-//               at a later pointer when the object is actually generated
+//  Description: The interface for reading a pointer to another object
+//               from a Bam file.  Objects reading themselves from a
+//               Bam file should call this when they expect to read a
+//               pointer, passing in the datagram iterator and a
+//               pointer to their own object, i.e. 'this'.
+//
+//               Rather than returning a pointer immediately, this
+//               function reads the internal pointer information from
+//               the datagram and queues up the request.  The pointer
+//               itself may not be available until later (it may be a
+//               pointer to an object that appears later in the Bam
+//               file).  Later, when all pointers are available, the
+//               complete_pointers() callback function will be called
+//               with an array of actual pointers, one for time
+//               read_pointer() was called.  It is then the calling
+//               object's responsibilty to store these pointers in the
+//               object properly.
 ////////////////////////////////////////////////////////////////////
 void BamReader::
 read_pointer(DatagramIterator& scan, TypedWriteable* forWhom)
@@ -264,6 +275,20 @@ read_pointer(DatagramIterator& scan, TypedWriteable* forWhom)
     queue(objId);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BamReader::read_pointers
+//       Access: Public
+//  Description: A convenience function to read a contiguous list of
+//               pointers.  This is equivalent to calling
+//               read_pointer() count times.
+////////////////////////////////////////////////////////////////////
+void BamReader::
+read_pointers(DatagramIterator &scan, TypedWriteable *forWhom, int count) {
+  for (int i = 0; i < count; i++) {
+    read_pointer(scan, forWhom);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: BamReader::register_finalize
 //       Access: Public

+ 1 - 0
panda/src/putil/bamReader.h

@@ -65,6 +65,7 @@ public:
   //points to, it needs to pass a reference to itself, that BamReader
   //can register in itself for later "fixing"
   void read_pointer(DatagramIterator &scan, TypedWriteable* forWhom);
+  void read_pointers(DatagramIterator &scan, TypedWriteable* forWhom, int count);
 
   //At any time you can call this function to try and resolve all
   //outstanding pointer requests.  Will resolve all requests that