Revision: 44621
          http://brlcad.svn.sourceforge.net/brlcad/?rev=44621&view=rev
Author:   davidloman
Date:     2011-05-17 17:09:03 +0000 (Tue, 17 May 2011)

Log Message:
-----------
Clean up the IDataSource interface a tad.

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

Modified: geomcore/trunk/include/FileDataSource.h
===================================================================
--- geomcore/trunk/include/FileDataSource.h     2011-05-16 18:11:48 UTC (rev 
44620)
+++ geomcore/trunk/include/FileDataSource.h     2011-05-17 17:09:03 UTC (rev 
44621)
@@ -43,8 +43,8 @@
         * 'GET' ers
         */
 
-       /* Get a single BRLCAD::MinimalObject */
-       BRLCAD::MinimalObject* getObj(std::string path);
+       /* get a directory listing or a child list */
+       std::list<std::string>* getListing(std::string path);
 
        /* Get a set of objects */
        std::list<BRLCAD::MinimalObject*>* getObjs(std::string path, bool 
recurse);
@@ -65,9 +65,11 @@
         * 2 == exists and is a File
         */
        static int existsFileOrDir(const char* path);
+
+        static void buildFullPath(std::string* out, std::string* base, 
std::string* path);
+        static void cleanString(std::string* out);
 private:
        std::string repoPath;
-
        std::list<std::string> locks;
 };
 

Modified: geomcore/trunk/include/IDataSource.h
===================================================================
--- geomcore/trunk/include/IDataSource.h        2011-05-16 18:11:48 UTC (rev 
44620)
+++ geomcore/trunk/include/IDataSource.h        2011-05-17 17:09:03 UTC (rev 
44621)
@@ -44,10 +44,10 @@
         * 'GET' ers
         */
 
-       /* Get a single BRLCAD::MinimalObject */
-       virtual BRLCAD::MinimalObject* getObj(std::string path) = 0;
+       /* get a directory listing or a child list */
+       virtual std::list<std::string>* getListing(std::string path) = 0;
 
-       /* Get a set of BRLCAD::MinimalObjects */
+       /* Get BRLCAD::MinimalObject s */
        virtual std::list<BRLCAD::MinimalObject*>* getObjs(std::string path, 
bool recurse) = 0;
 
        /*

Modified: geomcore/trunk/include/SvnDataSource.h
===================================================================
--- geomcore/trunk/include/SvnDataSource.h      2011-05-16 18:11:48 UTC (rev 
44620)
+++ geomcore/trunk/include/SvnDataSource.h      2011-05-17 17:09:03 UTC (rev 
44621)
@@ -39,8 +39,8 @@
        SvnDataSource(std::string repoPath);
        virtual ~SvnDataSource();
 
-       /* Get a single BRLCAD::MinimalObject */
-       BRLCAD::MinimalObject* getObj(std::string path);
+        /* get a directory listing or a child list */
+        std::list<std::string>* getListing(std::string path);
 
        /* Get a set of BRLCAD::MinimalObject */
        std::list<BRLCAD::MinimalObject*>* getObjs(std::string path, bool 
recurse);

Modified: geomcore/trunk/src/GS/DataManager.cxx
===================================================================
--- geomcore/trunk/src/GS/DataManager.cxx       2011-05-16 18:11:48 UTC (rev 
44620)
+++ geomcore/trunk/src/GS/DataManager.cxx       2011-05-17 17:09:03 UTC (rev 
44621)
@@ -168,6 +168,7 @@
           log->logERROR("DataManager","Failed to send CHUNK.  Socket closed?");
           break;
       }
+      usleep(1); /* yield thread */
   }
 
   log->logDEBUG("DataManager", "Chunk send complete, Cleaning up.");

Modified: geomcore/trunk/src/GS/FileDataSource.cxx
===================================================================
--- geomcore/trunk/src/GS/FileDataSource.cxx    2011-05-16 18:11:48 UTC (rev 
44620)
+++ geomcore/trunk/src/GS/FileDataSource.cxx    2011-05-17 17:09:03 UTC (rev 
44621)
@@ -23,24 +23,25 @@
 
 #include "FileDataSource.h"
 #include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <algorithm>
 
-
 FileDataSource::FileDataSource(std::string repoPath)
-:   repoPath(repoPath)
-{}
+{
+  this->repoPath = repoPath;
+  FileDataSource::cleanString(&this->repoPath);
+}
 
-
 FileDataSource::~FileDataSource()
 {}
 
+/* get a directory listing or a child list */
+std::list<std::string>*
+FileDataSource::getListing(std::string path)
+{}
 
-/* Get a single BRLCAD::MinimalObject */
-BRLCAD::MinimalObject*
-FileDataSource::getObj(std::string path)
-{
-}
-
-
 /* Get a set of BRLCAD::MinimalObjects */
 std::list<BRLCAD::MinimalObject*>*
 FileDataSource::getObjs(std::string relPath, bool recurse)
@@ -55,25 +56,37 @@
        if (this->existsFileOrDir(absPath.c_str()) == 1)
                return NULL;
 
-       //FIXME something in here is killing the logger....
+       std::list<BRLCAD::MinimalObject*>* out = NULL;
+
        BRLCAD::MinimalDatabase md;
-       md.Load(absPath);
+       bool loaded = md.Load(absPath);
 
+       if (!loaded) {
+            perror(strerror(errno));
+            Logger::getInstance()->logINFO("FileDataSource", "Failed to 
load.");
+           return out;
+       }
+        Logger::getInstance()->logINFO("FileDataSource", "File seemingly 
loaded.");
+
+/*
        if (recurse)
-               return md.getAllObjects();
+         out = md->getAllObjects();
        else
-               return md.getAllTopObjects();
+         out = md->getAllTopObjects();
+*/
+
+       out = md.getAllObjs();
+
+       return out;
 }
 
 /* Put a single BRLCAD::MinimalObject */
 bool
 FileDataSource::putObj(std::string path, BRLCAD::MinimalObject* obj)
 {
-
     return true;
 }
 
-
 bool
 FileDataSource::init()
 {
@@ -91,7 +104,6 @@
     return true;
 }
 
-
 int
 FileDataSource::existsFileOrDir(const char* path)
 {
@@ -113,7 +125,24 @@
     return -1;
 }
 
+void
+FileDataSource::buildFullPath(std::string* out, std::string* base, 
std::string* path)
+{
+  *out = *base + "/" + *path;
+  FileDataSource::cleanString(out);
+}
 
+void
+FileDataSource::cleanString(std::string* out)
+{
+  int pos = out->find("//");
+  while (pos != -1)
+    {
+      out->replace(pos,2,"/");
+      pos = out->find("//");
+    }
+}
+
 /*
  * Local Variables:
  * tab-width: 8

Modified: geomcore/trunk/src/GS/GSClient.cxx
===================================================================
--- geomcore/trunk/src/GS/GSClient.cxx  2011-05-16 18:11:48 UTC (rev 44620)
+++ geomcore/trunk/src/GS/GSClient.cxx  2011-05-17 17:09:03 UTC (rev 44621)
@@ -144,10 +144,11 @@
                {
                        GeometryManifestMsg* man = (GeometryManifestMsg*)msg;
 
+                       std::string str;
                        std::stringstream ss;
-                       ss << "Got manifest of " << man->getNumOfItems() << " 
items.";
-                       log->logINFO("GSClient", ss.str());
-/*
+                        ss << "Got manifest of " << man->getNumOfItems() << " 
items.";
+                        log->logINFO("GSClient", ss.str());
+
                        // build manifest & Chunks to send
                        std::list<std::string>* items = man->getItemData();
                        for (std::list<std::string>::iterator it = 
items->begin(); it
@@ -156,8 +157,9 @@
                                std::cout << "  '" << str << ",\n";
                        }
                        std::cout << std::endl;
-*/
 
+                        log->logINFO("GSClient", ss.str());
+
                        return false;
                }
   case GEOMETRYCHUNK:

Modified: geomcore/trunk/src/GS/SvnDataSource.cxx
===================================================================
--- geomcore/trunk/src/GS/SvnDataSource.cxx     2011-05-16 18:11:48 UTC (rev 
44620)
+++ geomcore/trunk/src/GS/SvnDataSource.cxx     2011-05-17 17:09:03 UTC (rev 
44621)
@@ -38,11 +38,10 @@
 {}
 
 
-/* Get a single BRLCAD::MinimalObject */
-BRLCAD::MinimalObject*
-SvnDataSource::getObj(std::string path)
+/* get a directory listing or a child list */
+std::list<std::string>*
+SvnDataSource::getListing(std::string path)
 {
-
 }
 
 


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

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to