Revision: 40262 http://brlcad.svn.sourceforge.net/brlcad/?rev=40262&view=rev Author: davidloman Date: 2010-08-19 19:52:52 +0000 (Thu, 19 Aug 2010)
Log Message: ----------- Implement PkgTcpClient and PkgUdpClient as subclasses of PkgClient. Update cmake files and tests. Had to add connection specific getter methods to PkgServer subclasses so they can generate proper types of PkgClient subclasses. Modified Paths: -------------- rt^3/trunk/include/PkgClient.h rt^3/trunk/include/PkgServer.h rt^3/trunk/include/PkgTcpServer.h rt^3/trunk/include/PkgUdpServer.h rt^3/trunk/src/libPkgCpp/CMakeLists.txt rt^3/trunk/src/libPkgCpp/PkgClient.cxx rt^3/trunk/src/libPkgCpp/PkgServer.cxx rt^3/trunk/src/libPkgCpp/PkgTcpServer.cxx rt^3/trunk/src/libPkgCpp/PkgUdpServer.cxx rt^3/trunk/tests/libpkgcpp/pkgcppTest.cxx Added Paths: ----------- rt^3/trunk/include/PkgTcpClient.h rt^3/trunk/include/PkgUdpClient.h rt^3/trunk/src/libPkgCpp/PkgTcpClient.cxx rt^3/trunk/src/libPkgCpp/PkgUdpClient.cxx Modified: rt^3/trunk/include/PkgClient.h =================================================================== --- rt^3/trunk/include/PkgClient.h 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/include/PkgClient.h 2010-08-19 19:52:52 UTC (rev 40262) @@ -33,8 +33,8 @@ class PkgClient { public: - PkgClient(std::string ipOrHostname, int port); - PkgClient(pkg_conn* conn); + PkgClient(std::string proto, std::string ipOrHostname, int port); + PkgClient(std::string proto, pkg_conn* conn); virtual ~PkgClient(); bool hasGoodConnection(); @@ -68,6 +68,7 @@ int send(int opcode, const char* buffer, size_t bufferLen); private: + std::string proto; pkg_conn* conn; Modified: rt^3/trunk/include/PkgServer.h =================================================================== --- rt^3/trunk/include/PkgServer.h 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/include/PkgServer.h 2010-08-19 19:52:52 UTC (rev 40262) @@ -47,6 +47,9 @@ std::string proto; int listenFD; pkg_switch* callBackTable; + + virtual PkgClient* getNewClient(pkg_conn* conn) = 0; + }; #endif /* __PKGSERVER_H__ */ Added: rt^3/trunk/include/PkgTcpClient.h =================================================================== --- rt^3/trunk/include/PkgTcpClient.h (rev 0) +++ rt^3/trunk/include/PkgTcpClient.h 2010-08-19 19:52:52 UTC (rev 40262) @@ -0,0 +1,51 @@ +/* P K G T C P C L I E N T . H + * BRL-CAD + * + * Copyright (c) 2010 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 PkgTcpClient.h + * PkgTcpClient.h + * + * Created on: Aug 19, 2010 + * Author: dloman + */ + +#ifndef __PKGTCPCLIENT_H__ +#define __PKGTCPCLIENT_H__ + +#include "PkgClient.h" + +class PkgTcpClient : public PkgClient +{ +public: + PkgTcpClient(std::string ipOrHostname, int port); + PkgTcpClient(pkg_conn* conn); + virtual + ~PkgTcpClient(); +}; + +#endif /* __PKGTCPCLIENT_H__ */ + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: rt^3/trunk/include/PkgTcpClient.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Revision Date Author Added: svn:eol-style + native Modified: rt^3/trunk/include/PkgTcpServer.h =================================================================== --- rt^3/trunk/include/PkgTcpServer.h 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/include/PkgTcpServer.h 2010-08-19 19:52:52 UTC (rev 40262) @@ -28,12 +28,17 @@ #define __PKGTCPSERVER_H__ #include "PkgServer.h" +#include "PkgTcpClient.h" class PkgTcpServer : public PkgServer { public: PkgTcpServer(pkg_switch callbacks[]); virtual ~PkgTcpServer(); + +private: + PkgClient* getNewClient(pkg_conn* conn); + }; #endif /* __PKGTCPSERVER_H__ */ Added: rt^3/trunk/include/PkgUdpClient.h =================================================================== --- rt^3/trunk/include/PkgUdpClient.h (rev 0) +++ rt^3/trunk/include/PkgUdpClient.h 2010-08-19 19:52:52 UTC (rev 40262) @@ -0,0 +1,50 @@ +/* P K G U D P C L I E N T . H + * BRL-CAD + * + * Copyright (c) 2010 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 PkgUdpClient.h + * PkgUdpClient.h + * + * Created on: Aug 19, 2010 + * Author: dloman + */ + +#ifndef __PKGUDPCLIENT_H__ +#define __PKGUDPCLIENT_H__ + +#include "PkgClient.h" + +class PkgUdpClient : public PkgClient +{ +public: + PkgUdpClient(std::string ipOrHostname, int port); + PkgUdpClient(pkg_conn* conn); + virtual ~PkgUdpClient(); +}; + +#endif /* __PKGUDPCLIENT_H__ */ + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: rt^3/trunk/include/PkgUdpClient.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Revision Date Author Added: svn:eol-style + native Modified: rt^3/trunk/include/PkgUdpServer.h =================================================================== --- rt^3/trunk/include/PkgUdpServer.h 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/include/PkgUdpServer.h 2010-08-19 19:52:52 UTC (rev 40262) @@ -28,12 +28,17 @@ #define __PKGUDPSERVER_H__ #include "PkgServer.h" +#include "PkgUdpClient.h" class PkgUdpServer : public PkgServer { public: PkgUdpServer(pkg_switch callbacks[]); virtual ~PkgUdpServer(); + +private: + PkgClient* getNewClient(pkg_conn* conn); + }; #endif /* __PKGUDPSERVER_H__ */ Modified: rt^3/trunk/src/libPkgCpp/CMakeLists.txt =================================================================== --- rt^3/trunk/src/libPkgCpp/CMakeLists.txt 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/src/libPkgCpp/CMakeLists.txt 2010-08-19 19:52:52 UTC (rev 40262) @@ -41,6 +41,8 @@ #set Source files RT3_PROJECT_ADD_SOURCES ( PkgClient.cxx + PkgTcpClient.cxx + PkgUdpClient.cxx PkgServer.cxx PkgTcpServer.cxx PkgUdpServer.cxx @@ -50,6 +52,8 @@ RT3_PROJECT_ADD_INST_HEADERS( pkgcppcommon.h PkgClient.h + PkgTcpClient.h + PkgUdpClient.h PkgServer.h PkgTcpServer.h PkgUdpServer.h Modified: rt^3/trunk/src/libPkgCpp/PkgClient.cxx =================================================================== --- rt^3/trunk/src/libPkgCpp/PkgClient.cxx 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/src/libPkgCpp/PkgClient.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -26,19 +26,20 @@ #include <string.h> //TODO Need a path for a callback table to get to this -PkgClient::PkgClient(std::string ipOrHostname, int port) +PkgClient::PkgClient(std::string proto, std::string ipOrHostname, int port) { - char portCString[7] = - { 0 }; + this->proto = proto; + char portCString[7] = { 0 }; snprintf(portCString, 6, "%d", port); //TODO Make this more robust. TCP being hardcoded is bad. - this->conn = pkg_open(ipOrHostname.c_str(), portCString, "tcp", NULL, NULL, + this->conn = pkg_open(ipOrHostname.c_str(), portCString, proto.c_str(), NULL, NULL, NULL, NULL); } -PkgClient::PkgClient(pkg_conn* conn) +PkgClient::PkgClient(std::string proto, pkg_conn* conn) { + this->proto = proto; this->conn = conn; } Modified: rt^3/trunk/src/libPkgCpp/PkgServer.cxx =================================================================== --- rt^3/trunk/src/libPkgCpp/PkgServer.cxx 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/src/libPkgCpp/PkgServer.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -77,7 +77,7 @@ return NULL; } - PkgClient* pkgClientObj = new PkgClient(clientStruct); + PkgClient* pkgClientObj = this->getNewClient(clientStruct); return pkgClientObj; } Added: rt^3/trunk/src/libPkgCpp/PkgTcpClient.cxx =================================================================== --- rt^3/trunk/src/libPkgCpp/PkgTcpClient.cxx (rev 0) +++ rt^3/trunk/src/libPkgCpp/PkgTcpClient.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -0,0 +1,51 @@ +/* P K G T C P C L I E N T . C X X + * BRL-CAD + * + * Copyright (c) 2010 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 PkgTcpClient.cxx + * PkgTcpClient.cxx + * + * Created on: Aug 19, 2010 + * Author: dloman + */ + +#include "PkgTcpClient.h" + +PkgTcpClient::PkgTcpClient(std::string ipOrHostname, int port) : +PkgClient(PKGCPP_PROTO_TCP, ipOrHostname, port) +{ +} + +PkgTcpClient::PkgTcpClient(pkg_conn* conn) : +PkgClient(PKGCPP_PROTO_TCP, conn) +{ +} + +PkgTcpClient::~PkgTcpClient() +{ + // TODO Auto-generated destructor stub +} + +// Local Variables: +// tab-width: 8 +// mode: C++ +// c-basic-offset: 4 +// indent-tabs-mode: t +// c-file-style: "stroustrup" +// End: +// ex: shiftwidth=4 tabstop=8 Property changes on: rt^3/trunk/src/libPkgCpp/PkgTcpClient.cxx ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Revision Date Author Added: svn:eol-style + native Modified: rt^3/trunk/src/libPkgCpp/PkgTcpServer.cxx =================================================================== --- rt^3/trunk/src/libPkgCpp/PkgTcpServer.cxx 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/src/libPkgCpp/PkgTcpServer.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -38,6 +38,11 @@ // TODO Auto-generated destructor stub } + +PkgClient* +PkgTcpServer::getNewClient(pkg_conn* conn) { + return new PkgTcpClient(conn); +} // Local Variables: // tab-width: 8 // mode: C++ Added: rt^3/trunk/src/libPkgCpp/PkgUdpClient.cxx =================================================================== --- rt^3/trunk/src/libPkgCpp/PkgUdpClient.cxx (rev 0) +++ rt^3/trunk/src/libPkgCpp/PkgUdpClient.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -0,0 +1,52 @@ +/* P K G U D P C L I E N T . C X X + * BRL-CAD + * + * Copyright (c) 2010 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 PkgUdpClient.cxx + * PkgUdpClient.cxx + * + * Created on: Aug 19, 2010 + * Author: dloman + */ + +#include "PkgUdpClient.h" + +PkgUdpClient::PkgUdpClient(std::string ipOrHostname, int port) : +PkgClient(PKGCPP_PROTO_UDP, ipOrHostname, port) +{ +} + +PkgUdpClient::PkgUdpClient(pkg_conn* conn) : +PkgClient(PKGCPP_PROTO_UDP, conn) +{ +} + + +PkgUdpClient::~PkgUdpClient() +{ + // TODO Auto-generated destructor stub +} + +// Local Variables: +// tab-width: 8 +// mode: C++ +// c-basic-offset: 4 +// indent-tabs-mode: t +// c-file-style: "stroustrup" +// End: +// ex: shiftwidth=4 tabstop=8 Property changes on: rt^3/trunk/src/libPkgCpp/PkgUdpClient.cxx ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Revision Date Author Added: svn:eol-style + native Modified: rt^3/trunk/src/libPkgCpp/PkgUdpServer.cxx =================================================================== --- rt^3/trunk/src/libPkgCpp/PkgUdpServer.cxx 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/src/libPkgCpp/PkgUdpServer.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -38,6 +38,11 @@ // TODO Auto-generated destructor stub } +PkgClient* +PkgUdpServer::getNewClient(pkg_conn* conn) { + return new PkgUdpClient(conn); +} + // Local Variables: // tab-width: 8 // mode: C++ Modified: rt^3/trunk/tests/libpkgcpp/pkgcppTest.cxx =================================================================== --- rt^3/trunk/tests/libpkgcpp/pkgcppTest.cxx 2010-08-19 19:32:14 UTC (rev 40261) +++ rt^3/trunk/tests/libpkgcpp/pkgcppTest.cxx 2010-08-19 19:52:52 UTC (rev 40262) @@ -239,7 +239,7 @@ } //Create PkgClient obj and open new connection - PkgClient* connToServer = new PkgClient(ipOrHostname, port); + PkgTcpClient* connToServer = new PkgTcpClient(ipOrHostname, port); if (!connToServer->hasGoodConnection()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits