From: curt Date: Fri, 5 Jan 2001 17:37:59 +0000 (+0000) Subject: Contibuted by David Megginson; Initial revision. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5ef00ab621d118b0695f0c167cf3369d49f206da;p=flightgear.git Contibuted by David Megginson; Initial revision. --- diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx new file mode 100644 index 000000000..46bc65838 --- /dev/null +++ b/src/Main/fg_props.cxx @@ -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 + +#include
+#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 index 000000000..904174ddd --- /dev/null +++ b/src/Main/fg_props.hxx @@ -0,0 +1,120 @@ +#ifndef __FG_PROPS_HXX +#define __FG_PROPS_HXX 1 + +#include +#include +#include "globals.hxx" + + +//////////////////////////////////////////////////////////////////////// +// Loading and saving properties. +//////////////////////////////////////////////////////////////////////// + +extern bool fgSaveFlight (ostream &output); +extern bool fgLoadFlight (istream &input); + + + +//////////////////////////////////////////////////////////////////////// +// 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(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(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(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(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(pointer))) + FG_LOG(FG_GENERAL, FG_WARN, + "Failed to tie property " << name << " to a pointer"); +} + +template +inline void +fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0) +{ + if (!globals->get_props()->tie(name, SGRawValueFunctions(getter, setter))) + FG_LOG(FG_GENERAL, FG_WARN, + "Failed to tie property " << name << " to functions"); +} + +template +inline void +fgTie (const string &name, int index, V (*getter)(int), + void (*setter)(int, V) = 0) +{ + if (!globals->get_props()->tie(name, + SGRawValueFunctionsIndexed(index, + getter, + setter))) + FG_LOG(FG_GENERAL, FG_WARN, + "Failed to tie property " << name << " to indexed functions"); +} + +template +inline void +fgTie (const string &name, T * obj, V (T::*getter)() const, + void (T::*setter)(V) = 0) +{ + if (!globals->get_props()->tie(name, + SGRawValueMethods(*obj, getter, setter))) + FG_LOG(FG_GENERAL, FG_WARN, + "Failed to tie property " << name << " to object methods"); +} + +template +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(*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 index 000000000..33e281f6a --- /dev/null +++ b/src/Main/fgfs.cxx @@ -0,0 +1,20 @@ +#include "fgfs.hxx" + +#include + +#include "globals.hxx" + + + +//////////////////////////////////////////////////////////////////////// +// 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 index 000000000..b2e8c7ac6 --- /dev/null +++ b/src/Main/fgfs.hxx @@ -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 +#endif + +#ifdef FG_MATH_EXCEPTION_CLASH +# include +#endif + +#ifdef HAVE_WINDOWS_H +# include +# include +#endif + + + +/** + * 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