Revision: 41632
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41632&view=rev
Author:   davidloman
Date:     2010-12-15 19:15:50 +0000 (Wed, 15 Dec 2010)

Log Message:
-----------
Stub in AbstractClientCmd, a base class for all client commands to be derived 
from, and ClientCmdRegistry, a centralized manager for maintaining references 
to previously mentioned commands.

Modified Paths:
--------------
    rt^3/trunk/src/GS/CMakeLists.txt

Added Paths:
-----------
    rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx
    rt^3/trunk/src/GS/cmds/AbstractClientCmd.h
    rt^3/trunk/src/GS/cmds/ClientCmdRegistry.cxx
    rt^3/trunk/src/GS/cmds/ClientCmdRegistry.h

Property Changed:
----------------
    rt^3/trunk/src/GS/cmds/

Modified: rt^3/trunk/src/GS/CMakeLists.txt
===================================================================
--- rt^3/trunk/src/GS/CMakeLists.txt    2010-12-15 18:38:23 UTC (rev 41631)
+++ rt^3/trunk/src/GS/CMakeLists.txt    2010-12-15 19:15:50 UTC (rev 41632)
@@ -54,6 +54,8 @@
        Account.cxx
        AccountManager.cxx
        GSClient.cxx
+       cmds/ClientCmdRegistry.cxx
+       cmds/AbstractClientCmd.cxx
 )
 
 #Set INST Headers
@@ -74,6 +76,8 @@
        DbObjectManifest.h
        GeometryProcessor.h
        GSClient.h
+       cmds/ClientCmdRegistry.h
+       cmds/AbstractClientCmd.h
 )
 
 #Set QT INST headers


Property changes on: rt^3/trunk/src/GS/cmds
___________________________________________________________________
Added: svn:ignore
   + *.backup


Added: rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx                                
(rev 0)
+++ rt^3/trunk/src/GS/cmds/AbstractClientCmd.cxx        2010-12-15 19:15:50 UTC 
(rev 41632)
@@ -0,0 +1,55 @@
+/*           A B S T R A C T C L I E N T C M D . 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 AbstractClientCmd.cxx
+ * AbstractClientCmd.cxx
+ *
+ */
+
+#include "AbstractClientCmd.h"
+
+AbstractClientCmd::AbstractClientCmd(QString cmd) : cmd(cmd)
+{}
+
+AbstractClientCmd::AbstractClientCmd(AbstractClientCmd* acCmd) : 
cmd(acCmd->getCmd())
+{}
+
+AbstractClientCmd::~AbstractClientCmd() {
+}
+
+QString
+AbstractClientCmd::getCmd()
+{
+       return this->cmd;
+}
+
+bool
+AbstractClientCmd::exec(QString args[]) {
+       return this->_exec(args);
+}
+
+/*
+ * 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/src/GS/cmds/AbstractClientCmd.cxx
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native

Added: rt^3/trunk/src/GS/cmds/AbstractClientCmd.h
===================================================================
--- rt^3/trunk/src/GS/cmds/AbstractClientCmd.h                          (rev 0)
+++ rt^3/trunk/src/GS/cmds/AbstractClientCmd.h  2010-12-15 19:15:50 UTC (rev 
41632)
@@ -0,0 +1,56 @@
+/*             A B S T R A C T C L I E N T C M D . 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 AbstractClientCmd.h
+ * AbstractClientCmd.h
+ *
+ */
+
+#ifndef __ABSTRACTCLIENTCMD_H__
+#define __ABSTRACTCLIENTCMD_H__
+
+#include <QtCore/QString>
+
+class AbstractClientCmd {
+public:
+       virtual ~AbstractClientCmd();
+       bool exec(QString args[]);
+
+       QString getCmd();
+protected:
+       AbstractClientCmd(QString cmd);
+       AbstractClientCmd(AbstractClientCmd* acCmd);
+
+       virtual bool _exec(QString args[]) = 0;
+
+private:
+       QString cmd;
+};
+
+#endif /* __ABSTRACTCLIENTCMD_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/src/GS/cmds/AbstractClientCmd.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native

Added: rt^3/trunk/src/GS/cmds/ClientCmdRegistry.cxx
===================================================================
--- rt^3/trunk/src/GS/cmds/ClientCmdRegistry.cxx                                
(rev 0)
+++ rt^3/trunk/src/GS/cmds/ClientCmdRegistry.cxx        2010-12-15 19:15:50 UTC 
(rev 41632)
@@ -0,0 +1,94 @@
+/*           C L I E N T C M D R E G I S T R Y . 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 ClientCmdRegistry.cxx
+ *
+ * Brief description
+ *
+ */
+
+
+#include "ClientCmdRegistry.h"
+#include <QtCore/QMutexLocker>
+
+ClientCmdRegistry* ClientCmdRegistry::pInstance = NULL;
+
+ClientCmdRegistry*
+ClientCmdRegistry::getInstance() {
+       if (ClientCmdRegistry::pInstance == NULL) {
+               ClientCmdRegistry::pInstance = new ClientCmdRegistry();
+               ClientCmdRegistry::pInstance->registerInternalCmds();
+       }
+       return ClientCmdRegistry::pInstance;
+}
+
+ClientCmdRegistry::ClientCmdRegistry() {
+       this->cmdMap = new QMap<QString,AbstractClientCmd*> ();
+       this->log = Logger::getInstance();
+}
+
+ClientCmdRegistry::~ClientCmdRegistry() {
+       /* TODO loop thru and del all the CMDs?? */
+       delete cmdMap;
+}
+
+bool ClientCmdRegistry::registerCmd(AbstractClientCmd* cmd) {
+       QString cmdString = cmd->getCmd();
+
+       QMutexLocker(&this->mapLock);
+       if (this->cmdMap->contains(cmdString) == false) {
+               this->cmdMap->insert(cmdString, cmd);
+               return true;
+       }
+
+       this->log->logWARNING("ClientCmdRegistry","An AbstractClientCmd '" + 
cmdString + "' already exists in Registry.");
+       return false;
+}
+
+AbstractClientCmd*
+ClientCmdRegistry::getCmd(QString cmd)
+{
+
+}
+
+QList<QString>*
+ClientCmdRegistry::getListOfCmds() {
+       QMutexLocker(&this->mapLock);
+
+       QList<QString>* keys = new QList<QString>(this->cmdMap->keys());
+
+       return keys;
+}
+
+void
+ClientCmdRegistry::registerInternalCmds()
+{
+       /* TODO add in any cmds that should be automatically mapped here. */
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
+


Property changes on: rt^3/trunk/src/GS/cmds/ClientCmdRegistry.cxx
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Revision Date Author
Added: svn:eol-style
   + native

Added: rt^3/trunk/src/GS/cmds/ClientCmdRegistry.h
===================================================================
--- rt^3/trunk/src/GS/cmds/ClientCmdRegistry.h                          (rev 0)
+++ rt^3/trunk/src/GS/cmds/ClientCmdRegistry.h  2010-12-15 19:15:50 UTC (rev 
41632)
@@ -0,0 +1,75 @@
+/*             C L I E N T C M D R E G I S T R Y . 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 ClientCmdRegistry.h
+ *
+ * Brief description
+ *
+ */
+
+
+#ifndef __CLIENTCMDREGISTRY_H__
+#define __CLIENTCMDREGISTRY_H__
+
+#include "AbstractClientCmd.h"
+#include "Logger.h"
+
+#include <QtCore/QString>
+#include <QtCore/QMap>
+#include <QtCore/QList>
+#include <QtCore/QMutex>
+
+class ClientCmdRegistry
+{
+public:
+       static ClientCmdRegistry* getInstance();
+       virtual ~ClientCmdRegistry();
+
+       bool registerCmd(AbstractClientCmd* cmd);
+       AbstractClientCmd* getCmd(QString cmd);
+
+       QList<QString>* getListOfCmds();
+
+private:
+       static ClientCmdRegistry* pInstance;
+       ClientCmdRegistry();
+
+       static void registerInternalCmds();
+
+       Logger* log;
+
+       QMutex mapLock;
+       QMap<QString,AbstractClientCmd*>* cmdMap;
+
+       /* Disable copy cstr and =operator */
+       ClientCmdRegistry(ClientCmdRegistry const&){};
+       ClientCmdRegistry& operator=(ClientCmdRegistry const&){};
+};
+
+#endif /* __CLIENTCMDREGISTRY_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/src/GS/cmds/ClientCmdRegistry.h
___________________________________________________________________
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.

------------------------------------------------------------------------------
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

Reply via email to