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

Log Message:
-----------
Add directory listing request and response to the gsnet protocol.

Modified Paths:
--------------
    geomcore/trunk/include/NetMsgTypes.h
    geomcore/trunk/src/libNet/CMakeLists.txt

Added Paths:
-----------
    geomcore/trunk/include/DirListReqMsg.h
    geomcore/trunk/include/DirListResMsg.h
    geomcore/trunk/src/libNet/netMsg/DirListReqMsg.cxx
    geomcore/trunk/src/libNet/netMsg/DirListResMsg.cxx

Added: geomcore/trunk/include/DirListReqMsg.h
===================================================================
--- geomcore/trunk/include/DirListReqMsg.h                              (rev 0)
+++ geomcore/trunk/include/DirListReqMsg.h      2011-05-24 17:22:16 UTC (rev 
44659)
@@ -0,0 +1,73 @@
+/*                 D I R L I S T R E Q M S G . H
+ * BRL-CAD
+ *
+ * Copyright (c) 2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file DirListReqMsg.h
+ *
+ * Brief description
+ *
+ */
+
+#ifndef __DIRLISTREQMSG_H__
+#define __DIRLISTREQMSG_H__
+
+#include "NetMsg.h"
+
+class DirListReqMsg : public NetMsg
+{
+public:
+       /* Only Constructor */
+       DirListReqMsg(std::string path);
+
+       /* Reply Constructor */
+       DirListReqMsg(NetMsg* msg, std::string path);
+
+       /* Deserializing Constructor */
+       DirListReqMsg(ByteBuffer* bb, Portal* origin);
+
+       /* Destructor */
+       virtual ~DirListReqMsg();
+
+       /*
+        *Getters n Setters
+        */
+       std::string getPath();
+       virtual std::string toString();
+
+private:
+       std::string path;
+
+       bool _serialize(ByteBuffer* bb);
+       bool _equals(const NetMsg& msg);
+
+       /* Disable copy cstr and =operator */
+       DirListReqMsg(DirListReqMsg const&):NetMsg(0){};
+       DirListReqMsg& operator=(DirListReqMsg const&){};
+};
+
+#endif /* __DIRLISTREQMSG_H__ */
+
+/*
+ * Local Variables: ***
+ * mode: C
+ * tab-width: 8
+ * c-basic-offset: 2 ***
+ * indent-tabs-mode: t
+ * End: ***
+ * ex: shiftwidth=4 tabstop=8
+*/


Property changes on: geomcore/trunk/include/DirListReqMsg.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native

Added: geomcore/trunk/include/DirListResMsg.h
===================================================================
--- geomcore/trunk/include/DirListResMsg.h                              (rev 0)
+++ geomcore/trunk/include/DirListResMsg.h      2011-05-24 17:22:16 UTC (rev 
44659)
@@ -0,0 +1,77 @@
+/*                 D I R L I S T R E S M S G . H
+ * BRL-CAD
+ *
+ * Copyright (c) 2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file DirListResMsg.h
+ *
+ * Brief description
+ *
+ */
+
+
+#ifndef __DIRLISTREQMSG_H__
+#define __DIRLISTREQMSG_H__
+
+#include "NetMsg.h"
+#include <list>
+
+class DirListResMsg : public NetMsg
+{
+public:
+       /* Normal Constructor */
+       DirListResMsg(std::list<std::string>* items);
+
+       /* Reply Constructor */
+       DirListResMsg(NetMsg* msg, std::list<std::string>* items);
+
+       /* Deserializing Constructor */
+       DirListResMsg(ByteBuffer* bb, Portal* origin);
+
+       /* Destructor */
+       virtual ~DirListResMsg();
+
+       virtual std::string toString();
+
+       /*
+        *Getters n Setters
+        */
+       uint32_t getNumOfItems();
+       uint32_t getItems(std::list<std::string>* items);
+
+private:
+       std::list<std::string>* itemData;
+
+       bool _serialize(ByteBuffer* bb);
+       bool _equals(const NetMsg& msg);
+
+       /* Disable copy cstr and =operator */
+       DirListResMsg(DirListResMsg const&):NetMsg(0){};
+       DirListResMsg& operator=(DirListResMsg const&){};
+};
+
+#endif /* __DIRLISTREQMSG_H__ */
+
+/*
+ * Local Variables: ***
+ * mode: C
+ * tab-width: 8
+ * c-basic-offset: 2 ***
+ * indent-tabs-mode: t
+ * End: ***
+ * ex: shiftwidth=4 tabstop=8
+*/


Property changes on: geomcore/trunk/include/DirListResMsg.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native

Modified: geomcore/trunk/include/NetMsgTypes.h
===================================================================
--- geomcore/trunk/include/NetMsgTypes.h        2011-05-24 17:01:21 UTC (rev 
44658)
+++ geomcore/trunk/include/NetMsgTypes.h        2011-05-24 17:22:16 UTC (rev 
44659)
@@ -81,8 +81,8 @@
 
 #define        GEOMETRYREQ                                     0x0400
 #define GEOMETRYBOTREQ                 0x0401
-#define GEOMETRYLISTREQ                        0x0402
-#define GEOMETRYLISTRES                        0x0403
+#define DIRLISTREQ                     0x0402
+#define DIRLISTRES                     0x0403
 #define GEOMETRYMANIFEST                       0x0405
 #define GEOMETRYCHUNK                          0x0410
 

Modified: geomcore/trunk/src/libNet/CMakeLists.txt
===================================================================
--- geomcore/trunk/src/libNet/CMakeLists.txt    2011-05-24 17:01:21 UTC (rev 
44658)
+++ geomcore/trunk/src/libNet/CMakeLists.txt    2011-05-24 17:22:16 UTC (rev 
44659)
@@ -49,6 +49,8 @@
        netMsg/NewSessionReqMsg.cxx
        netMsg/SessionInfoMsg.cxx
        netMsg/NewNodeOnNetMsg.cxx
+       netMsg/DirListReqMsg.cxx
+       netMsg/DirListResMsg.cxx
        netMsg/GeometryReqMsg.cxx
        netMsg/GeometryManifestMsg.cxx
        netMsg/GeometryChunkMsg.cxx
@@ -97,6 +99,8 @@
        NewSessionReqMsg.h
        SessionInfoMsg.h
        NewNodeOnNetMsg.h
+       DirListReqMsg.h
+       DirListResMsg.h
        GeometryReqMsg.h
        GeometryBoTReqMsg.h
        GeometryManifestMsg.h

Added: geomcore/trunk/src/libNet/netMsg/DirListReqMsg.cxx
===================================================================
--- geomcore/trunk/src/libNet/netMsg/DirListReqMsg.cxx                          
(rev 0)
+++ geomcore/trunk/src/libNet/netMsg/DirListReqMsg.cxx  2011-05-24 17:22:16 UTC 
(rev 44659)
@@ -0,0 +1,91 @@
+/*               D I R L I S T R E Q M S G . C X X
+ * BRL-CAD
+ *
+ * Copyright (c) 2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file DirListReqMsg.cxx
+ *
+ * Brief description
+ *
+ */
+
+#include "DirListReqMsg.h"
+
+/* Normal Constructor */
+DirListReqMsg::DirListReqMsg(std::string path) :
+  NetMsg(DIRLISTREQ), path(path)
+{}
+
+/* Reply Constructor */
+DirListReqMsg::DirListReqMsg(NetMsg* msg, std::string path) :
+  NetMsg(DIRLISTREQ, msg), path(path)
+{}
+
+/* Deserializing Constructor */
+DirListReqMsg::DirListReqMsg(ByteBuffer* bb, Portal* origin) :
+ NetMsg(bb,origin)
+{
+  this->path = bb->getString();
+}
+
+/* Destructor */
+DirListReqMsg::~DirListReqMsg()
+{}
+
+bool
+DirListReqMsg::_serialize(ByteBuffer* bb)
+{
+  bb->putString(this->path);
+  return true;
+}
+
+std::string
+DirListReqMsg::toString()
+{
+  std::string out;
+  out += "Path: '" + this->path + "'";
+  return out;
+}
+
+bool
+DirListReqMsg::_equals(const NetMsg& msg)
+{
+  DirListReqMsg& gmsg = (DirListReqMsg&) msg;
+  if (this->path != gmsg.path)
+    return false;
+  return true;
+}
+
+/*
+ *Getters n Setters
+ */
+
+std::string
+DirListReqMsg::getPath()
+{
+  return this->path;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: geomcore/trunk/src/libNet/netMsg/DirListReqMsg.cxx
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native

Added: geomcore/trunk/src/libNet/netMsg/DirListResMsg.cxx
===================================================================
--- geomcore/trunk/src/libNet/netMsg/DirListResMsg.cxx                          
(rev 0)
+++ geomcore/trunk/src/libNet/netMsg/DirListResMsg.cxx  2011-05-24 17:22:16 UTC 
(rev 44659)
@@ -0,0 +1,154 @@
+/*               D I R L I S T R E S M S G . C X X
+ * BRL-CAD
+ *
+ * Copyright (c) 2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file DirListResMsg.cxx
+ *
+ * Brief description
+ *
+ */
+
+
+#include "DirListResMsg.h"
+#include <iostream>
+
+/* Normal Constructor */
+DirListResMsg::DirListResMsg(
+    std::list<std::string>* items) :
+    NetMsg(GEOMETRYMANIFEST)
+{
+    this->itemData = new std::list<std::string> (*items);
+}
+
+/* Reply Constructor */
+DirListResMsg::DirListResMsg(NetMsg* msg, std::list<std::string>* items) :
+       NetMsg(GEOMETRYMANIFEST, msg)
+{
+  this->itemData = new std::list<std::string> (*items);
+}
+
+/* Deserializing Constructor */
+DirListResMsg::DirListResMsg(ByteBuffer* bb, Portal* origin) :
+  NetMsg(bb, origin)
+{
+  this->itemData = new std::list<std::string>();
+  uint32_t numOfItems = bb->get32bit();
+  std::string tstr;
+  for (uint32_t i = 0; i < numOfItems; ++i)
+    {
+      tstr = bb->getString();
+      if (tstr.size() == 0)
+        continue;
+      this->itemData->push_back(tstr);
+    }
+}
+
+/* Destructor */
+DirListResMsg::~DirListResMsg()
+{
+  delete this->itemData;
+}
+
+bool
+DirListResMsg::_serialize(ByteBuffer* bb)
+{
+  /* put in placeholder for count */
+  int start = bb->position();
+  bb->put32bit(0);
+
+  //TODO this list serializer could be generalized....
+  /* Add elements while counting. */
+  int cnt = 0;
+  std::string tstr;
+  for (std::list<std::string>::iterator it = this->itemData->begin(); it
+      != this->itemData->end(); it++)
+    {
+      tstr = *it;
+      if (tstr.size() == 0)
+        continue;
+      bb->putString(tstr);
+      ++cnt;
+    }
+
+  /* Go back and insert actual count */
+  int stop = bb->position();
+  bb->setPosition(start);
+  bb->put32bit(cnt);
+  bb->setPosition(stop);
+
+  return true;
+}
+
+bool
+DirListResMsg::_equals(const NetMsg& msg)
+{
+  DirListResMsg& gmsg = (DirListResMsg&) msg;
+  if (this->itemData->size() != gmsg.itemData->size())
+    return false;
+  std::list<std::string>::iterator it = this->itemData->begin(), git =
+      gmsg.itemData->begin();
+
+  for (; it != this->itemData->end(); it++, git++)
+    if (*it != *git)
+      return false;
+  return true;
+}
+
+std::string
+DirListResMsg::toString()
+{
+  std::string out = "Number of items: " + this->itemData->size();
+
+  std::list<std::string>::iterator it;
+  for (it = this->itemData->begin(); it != this->itemData->end(); ++it)
+    {
+      out += "{" + *it + "} ";
+    }
+
+  return out;
+}
+
+/*
+ *Getters n Setters
+ */
+uint32_t
+DirListResMsg::getNumOfItems()
+{
+  return this->itemData->size();
+}
+
+uint32_t
+DirListResMsg::getItems(std::list<std::string>* items)
+{
+
+  std::list<std::string>::iterator it = this->itemData->begin();
+  for (;it != this->itemData->end(); ++it)
+    items->push_back(*it);
+
+  return items->size();
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: geomcore/trunk/src/libNet/netMsg/DirListResMsg.cxx
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native


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