Browse Source

Add list_contents function that takes no parameters which outputs to cout thus making it callable in Python.
Format the output so it is a bit easier to read.

aignacio_sf 19 years ago
parent
commit
af8a72f828
3 changed files with 18 additions and 3 deletions
  1. 10 0
      panda/src/pgraph/modelPool.I
  2. 7 3
      panda/src/pgraph/modelPool.cxx
  3. 1 0
      panda/src/pgraph/modelPool.h

+ 10 - 0
panda/src/pgraph/modelPool.I

@@ -157,6 +157,16 @@ list_contents(ostream &out) {
   get_ptr()->ns_list_contents(out);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: ModelPool::list_contents
+//       Access: Public, Static
+//  Description: Lists the contents of the model pool to cout.
+////////////////////////////////////////////////////////////////////
+INLINE void ModelPool::
+list_contents() {
+  get_ptr()->ns_list_contents(cout);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: ModelPool::Constructor
 //       Access: Private

+ 7 - 3
panda/src/pgraph/modelPool.cxx

@@ -218,12 +218,16 @@ void ModelPool::
 ns_list_contents(ostream &out) const {
   MutexHolder holder(_lock);
 
-  out << _models.size() << " models:\n";
+  out << "model pool contents:\n";
+  
   Models::const_iterator ti;
   for (ti = _models.begin(); ti != _models.end(); ++ti) {
-    out << "  " << (*ti).first
-        << " (count = " << (*ti).second->get_model_ref_count() << ")\n";
+    out << (*ti).first << "\n"
+        << "  (count = " << (*ti).second->get_model_ref_count() 
+        << ")\n";
   }
+  
+  out << "total number of models: " << _models.size() << "\n";
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 0
panda/src/pgraph/modelPool.h

@@ -67,6 +67,7 @@ PUBLISHED:
   INLINE static int garbage_collect();
 
   INLINE static void list_contents(ostream &out);
+  INLINE static void list_contents();
   static void write(ostream &out);
 
 private: