Revision: 41635
http://brlcad.svn.sourceforge.net/brlcad/?rev=41635&view=rev
Author: davidloman
Date: 2010-12-15 19:59:35 +0000 (Wed, 15 Dec 2010)
Log Message:
-----------
Convert from using QString[] to QStringList. Add in cin parsing.
Modified Paths:
--------------
rt^3/trunk/include/AbstractClientCmd.h
rt^3/trunk/src/GS/GSClient.cxx
rt^3/trunk/src/GS/GSClient.h
rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx
Modified: rt^3/trunk/include/AbstractClientCmd.h
===================================================================
--- rt^3/trunk/include/AbstractClientCmd.h 2010-12-15 19:33:05 UTC (rev
41634)
+++ rt^3/trunk/include/AbstractClientCmd.h 2010-12-15 19:59:35 UTC (rev
41635)
@@ -26,18 +26,19 @@
#define __ABSTRACTCLIENTCMD_H__
#include <QtCore/QString>
+#include <QtCore/QStringList>
class AbstractClientCmd {
public:
virtual ~AbstractClientCmd();
- bool exec(QString args[]);
+ bool exec(QStringList args);
QString getCmd();
protected:
AbstractClientCmd(QString cmd);
AbstractClientCmd(AbstractClientCmd* acCmd);
- virtual bool _exec(QString args[]) = 0;
+ virtual bool _exec(QStringList args) = 0;
private:
QString cmd;
Modified: rt^3/trunk/src/GS/GSClient.cxx
===================================================================
--- rt^3/trunk/src/GS/GSClient.cxx 2010-12-15 19:33:05 UTC (rev 41634)
+++ rt^3/trunk/src/GS/GSClient.cxx 2010-12-15 19:59:35 UTC (rev 41635)
@@ -24,27 +24,66 @@
#include "GSClient.h"
+const std::string GSClient::defaultPrompt ="geoclient> ";
+
GSClient::GSClient() {
- // TODO Auto-generated constructor stub
-
+ this->ccReg = ClientCmdRegistry::getInstance();
+ this->log = Logger::getInstance();
+ this->jobMan = JobManager::getInstance();
+ this->stayRun = true;
+ this->prompt = defaultPrompt;
}
GSClient::~GSClient() {
- // TODO Auto-generated destructor stub
}
-bool
-GSClient::hasCmd(QString cmd)
+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());
+
+ /* convert to lowercase */
+ qin = qin.toLower();
+
+ /* split string */
+ QStringList list = qin.split(" ");
+
+ /* check to see if there is at least one element */
+ if (list.length() <= 0) {
+ continue;
+ }
+ QString cmd = list.takeFirst();
+
+ this->execCmd(cmd, list);
+
+ }
+
+ this->log->logINFO("geoclient","Exiting.");
+ return 0;
}
-void
-GSClient::execCmd(QString cmd, QString args[])
+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(args);
}
Modified: rt^3/trunk/src/GS/GSClient.h
===================================================================
--- rt^3/trunk/src/GS/GSClient.h 2010-12-15 19:33:05 UTC (rev 41634)
+++ rt^3/trunk/src/GS/GSClient.h 2010-12-15 19:59:35 UTC (rev 41635)
@@ -25,18 +25,33 @@
#ifndef __GSCLIENT_H__
#define __GSCLIENT_H__
+#include "ClientCmdRegistry.h"
+#include "Logger.h"
+#include "JobManager.h"
+
#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <string>
+#include <iostream>
+#include <stdlib.h>
+
class GSClient {
public:
GSClient();
virtual ~GSClient();
- bool hasCmd(QString cmd);
- void execCmd(QString cmd, QString args[]);
+ int run();
+ bool execCmd(QString cmd, QStringList args);
private:
+ ClientCmdRegistry* ccReg;
+ Logger* log;
+ JobManager* jobMan;
+ bool stayRun;
+ std::string prompt;
+ const static std::string defaultPrompt;
};
#endif /* __GSCLIENT_H__ */
Modified: rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx 2010-12-15 19:33:05 UTC
(rev 41634)
+++ rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx 2010-12-15 19:59:35 UTC
(rev 41635)
@@ -40,7 +40,7 @@
}
bool
-AbstractClientCmd::exec(QString args[]) {
+AbstractClientCmd::exec(QStringList args) {
return this->_exec(args);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits