]> git.mxchange.org Git - flightgear.git/commitdiff
Contibuted by David Megginson; Initial revision.
authorcurt <curt>
Fri, 5 Jan 2001 17:37:59 +0000 (17:37 +0000)
committercurt <curt>
Fri, 5 Jan 2001 17:37:59 +0000 (17:37 +0000)
src/Main/fg_props.cxx [new file with mode: 0644]
src/Main/fg_props.hxx [new file with mode: 0644]
src/Main/fgfs.cxx [new file with mode: 0644]
src/Main/fgfs.hxx [new file with mode: 0644]

diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx
new file mode 100644 (file)
index 0000000..46bc658
--- /dev/null
@@ -0,0 +1,52 @@
+// fg_props.cxx -- support for
+//
+// Written by David Megginson, started November 1999.
+//
+// Copyright (C) 1999, 2000 David Megginson - david@megginson.com
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program 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
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+#include <iostream>
+
+#include <Main/fgfs.hxx>
+#include "fg_props.hxx"
+
+using std::istream;
+using std::ostream;
+
+
+/**
+ * Save the current state of the simulator to a stream.
+ */
+bool
+fgSaveFlight (ostream &output)
+{
+  return writeProperties(output, globals->get_props());
+}
+
+
+/**
+ * Restore the current state of the simulator from a stream.
+ */
+bool
+fgLoadFlight (istream &input)
+{
+  return readProperties(input, globals->get_props());
+}
+
+// end of fg_props.cxx
+
diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx
new file mode 100644 (file)
index 0000000..904174d
--- /dev/null
@@ -0,0 +1,120 @@
+#ifndef __FG_PROPS_HXX
+#define __FG_PROPS_HXX 1
+
+#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/props.hxx>
+#include "globals.hxx"
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Loading and saving properties.
+////////////////////////////////////////////////////////////////////////
+
+extern bool fgSaveFlight (ostream &output);
+extern bool fgLoadFlight (istream &input);
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Convenience functions for tying properties, with logging.
+////////////////////////////////////////////////////////////////////////
+
+inline void
+fgUntie (const string &name)
+{
+  if (!globals->get_props()->untie(name))
+    FG_LOG(FG_GENERAL, FG_WARN, "Failed to untie property " << name);
+}
+
+
+                               // Templates cause ambiguity here
+inline void
+fgTie (const string &name, bool *pointer)
+{
+  if (!globals->get_props()->tie(name, SGRawValuePointer<bool>(pointer)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to a pointer");
+}
+
+inline void
+fgTie (const string &name, int *pointer)
+{
+  if (!globals->get_props()->tie(name, SGRawValuePointer<int>(pointer)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to a pointer");
+}
+
+inline void
+fgTie (const string &name, float *pointer)
+{
+  if (!globals->get_props()->tie(name, SGRawValuePointer<float>(pointer)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to a pointer");
+}
+
+inline void
+fgTie (const string &name, double *pointer)
+{
+  if (!globals->get_props()->tie(name, SGRawValuePointer<double>(pointer)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to a pointer");
+}
+
+inline void
+fgTie (const string &name, string *pointer)
+{
+  if (!globals->get_props()->tie(name, SGRawValuePointer<string>(pointer)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to a pointer");
+}
+
+template <class V>
+inline void
+fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0)
+{
+  if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to functions");
+}
+
+template <class V>
+inline void
+fgTie (const string &name, int index, V (*getter)(int),
+       void (*setter)(int, V) = 0)
+{
+  if (!globals->get_props()->tie(name,
+                                SGRawValueFunctionsIndexed<V>(index,
+                                                              getter,
+                                                              setter)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to indexed functions");
+}
+
+template <class T, class V>
+inline void
+fgTie (const string &name, T * obj, V (T::*getter)() const,
+       void (T::*setter)(V) = 0)
+{
+  if (!globals->get_props()->tie(name,
+                                SGRawValueMethods<T,V>(*obj, getter, setter)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to object methods");
+}
+
+template <class T, class V>
+inline void 
+fgTie (const string &name, T * obj, int index,
+       V (T::*getter)(int) const, void (T::*setter)(int, V) = 0)
+{
+  if (!globals->get_props()->tie(name,
+                                SGRawValueMethodsIndexed<T,V>(*obj,
+                                                              index,
+                                                              getter,
+                                                              setter)))
+    FG_LOG(FG_GENERAL, FG_WARN,
+          "Failed to tie property " << name << " to indexed object methods");
+}
+
+
+#endif // __FG_PROPS_HXX
+
diff --git a/src/Main/fgfs.cxx b/src/Main/fgfs.cxx
new file mode 100644 (file)
index 0000000..33e281f
--- /dev/null
@@ -0,0 +1,20 @@
+#include "fgfs.hxx"
+
+#include <simgear/debug/logstream.hxx>
+
+#include "globals.hxx"
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGSubsystem
+////////////////////////////////////////////////////////////////////////
+
+
+FGSubsystem::~FGSubsystem ()
+{
+  // NO-OP
+}
+
+
+// end of fgfs.cxx
diff --git a/src/Main/fgfs.hxx b/src/Main/fgfs.hxx
new file mode 100644 (file)
index 0000000..b2e8c7a
--- /dev/null
@@ -0,0 +1,60 @@
+// fgfs.hxx -- top level include file for FlightGear.
+//
+// Written by David Megginson, started 2000-12
+//
+// Copyright (C) 2000  David Megginson, david@megginson.com
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program 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
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#ifndef __FGFS_HXX
+#define __FGFS_HXX 1
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#ifdef FG_MATH_EXCEPTION_CLASH
+#  include <math.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#  include <windows.h>                     
+#  include <float.h>                    
+#endif
+
+
+\f
+/**
+ * Basic interface for all FlightGear subsystems.
+ */
+class FGSubsystem
+{
+public:
+  virtual ~FGSubsystem ();
+
+  virtual void init () = 0;
+  virtual void bind () = 0;
+  virtual void unbind () = 0;
+  virtual void update () = 0;
+};
+
+
+#endif // __FGFS_HXX
+
+// end of fgfs.hxx