Contibuted by David Megginson; Initial revision.
This commit is contained in:
parent
3e7bc24006
commit
5ef00ab621
4 changed files with 252 additions and 0 deletions
52
src/Main/fg_props.cxx
Normal file
52
src/Main/fg_props.cxx
Normal file
|
@ -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
|
||||
|
120
src/Main/fg_props.hxx
Normal file
120
src/Main/fg_props.hxx
Normal file
|
@ -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"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// 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<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
|
||||
|
20
src/Main/fgfs.cxx
Normal file
20
src/Main/fgfs.cxx
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "fgfs.hxx"
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "globals.hxx"
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of FGSubsystem
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
FGSubsystem::~FGSubsystem ()
|
||||
{
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
|
||||
// end of fgfs.cxx
|
60
src/Main/fgfs.hxx
Normal file
60
src/Main/fgfs.hxx
Normal file
|
@ -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
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
Loading…
Add table
Reference in a new issue