Revision: 44695
          http://brlcad.svn.sourceforge.net/brlcad/?rev=44695&view=rev
Author:   davidloman
Date:     2011-05-25 19:53:59 +0000 (Wed, 25 May 2011)

Log Message:
-----------
Implement a bulk getter: getExtObjects(...).  works on a list of names and 
provides a list of ExtObject objects.

Modified Paths:
--------------
    geomcore/trunk/include/BrlcadDb.h
    geomcore/trunk/src/GS/BrlcadDb.cxx

Modified: geomcore/trunk/include/BrlcadDb.h
===================================================================
--- geomcore/trunk/include/BrlcadDb.h   2011-05-25 19:34:16 UTC (rev 44694)
+++ geomcore/trunk/include/BrlcadDb.h   2011-05-25 19:53:59 UTC (rev 44695)
@@ -73,6 +73,17 @@
    */
   ExtObject* getExtObj(const std::string name);
 
+  /**
+   * Bulk build of ExtObjects from 'nameList' and place them into extList
+   *
+   * Return Values:
+   *    0 = Success
+   *    -1 = db_open() failed
+   *    -2 = either nameList or extList was NULL
+   */
+  int getExtObjs(const std::list<std::string>* nameList,
+      std::list<ExtObject*>* extList);
+
 private:
   std::string path;
   struct db_i* dbip;
@@ -110,16 +121,22 @@
 
    /**
      * Performs the actual name lookup. To be used internally only.
-     * NOTE:  Does not call open() or close().  See list().
+     * NOTE:  Does not call open() or close().  See contains().
      */
    bool _contains(const std::string name);
 
    /**
      * Performs the actual name lookup. To be used internally only.
-     * NOTE:  Does not call open() or close().  See list().
+     * NOTE:  Does not call open() or close().  See getExtObj().
      */
    ExtObject* _getExtObj(const std::string name);
 
+   /**
+      * Performs the actual name lookups. To be used internally only.
+      * NOTE:  Does not call open() or close().  See getExtObjs().
+      */
+   int _getExtObjs(const std::list<std::string>* nameList,
+       std::list<ExtObject*>* extList);
 
 };
 

Modified: geomcore/trunk/src/GS/BrlcadDb.cxx
===================================================================
--- geomcore/trunk/src/GS/BrlcadDb.cxx  2011-05-25 19:34:16 UTC (rev 44694)
+++ geomcore/trunk/src/GS/BrlcadDb.cxx  2011-05-25 19:53:59 UTC (rev 44695)
@@ -23,6 +23,7 @@
 
 #include "BrlcadDb.h"
 #include "StringUtils.h"
+#include "Logger.h"
 
 #include "db.h"
 #include "raytrace.h"
@@ -263,11 +264,49 @@
       return NULL;
   }
 
-  return new ExtObject(name, ext);
+  return new ExtObject(name, extp);
 }
 
+int
+BrlcadDb::getExtObjs(const std::list<std::string>* nameList,
+    std::list<ExtObject*>* extList)
+{
+  if (nameList == NULL || extList == NULL) return -2;
+  if (this->open() == false) return -1;
 
+  int retVal = this->_getExtObjs(nameList,extList);
+  this->close();
+  return retVal;
+}
+int
+BrlcadDb::_getExtObjs(const std::list<std::string>* nameList,
+    std::list<ExtObject*>* extList)
+{
+  if (nameList == NULL || extList == NULL) return -2;
 
+  ExtObject* extObj = NULL;
+  std::string strObj = "";
+  std::list<std::string>::const_iterator it = nameList->begin();
+
+  for (; it != nameList->end();++it) {
+      strObj = *it;
+
+      if (strObj.length() <=0)
+        continue;
+
+      extObj = this->_getExtObj(strObj);
+      if (extObj == NULL) {
+        /* ERROR! */
+        Logger::getInstance()->logERROR("BrlcadDb", "No extObject returned 
for: " + strObj);
+      } else {
+          extList->push_back(extObj);
+      }
+  }
+  return 0;
+}
+
+
+
 // Local Variables:
 // tab-width: 8
 // mode: C++


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to