From 0f14a2d73ba4a2f6447033e6a85d928896702b6c Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sat, 12 Jul 2014 01:17:35 +0200 Subject: [PATCH] subsystemFactor: name fixing (use same as in fg_init.cxx) and cleanup. --- src/Main/FGInterpolator.cxx | 34 ++++++-- src/Main/FGInterpolator.hxx | 24 ++++-- src/Main/fg_init.cxx | 6 +- src/Main/subsystemFactory.cxx | 146 ++++++++++++++++++++-------------- 4 files changed, 135 insertions(+), 75 deletions(-) diff --git a/src/Main/FGInterpolator.cxx b/src/Main/FGInterpolator.cxx index 2783e0c7f..89cb66804 100644 --- a/src/Main/FGInterpolator.cxx +++ b/src/Main/FGInterpolator.cxx @@ -1,15 +1,37 @@ -/* - * FGInterpolator.cxx - * - * Created on: 16.03.2013 - * Author: tom - */ +// Property interpolation manager for SGPropertyNodes +// +// Copyright (C) 2013 Thomas Geymayer +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA #include "FGInterpolator.hxx" +#include "fg_props.hxx" #include //------------------------------------------------------------------------------ FGInterpolator::FGInterpolator() { addInterpolatorFactory("color"); + + setRealtimeProperty( fgGetNode("/sim/time/delta-realtime-sec", true) ); + SGPropertyNode::setInterpolationMgr(this); +} + +//------------------------------------------------------------------------------ +FGInterpolator::~FGInterpolator() +{ + if( SGPropertyNode::getInterpolationMgr() == this ) + SGPropertyNode::setInterpolationMgr(0); } diff --git a/src/Main/FGInterpolator.hxx b/src/Main/FGInterpolator.hxx index ef7f62171..548522ddb 100644 --- a/src/Main/FGInterpolator.hxx +++ b/src/Main/FGInterpolator.hxx @@ -1,9 +1,20 @@ -/* - * FGInterpolator.hxx - * - * Created on: 16.03.2013 - * Author: tom - */ +///@file Property interpolation manager for SGPropertyNodes +// +// Copyright (C) 2013 Thomas Geymayer +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA #ifndef FG_INTERPOLATOR_HXX_ #define FG_INTERPOLATOR_HXX_ @@ -15,6 +26,7 @@ class FGInterpolator: { public: FGInterpolator(); + ~FGInterpolator(); }; diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index fb8774f0a..8efcb805d 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -677,10 +677,8 @@ void fgCreateSubsystems(bool duringReset) { // Initialize the property interpolator subsystem. Put into the INIT // group because the "nasal" subsystem may need it at GENERAL take-down. //////////////////////////////////////////////////////////////////// - FGInterpolator* interp = new FGInterpolator; - interp->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true)); - globals->add_subsystem("prop-interpolator", interp, SGSubsystemMgr::INIT); - SGPropertyNode::setInterpolationMgr(interp); + globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); + //////////////////////////////////////////////////////////////////// // Add the FlightGear property utilities. diff --git a/src/Main/subsystemFactory.cxx b/src/Main/subsystemFactory.cxx index b0729d64b..bd0d0057f 100644 --- a/src/Main/subsystemFactory.cxx +++ b/src/Main/subsystemFactory.cxx @@ -33,6 +33,7 @@ // subsystem includes #include +#include #include
#include
#include
@@ -45,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +63,7 @@ #include #include