Browse Source

rename LoaderOptions methods for clarity; add output

David Rose 19 years ago
parent
commit
ec042275fe

+ 2 - 2
panda/src/pgraph/loader.cxx

@@ -189,7 +189,7 @@ output(ostream &out) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 PT(PandaNode) Loader::
 PT(PandaNode) Loader::
 load_file(const Filename &filename, const LoaderOptions &options) const {
 load_file(const Filename &filename, const LoaderOptions &options) const {
-  if (options.allow_ram_cache()) {
+  if (options.get_allow_ram_cache()) {
     // If we're allowing a RAM cache (and we don't have any other
     // If we're allowing a RAM cache (and we don't have any other
     // funny options), use the ModelPool to load the file.
     // funny options), use the ModelPool to load the file.
     PT(PandaNode) node = ModelPool::load_model(filename, options);
     PT(PandaNode) node = ModelPool::load_model(filename, options);
@@ -261,7 +261,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const {
 
 
     PT(BamCacheRecord) record;
     PT(BamCacheRecord) record;
 
 
-    if (cache->get_active() && options.allow_disk_cache()) {
+    if (cache->get_active() && options.get_allow_disk_cache()) {
       // See if the texture can be found in the on-disk cache, if it is
       // See if the texture can be found in the on-disk cache, if it is
       // active.
       // active.
       record = cache->lookup(path, "bam");
       record = cache->lookup(path, "bam");

+ 4 - 4
panda/src/pgraph/loaderOptions.I

@@ -70,26 +70,26 @@ get_flags() const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: LoaderOptions::allow_disk_cache
+//     Function: LoaderOptions::get_allow_disk_cache
 //       Access: Published
 //       Access: Published
 //  Description: Returns true if the loader flags allow retrieving the
 //  Description: Returns true if the loader flags allow retrieving the
 //               model from the on-disk bam cache (if it is enabled),
 //               model from the on-disk bam cache (if it is enabled),
 //               false otherwise.
 //               false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE bool LoaderOptions::
 INLINE bool LoaderOptions::
-allow_disk_cache() const {
+get_allow_disk_cache() const {
   return (_flags & LF_no_disk_cache) == 0;
   return (_flags & LF_no_disk_cache) == 0;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: LoaderOptions::allow_ram_cache
+//     Function: LoaderOptions::get_allow_ram_cache
 //       Access: Published
 //       Access: Published
 //  Description: Returns true if the loader flags allow retrieving the
 //  Description: Returns true if the loader flags allow retrieving the
 //               model from the in-memory ModelPool cache, false
 //               model from the in-memory ModelPool cache, false
 //               otherwise.
 //               otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE bool LoaderOptions::
 INLINE bool LoaderOptions::
-allow_ram_cache() const {
+get_allow_ram_cache() const {
   return ((_flags & (LF_no_ram_cache | LF_convert_anim)) == 0 &&
   return ((_flags & (LF_no_ram_cache | LF_convert_anim)) == 0 &&
           (_flags & LF_search) != 0);
           (_flags & LF_search) != 0);
 }
 }

+ 44 - 0
panda/src/pgraph/loaderOptions.cxx

@@ -17,3 +17,47 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "loaderOptions.h"
 #include "loaderOptions.h"
+#include "indent.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: LoaderOptions::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void LoaderOptions::
+output(ostream &out) const {
+  out << "LoaderOptions(";
+  string sep = "";
+  write_flag(out, sep, "LF_search", LF_search);
+  write_flag(out, sep, "LF_report_errors", LF_report_errors);
+  if ((_flags & LF_convert_anim) == LF_convert_anim) {
+    write_flag(out, sep, "LF_convert_anim", LF_convert_anim);
+  } else {
+    write_flag(out, sep, "LF_convert_skeleton", LF_convert_skeleton);
+    write_flag(out, sep, "LF_convert_channels", LF_convert_channels);
+  }
+  if ((_flags & LF_no_cache) == LF_no_cache) {
+    write_flag(out, sep, "LF_no_cache", LF_no_cache);
+  } else {
+    write_flag(out, sep, "LF_no_disk_cache", LF_no_disk_cache);
+    write_flag(out, sep, "LF_no_ram_cache", LF_no_ram_cache);
+  }
+  if (sep.empty()) {
+    out << "0";
+  }
+  out << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LoaderOptions::write_flag
+//       Access: Private
+//  Description: Used to implement output().
+////////////////////////////////////////////////////////////////////
+void LoaderOptions::
+write_flag(ostream &out, string &sep, 
+           const string &flag_name, int flag) const {
+  if ((_flags & flag) == flag) {
+    out << sep << flag_name;
+    sep = " | ";
+  }
+}

+ 12 - 3
panda/src/pgraph/loaderOptions.h

@@ -48,13 +48,22 @@ PUBLISHED:
   INLINE void set_flags(int flags);
   INLINE void set_flags(int flags);
   INLINE int get_flags() const;
   INLINE int get_flags() const;
 
 
-  INLINE bool allow_disk_cache() const;
-  INLINE bool allow_ram_cache() const;
+  INLINE bool get_allow_disk_cache() const;
+  INLINE bool get_allow_ram_cache() const;
 
 
-private:  
+  void output(ostream &out) const;
+
+private:
+  void write_flag(ostream &out, string &sep, 
+                  const string &flag_name, int flag) const;
   int _flags;
   int _flags;
 };
 };
 
 
+INLINE ostream &operator << (ostream &out, const LoaderOptions &opts) {
+  opts.output(out);
+  return out;
+}
+
 #include "loaderOptions.I"
 #include "loaderOptions.I"
 
 
 #endif
 #endif