Revision: 44725
          http://brlcad.svn.sourceforge.net/brlcad/?rev=44725&view=rev
Author:   davidloman
Date:     2011-06-02 16:07:26 +0000 (Thu, 02 Jun 2011)

Log Message:
-----------
Modify iDataSource interface a bit.  Added/fixed lots of functionality to 
FileDataSource.

Modified Paths:
--------------
    geomcore/trunk/include/FileDataSource.h
    geomcore/trunk/include/IDataSource.h
    geomcore/trunk/include/SvnDataSource.h
    geomcore/trunk/src/GS/FileDataSource.cxx
    geomcore/trunk/src/GS/SvnDataSource.cxx

Modified: geomcore/trunk/include/FileDataSource.h
===================================================================
--- geomcore/trunk/include/FileDataSource.h     2011-06-02 16:05:38 UTC (rev 
44724)
+++ geomcore/trunk/include/FileDataSource.h     2011-06-02 16:07:26 UTC (rev 
44725)
@@ -35,48 +35,57 @@
 class FileDataSource : public IDataSource
 {
 public:
-       FileDataSource(std::string repoPath);
-       virtual ~FileDataSource();
-       bool init();
+  FileDataSource(std::string repoPath);
+  virtual ~FileDataSource();
+  bool init();
 
-       /*
-        * 'GET' ers
-        */
+  /*
+   * 'GET' ers
+   */
 
-       /* get a directory listing or a child list */
-       int getListing(std::string path, std::list<std::string>* list);
+  /* get a directory listing or a child list */
+  int getListing(std::string path, std::list<std::string>* list);
 
-       /* Get a set of objects */
-       std::list<BRLCAD::MinimalObject*>* getObjs(std::string path, bool 
recurse);
+  /**
+   * Using provided database 'path' to a db object,
+   * fill 'list' with the children objects
+   *
+   * Return value:
+   *  >=0 number of children objs added to 'list'
+   *  <0 error:
+   *     -1 filesystem Path not valid.
+   *     -2 geometry Path not valid.
+   *     -3 Valid path, but corrupt Object Data.
+   */
+  int getObjs(std::string path, std::list<ExtObject*>* objs, bool recurse);
 
-       /*
-        * 'PUT' ers
-        */
+  /*
+   * 'PUT' ers
+   */
 
-       /* Put a single BRLCAD::Object */
-       bool putObj(std::string path, BRLCAD::MinimalObject* obj);
+  /* Put a single BRLCAD::Object */
+  bool putObj(std::string path, ExtObject* obj);
 
-       static int getFsDirList(std::string, std::list<std::string>*);
+  static int getFsDirList(std::string, std::list<std::string>*);
 
-       /**
-        * Get a list of the names of the children for object 'gPath'
-        * in the brlcad file 'fsPath'
-        *
-        * Return values:
-        *      >=0 Number of items added to 'list'
-         *      <0 error:
-         *              -1 filesystem Path not valid.
-         *              -2 geometry Path not valid.
-         *              -3 Valid path, but corrupt Object Data.
-        */
-       static int getGChildList(
-           std::string fsPath,
-           std::string gPath,
-           std::list<std::string>* list);
+  /**
+   * Get a list of the names of the children for object 'gPath'
+   * in the brlcad file 'fsPath'
+   *
+   * Return values:
+   *      >=0 Number of items added to 'list'
+   *      <0 error:
+   *              -1 filesystem Path not valid.
+   *              -2 geometry Path not valid.
+   *              -3 Valid path, but corrupt Object Data.
+   */
+  static int getGChildList(
+      std::string fsPath,
+      std::string gPath,
+      std::list<std::string>* list);
 
 private:
-       std::string repoPath;
-
+  std::string repoPath;
 };
 
 #endif /* __FILEDATASOURCE_H__ */

Modified: geomcore/trunk/include/IDataSource.h
===================================================================
--- geomcore/trunk/include/IDataSource.h        2011-06-02 16:05:38 UTC (rev 
44724)
+++ geomcore/trunk/include/IDataSource.h        2011-06-02 16:07:26 UTC (rev 
44725)
@@ -27,7 +27,7 @@
 #ifndef __IDATASOURCE_H__
 #define __IDATASOURCE_H__
 
-#include <MinimalObject.h>
+#include "ExtObject.h"
 #include "Account.h"
 #include <map>
 #include <list>
@@ -48,14 +48,14 @@
        virtual int getListing(std::string path, std::list<std::string>* list) 
= 0;
 
        /* Get BRLCAD::MinimalObject s */
-       virtual std::list<BRLCAD::MinimalObject*>* getObjs(std::string path, 
bool recurse) = 0;
+       virtual int getObjs(std::string path, std::list<ExtObject*>* objs, bool 
recurse) = 0;
 
        /*
         * 'PUT' ers
         */
 
        /* Put a single BRLCAD::MinimalObject */
-       virtual bool putObj(std::string path, BRLCAD::MinimalObject* ext) = 0;
+       virtual bool putObj(std::string path, ExtObject* obj) = 0;
 };
 
 #endif /* __IDATASOURCE_H__ */

Modified: geomcore/trunk/include/SvnDataSource.h
===================================================================
--- geomcore/trunk/include/SvnDataSource.h      2011-06-02 16:05:38 UTC (rev 
44724)
+++ geomcore/trunk/include/SvnDataSource.h      2011-06-02 16:07:26 UTC (rev 
44725)
@@ -43,9 +43,9 @@
         std::list<std::string>* getListing(std::string path);
 
        /* Get a set of BRLCAD::MinimalObject */
-       std::list<BRLCAD::MinimalObject*>* getObjs(std::string path, bool 
recurse);
+       int getObjs(std::string path, std::list<ExtObject*>* objs, bool 
recurse);
 
-       virtual bool putObj(std::string path, BRLCAD::MinimalObject* ext) = 0;
+       virtual bool putObj(std::string path, ExtObject* ext) = 0;
 
 private:
        std::string repoPath;

Modified: geomcore/trunk/src/GS/FileDataSource.cxx
===================================================================
--- geomcore/trunk/src/GS/FileDataSource.cxx    2011-06-02 16:05:38 UTC (rev 
44724)
+++ geomcore/trunk/src/GS/FileDataSource.cxx    2011-06-02 16:07:26 UTC (rev 
44725)
@@ -52,13 +52,11 @@
 FileDataSource::getListing(std::string path, std::list<std::string>* list)
 {
   std::string absPath = "";
+  std::string fsPath = "";
+  std::string gPath = "";
+  int totalSteps = 0;
+
   StringUtils::combinePaths(&absPath, &this->repoPath, &path);
-
-  int pathStep = 0;
-
-  std::string fsPath;
-  std::string gPath;
-  int totalSteps = 0;
   int splitPoint = StringUtils::splitPathAtFile(absPath, &fsPath, &gPath, 
&totalSteps);
 
   if (splitPoint == totalSteps) {
@@ -75,47 +73,53 @@
 }
 
 /* Get a set of BRLCAD::MinimalObjects */
-std::list<BRLCAD::MinimalObject*>*
-FileDataSource::getObjs(std::string relPath, bool recurse)
+int
+FileDataSource::getObjs(std::string path, std::list<ExtObject*>* extList,
+    bool recurse)
 {
-       std::string absPath = "";
+  std::list<std::string> nameList;
+  std::string absPath = "";
+  std::string fsPath = "";
+  std::string gPath = "";
+  int totalSteps = 0;
+  int retVal = 0;
 
-       StringUtils::combinePaths(&absPath, &this->repoPath, &relPath);
+  StringUtils::combinePaths(&absPath, &this->repoPath, &path);
+  int splitPoint = StringUtils::splitPathAtFile(absPath, &fsPath, &gPath,
+      &totalSteps);
 
-       //figure out what kind of path we are dealing with;
-       if (StringUtils::isFileOrDir(absPath.c_str()) == 0)
-               return NULL;
+  if (splitPoint == totalSteps) {
+      /* We ended the path on a FS Dir or File */
+      int type = StringUtils::isFileOrDir(fsPath.c_str());
+      if (type <= 0)
+        return -1; /* 0 == NOT EXIST */
+      if (type == 1)
+        /* TODO This will need to db_concat several db's together */
+        return -1;  /* 1 == DIR */
 
-       if (StringUtils::isFileOrDir(absPath.c_str()) == 1)
-               return NULL;
+      /* Allow type == 2 (aka G File) to fall through to G processing code. */
+    }
 
-       std::list<BRLCAD::MinimalObject*>* out = NULL;
+  /* Open DB */
+  BrlcadDb* db = BrlcadDb::makeDb(fsPath);
+  if (db == NULL) return BrlcadDb::FS_PATH_NOT_VALID;
 
-       BRLCAD::MinimalDatabase md;
-       bool loaded = md.Load(absPath);
+  /* Get objects at 'gPath' */
+  retVal = db->list(gPath, &nameList);
+  if (retVal <=0) return retVal;
 
-       if (!loaded) {
-            perror(strerror(errno));
-            Logger::getInstance()->logINFO("FileDataSource", "Failed to 
load.");
-           return out;
-       }
-        Logger::getInstance()->logINFO("FileDataSource", "File seemingly 
loaded.");
+  /* list is populated, get objects */
+  retVal = db->getExtObjs(&nameList, extList, recurse);
 
-/*
-       if (recurse)
-         out = md->getAllObjects();
-       else
-         out = md->getAllTopObjects();
-*/
+  return retVal;
+}
 
-       out = md.getAllObjs();
 
-       return out;
-}
 
+
 /* Put a single BRLCAD::MinimalObject */
 bool
-FileDataSource::putObj(std::string path, BRLCAD::MinimalObject* obj)
+FileDataSource::putObj(std::string path, ExtObject* obj)
 {
     return true;
 }

Modified: geomcore/trunk/src/GS/SvnDataSource.cxx
===================================================================
--- geomcore/trunk/src/GS/SvnDataSource.cxx     2011-06-02 16:05:38 UTC (rev 
44724)
+++ geomcore/trunk/src/GS/SvnDataSource.cxx     2011-06-02 16:07:26 UTC (rev 
44725)
@@ -42,16 +42,16 @@
 }
 
 /* Get a set of BRLCAD::MinimalObjects */
-std::list<BRLCAD::MinimalObject*>*
-SvnDataSource::getObjs(std::string path, bool recurse)
+int
+SvnDataSource::getObjs(std::string path, std::list<ExtObject*>* objs, bool 
recurse)
 {
-
+  return -1;
 }
 
 bool
-SvnDataSource::putObj(std::string path, BRLCAD::MinimalObject* ext)
+SvnDataSource::putObj(std::string path, ExtObject* ext)
 {
-
+  return false;
 }
 
 /*


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

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to