Revision: 42012
http://brlcad.svn.sourceforge.net/brlcad/?rev=42012&view=rev
Author: davidloman
Date: 2011-01-07 14:59:13 +0000 (Fri, 07 Jan 2011)
Log Message:
-----------
Split out the GSClient and GSCmdLineClient functionality a bit more logically.
Also cleaned up some logging errors in the individual cmdline cmd processors.
Modified Paths:
--------------
rt^3/trunk/include/AbstractClientCmd.h
rt^3/trunk/include/ExitCmd.h
rt^3/trunk/include/GSClient.h
rt^3/trunk/include/GSCmdLineClient.h
rt^3/trunk/include/HelpCmd.h
rt^3/trunk/include/LoginCmd.h
rt^3/trunk/include/LogoutCmd.h
rt^3/trunk/include/PingCmd.h
rt^3/trunk/include/ShutdownCmd.h
rt^3/trunk/src/GS/GSClient.cxx
rt^3/trunk/src/GS/GSCmdLineClient.cxx
rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx
rt^3/trunk/src/GS/cmds/ExitCmd.cxx
rt^3/trunk/src/GS/cmds/HelpCmd.cxx
rt^3/trunk/src/GS/cmds/LoginCmd.cxx
rt^3/trunk/src/GS/cmds/LogoutCmd.cxx
rt^3/trunk/src/GS/cmds/PingCmd.cxx
rt^3/trunk/src/GS/cmds/ShutdownCmd.cxx
rt^3/trunk/src/GS/geoclient.cxx
Modified: rt^3/trunk/include/AbstractClientCmd.h
===================================================================
--- rt^3/trunk/include/AbstractClientCmd.h 2011-01-07 14:54:23 UTC (rev
42011)
+++ rt^3/trunk/include/AbstractClientCmd.h 2011-01-07 14:59:13 UTC (rev
42012)
@@ -26,7 +26,7 @@
#define __ABSTRACTCLIENTCMD_H__
#include "Logger.h"
-#include "GSClient.h"
+#include "GSCmdLineClient.h"
#include <QtCore/QString>
#include <QtCore/QStringList>
@@ -34,7 +34,7 @@
class AbstractClientCmd {
public:
virtual ~AbstractClientCmd();
- bool exec(GSClient* client, QStringList args);
+ bool exec(GSCmdLineClient* client, QStringList args);
QString getCmd();
virtual QString getUsage() = 0;
@@ -47,7 +47,7 @@
AbstractClientCmd(QString cmd);
AbstractClientCmd(AbstractClientCmd* acCmd);
- virtual bool _exec(GSClient* client, QStringList args) = 0;
+ virtual bool _exec(GSCmdLineClient* client, QStringList args) = 0;
Logger* log;
Modified: rt^3/trunk/include/ExitCmd.h
===================================================================
--- rt^3/trunk/include/ExitCmd.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/ExitCmd.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -38,7 +38,7 @@
QString getHelp();
protected:
- bool _exec(GSClient* client, QStringList args);
+ bool _exec(GSCmdLineClient* client, QStringList args);
};
#endif /* __EXITCMD_H__ */
Modified: rt^3/trunk/include/GSClient.h
===================================================================
--- rt^3/trunk/include/GSClient.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/GSClient.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -25,7 +25,6 @@
#ifndef __GSCLIENT_H__
#define __GSCLIENT_H__
-#include "ClientCmdRegistry.h"
#include "libutility.h"
#include "libnet.h"
@@ -36,41 +35,22 @@
#include <iostream>
#include <stdlib.h>
-class LoginCmd;
-class LogoutCmd;
class GSClient: public INetMsgHandler {
- friend class LoginCmd;
- friend class LogoutCmd;
-
public:
GSClient(QString localNodeName);
virtual ~GSClient();
- int run();
- void stopRun();
-
bool handleNetMsg(NetMsg* msg);
- bool execCmd(QString cmd, QStringList args);
PortalManager* getPortMan();
- Portal* getCurrentPortal();
protected:
-
-private:
- void registerClientCmds();
void registerMsgRoutes();
- ClientCmdRegistry* ccReg;
Logger* log;
JobManager* jobMan;
PortalManager* portMan;
- Portal* currentPortal;
-
- bool stayRun;
- std::string prompt;
- const static std::string defaultPrompt;
};
#endif /* __GSCLIENT_H__ */
Modified: rt^3/trunk/include/GSCmdLineClient.h
===================================================================
--- rt^3/trunk/include/GSCmdLineClient.h 2011-01-07 14:54:23 UTC (rev
42011)
+++ rt^3/trunk/include/GSCmdLineClient.h 2011-01-07 14:59:13 UTC (rev
42012)
@@ -27,12 +27,38 @@
#define __GSCMDLINECLIENT_H__
#include "GSClient.h"
+#include "ClientCmdRegistry.h"
+
#include <QtCore/QString>
+#include <string>
+#include <iostream>
+#include <stdlib.h>
+
+class LoginCmd;
+class LogoutCmd;
class GSCmdLineClient: public GSClient {
+ friend class LoginCmd;
+ friend class LogoutCmd;
public:
GSCmdLineClient(QString localNodeName);
virtual ~GSCmdLineClient();
+
+ int run();
+ void stopRun();
+ bool execCmd(QString cmd, QStringList args);
+ Portal* getCurrentPortal();
+
+protected:
+ bool stayRun;
+ ClientCmdRegistry* ccReg;
+ std::string prompt;
+ Portal* currentPortal;
+ const static std::string defaultPrompt;
+
+ void registerClientCmds();
+ bool setCurrentPortal(Portal* p);
+
};
#endif /* __GSCMDLINECLIENT_H__ */
Modified: rt^3/trunk/include/HelpCmd.h
===================================================================
--- rt^3/trunk/include/HelpCmd.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/HelpCmd.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -38,7 +38,7 @@
QString getHelp();
protected:
- bool _exec(GSClient* client, QStringList args);
+ bool _exec(GSCmdLineClient* client, QStringList args);
};
#endif /* __HELPCMD_H__ */
Modified: rt^3/trunk/include/LoginCmd.h
===================================================================
--- rt^3/trunk/include/LoginCmd.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/LoginCmd.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -39,7 +39,7 @@
QString getHelp();
protected:
- bool _exec(GSClient* client, QStringList args);
+ bool _exec(GSCmdLineClient* client, QStringList args);
};
#endif /* __LOGINCMD_H__ */
Modified: rt^3/trunk/include/LogoutCmd.h
===================================================================
--- rt^3/trunk/include/LogoutCmd.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/LogoutCmd.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -39,7 +39,7 @@
QString getHelp();
protected:
- bool _exec(GSClient* client, QStringList args);
+ bool _exec(GSCmdLineClient* client, QStringList args);
};
Modified: rt^3/trunk/include/PingCmd.h
===================================================================
--- rt^3/trunk/include/PingCmd.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/PingCmd.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -37,7 +37,7 @@
QString getHelp();
protected:
- bool _exec(GSClient* client, QStringList args);
+ bool _exec(GSCmdLineClient* client, QStringList args);
};
Modified: rt^3/trunk/include/ShutdownCmd.h
===================================================================
--- rt^3/trunk/include/ShutdownCmd.h 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/include/ShutdownCmd.h 2011-01-07 14:59:13 UTC (rev 42012)
@@ -39,7 +39,7 @@
QString getHelp();
protected:
- bool _exec(GSClient* client, QStringList args);
+ bool _exec(GSCmdLineClient* client, QStringList args);
};
Modified: rt^3/trunk/src/GS/GSClient.cxx
===================================================================
--- rt^3/trunk/src/GS/GSClient.cxx 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/src/GS/GSClient.cxx 2011-01-07 14:59:13 UTC (rev 42012)
@@ -25,18 +25,8 @@
#include "GSClient.h"
#include "NetMsgRouter.h"
-#include "AbstractClientCmd.h"
-#include "ExitCmd.h"
-#include "HelpCmd.h"
-#include "LoginCmd.h"
-#include "LogoutCmd.h"
-#include "ShutdownCmd.h"
-#include "PingCmd.h"
-const std::string GSClient::defaultPrompt ="geoclient> ";
-
GSClient::GSClient(QString localNodeName) {
- this->ccReg = ClientCmdRegistry::getInstance();
this->log = Logger::getInstance();
this->jobMan = JobManager::getInstance();
this->jobMan->startup();
@@ -45,12 +35,6 @@
this->portMan->start();
GSThread::msleep(100);
- this->currentPortal = NULL;
-
- this->stayRun = true;
- this->prompt = defaultPrompt;
-
- this->registerClientCmds();
this->registerMsgRoutes();
}
@@ -59,18 +43,6 @@
}
void
-GSClient::registerClientCmds()
-{
- /* Command Registrations */
- this->ccReg->registerCmd(new HelpCmd());
- this->ccReg->registerCmd(new ExitCmd());
- this->ccReg->registerCmd(new LoginCmd());
- this->ccReg->registerCmd(new LogoutCmd());
- this->ccReg->registerCmd(new ShutdownCmd());
- this->ccReg->registerCmd(new PingCmd());
-}
-
-void
GSClient::registerMsgRoutes()
{
NetMsgRouter* router = NetMsgRouter::getInstance();
@@ -141,85 +113,12 @@
return false;
}
-
-int
-GSClient::run()
-{
- this->log->logBANNER("geoclient","==================================");
- this->log->logBANNER("geoclient","GeometryService Test/Stress Client");
- this->log->logBANNER("geoclient","==================================");
-
- std::string in;
- while (this->stayRun) {
- in == "";
- std::cout << prompt;
- getline (std::cin, in);
-
- /* make a qstring */
- QString qin(in.c_str());
-
- /* cathc zero length strings here */
- if (qin.length() == 0)
- continue;
-
- /* split string */
- QStringList list = qin.split(" ");
-
- /* check to see if there is at least one element */
- if (list.length() <= 0) {
- continue;
- }
-
- /* convert to lowercase */
- QString cmd = list.takeFirst().toLower();
-
- this->execCmd(cmd, list);
- }
-
- if (this->currentPortal != NULL)
- this->currentPortal->disconnect();
-
- if (this->portMan != NULL)
- this->portMan->shutdown();
-
- if (this->jobMan != NULL)
- this->jobMan->shutdown();
-
- this->log->logINFO("geoclient","Exiting.");
- return 0;
-}
-
-bool
-GSClient::execCmd(QString cmd, QStringList args)
-{
- AbstractClientCmd* acc = this->ccReg->getCmd(cmd);
-
- if (acc == NULL) {
- this->log->logINFO("GSClient", "Unknown Command: '" + cmd +
"'.");
- return false;
- }
-
- return acc->exec(this, args);
-}
-
PortalManager*
GSClient::getPortMan()
{
return this->portMan;
}
-Portal*
-GSClient::getCurrentPortal()
-{
- return this->currentPortal;
-}
-
-void
-GSClient::stopRun()
-{
- this->stayRun = false;
-}
-
/*
* Local Variables:
* tab-width: 8
Modified: rt^3/trunk/src/GS/GSCmdLineClient.cxx
===================================================================
--- rt^3/trunk/src/GS/GSCmdLineClient.cxx 2011-01-07 14:54:23 UTC (rev
42011)
+++ rt^3/trunk/src/GS/GSCmdLineClient.cxx 2011-01-07 14:59:13 UTC (rev
42012)
@@ -25,12 +25,122 @@
#include "GSCmdLineClient.h"
-GSCmdLineClient::GSCmdLineClient(QString
localNodeName):GSClient(localNodeName) {
+#include "AbstractClientCmd.h"
+#include "ExitCmd.h"
+#include "HelpCmd.h"
+#include "LoginCmd.h"
+#include "LogoutCmd.h"
+#include "ShutdownCmd.h"
+#include "PingCmd.h"
+
+const std::string GSCmdLineClient::defaultPrompt ="geoclient> ";
+
+GSCmdLineClient::GSCmdLineClient(QString localNodeName):GSClient(localNodeName)
+{
+ this->ccReg = ClientCmdRegistry::getInstance();
+ this->registerClientCmds();
+ this->stayRun = true;
+ this->prompt = defaultPrompt;
+ this->currentPortal = NULL;
}
GSCmdLineClient::~GSCmdLineClient() {
}
+
+int
+GSCmdLineClient::run()
+{
+ this->log->logBANNER("geoclient","==================================");
+ this->log->logBANNER("geoclient","GeometryService Test/Stress Client");
+ this->log->logBANNER("geoclient","==================================");
+
+ std::string in;
+ while (this->stayRun) {
+ in == "";
+ std::cout << prompt;
+ getline (std::cin, in);
+
+ /* make a qstring */
+ QString qin(in.c_str());
+
+ /* cathc zero length strings here */
+ if (qin.length() == 0)
+ continue;
+
+ /* split string */
+ QStringList list = qin.split(" ");
+
+ /* check to see if there is at least one element */
+ if (list.length() <= 0) {
+ continue;
+ }
+
+ /* convert to lowercase */
+ QString cmd = list.takeFirst().toLower();
+
+ this->execCmd(cmd, list);
+ }
+
+ if (this->currentPortal != NULL)
+ this->currentPortal->disconnect();
+
+ if (this->portMan != NULL)
+ this->portMan->shutdown();
+
+ this->log->logINFO("geoclient","Exiting.");
+ return 0;
+}
+
+
+void
+GSCmdLineClient::stopRun()
+{
+ this->stayRun = false;
+}
+
+
+bool
+GSCmdLineClient::execCmd(QString cmd, QStringList args)
+{
+ AbstractClientCmd* acc = this->ccReg->getCmd(cmd);
+
+ if (acc == NULL) {
+ this->log->logINFO("GSClient", "Unknown Command: '" + cmd +
"'.");
+ return false;
+ }
+
+ return acc->exec(this, args);
+}
+
+void
+GSCmdLineClient::registerClientCmds()
+{
+ /* Command Registrations */
+ this->ccReg->registerCmd(new HelpCmd());
+ this->ccReg->registerCmd(new ExitCmd());
+ this->ccReg->registerCmd(new LoginCmd());
+ this->ccReg->registerCmd(new LogoutCmd());
+ this->ccReg->registerCmd(new ShutdownCmd());
+ this->ccReg->registerCmd(new PingCmd());
+}
+
+bool
+GSCmdLineClient::setCurrentPortal(Portal* p)
+{
+ if (p != NULL) {
+ this->currentPortal = p;
+ return true;
+ }
+ return false;
+}
+
+Portal*
+GSCmdLineClient::getCurrentPortal()
+{
+ return this->currentPortal;
+}
+
/*
* Local Variables:
* tab-width: 8
Modified: rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx 2011-01-07 14:54:23 UTC
(rev 42011)
+++ rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx 2011-01-07 14:59:13 UTC
(rev 42012)
@@ -43,7 +43,7 @@
}
bool
-AbstractClientCmd::exec(GSClient* client, QStringList args) {
+AbstractClientCmd::exec(GSCmdLineClient* client, QStringList args) {
return this->_exec(client, args);
}
Modified: rt^3/trunk/src/GS/cmds/ExitCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/ExitCmd.cxx 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/src/GS/cmds/ExitCmd.cxx 2011-01-07 14:59:13 UTC (rev 42012)
@@ -40,7 +40,7 @@
}
bool
-ExitCmd::_exec(GSClient* client, QStringList args){
+ExitCmd::_exec(GSCmdLineClient* client, QStringList args){
/* set the run flag to false */
client->stopRun();
}
Modified: rt^3/trunk/src/GS/cmds/HelpCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/HelpCmd.cxx 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/src/GS/cmds/HelpCmd.cxx 2011-01-07 14:59:13 UTC (rev 42012)
@@ -37,11 +37,11 @@
QString
HelpCmd::getHelp() {
- return "If envoked without any arguments, help diplays a list of
available commands. If a command name is provided as an argument, the help for
that command is displayed.";
+ return "If evoked without any arguments, help diplays a list of
available commands. If a command name is provided as an argument, the help for
that command is displayed.";
}
bool
-HelpCmd::_exec(GSClient* client, QStringList args){
+HelpCmd::_exec(GSCmdLineClient* client, QStringList args){
int argn = args.length();
Modified: rt^3/trunk/src/GS/cmds/LoginCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/LoginCmd.cxx 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/src/GS/cmds/LoginCmd.cxx 2011-01-07 14:59:13 UTC (rev 42012)
@@ -42,7 +42,7 @@
}
bool
-LoginCmd::_exec(GSClient* client, QStringList args){
+LoginCmd::_exec(GSCmdLineClient* client, QStringList args){
int argn = args.length();
if (argn != 4) {
@@ -79,8 +79,7 @@
/* Give the Portal some time to handshake. */
GSThread::msleep(100);
- /* This is an ugly way to do this, 'friend' is needed in GSClient.h */
- client->currentPortal = p;
+ client->setCurrentPortal(p);
/* Authenticate */
NewSessionReqMsg nsrm(uname, passwd);
Modified: rt^3/trunk/src/GS/cmds/LogoutCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/LogoutCmd.cxx 2011-01-07 14:54:23 UTC (rev
42011)
+++ rt^3/trunk/src/GS/cmds/LogoutCmd.cxx 2011-01-07 14:59:13 UTC (rev
42012)
@@ -42,12 +42,12 @@
}
bool
-LogoutCmd::_exec(GSClient* client, QStringList args){
+LogoutCmd::_exec(GSCmdLineClient* client, QStringList args){
Portal* p = client->getCurrentPortal();
/* Check to see if we are connected */
if (p == NULL) {
- this->log->logWARNING("ShutdownCmd","Current Portal returned
NULL. Cannot send Shutdown Msg.");
+ this->log->logWARNING("Logout","Not connected to a Geometry
Service.");
return false;
}
Modified: rt^3/trunk/src/GS/cmds/PingCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/PingCmd.cxx 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/src/GS/cmds/PingCmd.cxx 2011-01-07 14:59:13 UTC (rev 42012)
@@ -41,11 +41,11 @@
}
bool
-PingCmd::_exec(GSClient* client, QStringList args){
+PingCmd::_exec(GSCmdLineClient* client, QStringList args){
Portal* p = client->getCurrentPortal();
if (p == NULL) {
- this->log->logERROR("LoginCmd", "Current Portal is NULL.");
+ this->log->logERROR("PingCmd", "Not connected to a Geometry
Service.");
return false;
}
Modified: rt^3/trunk/src/GS/cmds/ShutdownCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/ShutdownCmd.cxx 2011-01-07 14:54:23 UTC (rev
42011)
+++ rt^3/trunk/src/GS/cmds/ShutdownCmd.cxx 2011-01-07 14:59:13 UTC (rev
42012)
@@ -39,12 +39,12 @@
}
bool
-ShutdownCmd::_exec(GSClient* client, QStringList args){
+ShutdownCmd::_exec(GSCmdLineClient* client, QStringList args){
Portal* p = client->getCurrentPortal();
/* Check to see if we are connected */
if (p == NULL) {
- this->log->logWARNING("ShutdownCmd","Current Portal returned
NULL. Cannot send Shutdown Msg.");
+ this->log->logERROR("ShutdownCmd","Not connected to a Geometry
Service. Cannot send Shutdown Msg.");
return false;
}
Modified: rt^3/trunk/src/GS/geoclient.cxx
===================================================================
--- rt^3/trunk/src/GS/geoclient.cxx 2011-01-07 14:54:23 UTC (rev 42011)
+++ rt^3/trunk/src/GS/geoclient.cxx 2011-01-07 14:59:13 UTC (rev 42012)
@@ -24,6 +24,7 @@
*/
#include "GSClient.h"
+#include "GSCmdLineClient.h"
#include "libutility.h"
#include <QtCore/QString>
#include <QtCore/QUuid>
@@ -68,8 +69,12 @@
gsExit(1);
}
- GSClient gsClient(localNodeName);
- return gsClient.run();
+ GSCmdLineClient gsClient(localNodeName);
+ int retVal = gsClient.run();
+
+ JobManager::getInstance()->shutdown(true);
+
+ return retVal;
}
/*
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web. Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits