]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/commands.cxx
Patch from Cameron Moore:
[simgear.git] / simgear / misc / commands.cxx
index 73964428eaed6f0b40ccbdd4455945f8cdd83f72..0b471651590d20068d376b46b35987e69fd81f67 100644 (file)
@@ -5,6 +5,37 @@
 // $Id$
 
 #include "commands.hxx"
+#include "props_io.hxx"
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of SGCommandState class.
+////////////////////////////////////////////////////////////////////////
+
+SGCommandState::SGCommandState ()
+  : _args(0)
+{
+}
+
+SGCommandState::SGCommandState (const SGPropertyNode * args)
+  : _args(0)
+{
+  setArgs(args);
+}
+
+SGCommandState::~SGCommandState ()
+{
+  delete _args;
+}
+
+void
+SGCommandState::setArgs (const SGPropertyNode * args)
+{
+  delete _args;
+  _args = new SGPropertyNode();
+  copyProperties(args, _args);
+}
 
 
 \f
@@ -50,83 +81,14 @@ SGCommandMgr::getCommandNames () const
 }
 
 bool
-SGCommandMgr::execute (const string &name, const SGPropertyNode * arg) const
+SGCommandMgr::execute (const string &name, const SGPropertyNode * arg,
+                      SGCommandState ** state) const
 {
   command_t command = getCommand(name);
   if (command == 0)
     return false;
   else
-    return (*command)(arg);
-}
-
-
-bool
-SGCommandMgr::execute (const string &name) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  execute(name, &node);
-}
-
-
-bool
-SGCommandMgr::execute (const string &name, bool value) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  node.setBoolValue(value);
-  execute(name, &node);
-}
-
-
-bool
-SGCommandMgr::execute (const string &name, int value) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  node.setIntValue(value);
-  execute(name, &node);
-}
-
-
-bool
-SGCommandMgr::execute (const string &name, long value) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  node.setLongValue(value);
-  execute(name, &node);
+    return (*command)(arg, state);
 }
 
-
-bool
-SGCommandMgr::execute (const string &name, float value) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  node.setFloatValue(value);
-  execute(name, &node);
-}
-
-
-bool
-SGCommandMgr::execute (const string &name, double value) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  node.setDoubleValue(value);
-  execute(name, &node);
-}
-
-
-bool
-SGCommandMgr::execute (const string &name, string value) const
-{
-                               // FIXME
-  SGPropertyNode node;
-  node.setStringValue(value);
-  execute(name, &node);
-}
-
-
 // end of commands.cxx