subsystemFactor: name fixing (use same as in fg_init.cxx) and cleanup.
This commit is contained in:
parent
a52c0882a1
commit
0f14a2d73b
4 changed files with 135 additions and 75 deletions
|
@ -1,15 +1,37 @@
|
||||||
/*
|
// Property interpolation manager for SGPropertyNodes
|
||||||
* FGInterpolator.cxx
|
//
|
||||||
*
|
// Copyright (C) 2013 Thomas Geymayer <tomgey@gmail.com>
|
||||||
* Created on: 16.03.2013
|
//
|
||||||
* Author: tom
|
// 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 "FGInterpolator.hxx"
|
||||||
|
#include "fg_props.hxx"
|
||||||
#include <simgear/scene/util/ColorInterpolator.hxx>
|
#include <simgear/scene/util/ColorInterpolator.hxx>
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
FGInterpolator::FGInterpolator()
|
FGInterpolator::FGInterpolator()
|
||||||
{
|
{
|
||||||
addInterpolatorFactory<simgear::ColorInterpolator>("color");
|
addInterpolatorFactory<simgear::ColorInterpolator>("color");
|
||||||
|
|
||||||
|
setRealtimeProperty( fgGetNode("/sim/time/delta-realtime-sec", true) );
|
||||||
|
SGPropertyNode::setInterpolationMgr(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
FGInterpolator::~FGInterpolator()
|
||||||
|
{
|
||||||
|
if( SGPropertyNode::getInterpolationMgr() == this )
|
||||||
|
SGPropertyNode::setInterpolationMgr(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,20 @@
|
||||||
/*
|
///@file Property interpolation manager for SGPropertyNodes
|
||||||
* FGInterpolator.hxx
|
//
|
||||||
*
|
// Copyright (C) 2013 Thomas Geymayer <tomgey@gmail.com>
|
||||||
* Created on: 16.03.2013
|
//
|
||||||
* Author: tom
|
// 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_
|
#ifndef FG_INTERPOLATOR_HXX_
|
||||||
#define FG_INTERPOLATOR_HXX_
|
#define FG_INTERPOLATOR_HXX_
|
||||||
|
@ -15,6 +26,7 @@ class FGInterpolator:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGInterpolator();
|
FGInterpolator();
|
||||||
|
~FGInterpolator();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -677,10 +677,8 @@ void fgCreateSubsystems(bool duringReset) {
|
||||||
// Initialize the property interpolator subsystem. Put into the INIT
|
// Initialize the property interpolator subsystem. Put into the INIT
|
||||||
// group because the "nasal" subsystem may need it at GENERAL take-down.
|
// group because the "nasal" subsystem may need it at GENERAL take-down.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
FGInterpolator* interp = new FGInterpolator;
|
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT);
|
||||||
interp->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
|
|
||||||
globals->add_subsystem("prop-interpolator", interp, SGSubsystemMgr::INIT);
|
|
||||||
SGPropertyNode::setInterpolationMgr(interp);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Add the FlightGear property utilities.
|
// Add the FlightGear property utilities.
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
// subsystem includes
|
// subsystem includes
|
||||||
#include <Aircraft/controls.hxx>
|
#include <Aircraft/controls.hxx>
|
||||||
|
#include <Aircraft/FlightHistory.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Main/FGInterpolator.hxx>
|
#include <Main/FGInterpolator.hxx>
|
||||||
#include <Main/fg_io.hxx>
|
#include <Main/fg_io.hxx>
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
#include <Autopilot/route_mgr.hxx>
|
#include <Autopilot/route_mgr.hxx>
|
||||||
#include <Autopilot/autopilotgroup.hxx>
|
#include <Autopilot/autopilotgroup.hxx>
|
||||||
#include <Traffic/TrafficMgr.hxx>
|
#include <Traffic/TrafficMgr.hxx>
|
||||||
|
#include <Network/fgcom.hxx>
|
||||||
#include <Network/HTTPClient.hxx>
|
#include <Network/HTTPClient.hxx>
|
||||||
#include <Cockpit/cockpitDisplayManager.hxx>
|
#include <Cockpit/cockpitDisplayManager.hxx>
|
||||||
#include <GUI/new_gui.hxx>
|
#include <GUI/new_gui.hxx>
|
||||||
|
@ -61,6 +63,7 @@
|
||||||
#include <Canvas/gui_mgr.hxx>
|
#include <Canvas/gui_mgr.hxx>
|
||||||
#include <Time/light.hxx>
|
#include <Time/light.hxx>
|
||||||
#include <Viewer/viewmgr.hxx>
|
#include <Viewer/viewmgr.hxx>
|
||||||
|
#include <Model/acmodel.hxx>
|
||||||
#include <Model/modelmgr.hxx>
|
#include <Model/modelmgr.hxx>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
@ -72,39 +75,45 @@ SGSubsystem* createSubsystemByName(const std::string& name)
|
||||||
{
|
{
|
||||||
#define MAKE_SUB(cl, n) \
|
#define MAKE_SUB(cl, n) \
|
||||||
if (name == n) return new cl;
|
if (name == n) return new cl;
|
||||||
|
|
||||||
MAKE_SUB(FGControls, "controls");
|
|
||||||
MAKE_SUB(FGSoundManager, "sound");
|
MAKE_SUB(FGSoundManager, "sound");
|
||||||
MAKE_SUB(FGInterpolator, "prop-interpolator")
|
MAKE_SUB(FGInterpolator, "prop-interpolator")
|
||||||
MAKE_SUB(FGProperties, "properties");
|
MAKE_SUB(FGProperties, "properties");
|
||||||
|
MAKE_SUB(FGHTTPClient, "http");
|
||||||
MAKE_SUB(FDMShell, "flight");
|
MAKE_SUB(FDMShell, "flight");
|
||||||
MAKE_SUB(FGEnvironmentMgr, "environment");
|
MAKE_SUB(FGEnvironmentMgr, "environment");
|
||||||
MAKE_SUB(Ephemeris, "ephemeris");
|
MAKE_SUB(Ephemeris, "ephemeris");
|
||||||
MAKE_SUB(FGSystemMgr, "aircraft-systems");
|
MAKE_SUB(FGSystemMgr, "systems");
|
||||||
MAKE_SUB(FGInstrumentMgr, "instruments");
|
MAKE_SUB(FGInstrumentMgr, "instrumentation");
|
||||||
MAKE_SUB(HUD, "hud");
|
MAKE_SUB(HUD, "hud");
|
||||||
MAKE_SUB(flightgear::CockpitDisplayManager, "cockpit-displays");
|
MAKE_SUB(flightgear::CockpitDisplayManager, "cockpit-displays");
|
||||||
MAKE_SUB(FGIO, "io");
|
|
||||||
MAKE_SUB(FGHTTPClient, "http");
|
|
||||||
MAKE_SUB(FGRouteMgr, "route-manager");
|
MAKE_SUB(FGRouteMgr, "route-manager");
|
||||||
|
MAKE_SUB(FGIO, "io");
|
||||||
MAKE_SUB(FGLogger, "logger");
|
MAKE_SUB(FGLogger, "logger");
|
||||||
MAKE_SUB(NewGUI, "gui");
|
MAKE_SUB(NewGUI, "gui");
|
||||||
MAKE_SUB(FGATCManager, "atc");
|
MAKE_SUB(CanvasMgr, "Canvas");
|
||||||
|
MAKE_SUB(GUIMgr, "CanvasGUI");
|
||||||
|
MAKE_SUB(FGATCManager, "ATC");
|
||||||
MAKE_SUB(FGMultiplayMgr, "mp");
|
MAKE_SUB(FGMultiplayMgr, "mp");
|
||||||
|
MAKE_SUB(FGAIManager, "ai-model");
|
||||||
|
MAKE_SUB(FGSubmodelMgr, "submodel-mgr");
|
||||||
MAKE_SUB(FGTrafficManager, "traffic-manager");
|
MAKE_SUB(FGTrafficManager, "traffic-manager");
|
||||||
MAKE_SUB(FGAIManager, "ai-manager");
|
|
||||||
MAKE_SUB(FGSubmodelMgr, "submodel-manager");
|
|
||||||
MAKE_SUB(FGControls, "controls");
|
MAKE_SUB(FGControls, "controls");
|
||||||
MAKE_SUB(FGInput, "input");
|
MAKE_SUB(FGInput, "input");
|
||||||
MAKE_SUB(FGReplay, "replay");
|
MAKE_SUB(FGReplay, "replay");
|
||||||
|
MAKE_SUB(FGFlightHistory, "history");
|
||||||
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
MAKE_SUB(FGVoiceMgr, "voice");
|
MAKE_SUB(FGVoiceMgr, "voice");
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_IAX
|
||||||
|
MAKE_SUB(FGCom, "fgcom");
|
||||||
|
#endif
|
||||||
MAKE_SUB(FGLight, "lighting");
|
MAKE_SUB(FGLight, "lighting");
|
||||||
MAKE_SUB(CanvasMgr, "canvas");
|
MAKE_SUB(FGAircraftModel, "aircraft-model");
|
||||||
MAKE_SUB(GUIMgr, "canvas-gui");
|
|
||||||
MAKE_SUB(FGViewMgr, "view-manager");
|
|
||||||
MAKE_SUB(FGModelMgr, "model-manager");
|
MAKE_SUB(FGModelMgr, "model-manager");
|
||||||
|
MAKE_SUB(FGViewMgr, "view-manager");
|
||||||
#undef MAKE_SUB
|
#undef MAKE_SUB
|
||||||
|
|
||||||
throw sg_range_exception("unknown subsystem:" + name);
|
throw sg_range_exception("unknown subsystem:" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,55 +130,73 @@ SGSubsystemMgr::GroupType mapGroupNameToType(const std::string& s)
|
||||||
return SGSubsystemMgr::GENERAL;
|
return SGSubsystemMgr::GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SGSubsystem* getSubsystem(const SGPropertyNode* arg, bool create)
|
||||||
|
{
|
||||||
|
std::string subsystem(arg->getStringValue("subsystem"));
|
||||||
|
std::string name = arg->getStringValue("name");
|
||||||
|
|
||||||
|
if (name.empty()) {
|
||||||
|
// default name is simply the subsytem's name
|
||||||
|
name = subsystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
SGSubsystem* sys = globals->get_subsystem_mgr()->get_subsystem(name);
|
||||||
|
if (!create)
|
||||||
|
return sys;
|
||||||
|
|
||||||
|
if( subsystem.empty() ) {
|
||||||
|
SG_LOG( SG_GENERAL,
|
||||||
|
SG_ALERT,
|
||||||
|
"do_add_subsystem: no subsystem/name supplied" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sys) {
|
||||||
|
SG_LOG( SG_GENERAL,
|
||||||
|
SG_ALERT,
|
||||||
|
"do_add_subsystem: duplicate subsystem name:" << name );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string groupname = arg->getStringValue("group");
|
||||||
|
SGSubsystemMgr::GroupType group = SGSubsystemMgr::GENERAL;
|
||||||
|
if (!groupname.empty()) {
|
||||||
|
group = mapGroupNameToType(groupname);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sys = createSubsystemByName(subsystem);
|
||||||
|
} catch (sg_exception& e) {
|
||||||
|
SG_LOG( SG_GENERAL,
|
||||||
|
SG_ALERT,
|
||||||
|
"subsystem creation failed:" << name
|
||||||
|
<< ":" << e.getFormattedMessage() );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool doInit = arg->getBoolValue("do-bind-init", false);
|
||||||
|
if (doInit) {
|
||||||
|
sys->bind();
|
||||||
|
sys->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
double minTime = arg->getDoubleValue("min-time-sec", 0.0);
|
||||||
|
globals->get_subsystem_mgr()
|
||||||
|
->add(name.c_str(), sys, group, minTime);
|
||||||
|
|
||||||
|
return sys;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
do_check_subsystem_running(const SGPropertyNode* arg)
|
||||||
|
{
|
||||||
|
return getSubsystem(arg, false) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_add_subsystem (const SGPropertyNode * arg)
|
do_add_subsystem (const SGPropertyNode * arg)
|
||||||
{
|
{
|
||||||
std::string subsystem(arg->getStringValue("subsystem"));
|
return getSubsystem(arg, true) != 0;
|
||||||
std::string name = arg->getStringValue("name");
|
|
||||||
if (subsystem.empty()) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "do_add_subsystem:"
|
|
||||||
<< "no subsystem/name supplied");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (name.empty()) {
|
|
||||||
// default name is simply the subsytem's name
|
|
||||||
name = subsystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (globals->get_subsystem_mgr()->get_subsystem(name)) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "do_add_subsystem:"
|
|
||||||
<< "duplicate subsystem name:" << name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string groupname = arg->getStringValue("group");
|
|
||||||
SGSubsystemMgr::GroupType group = SGSubsystemMgr::GENERAL;
|
|
||||||
if (!groupname.empty()) {
|
|
||||||
group = mapGroupNameToType(groupname);
|
|
||||||
}
|
|
||||||
|
|
||||||
SGSubsystem* instance = NULL;
|
|
||||||
try {
|
|
||||||
instance = createSubsystemByName(subsystem);
|
|
||||||
} catch (sg_exception& e) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "subsystem creation failed:" <<
|
|
||||||
name << ":" << e.getFormattedMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool doInit = arg->getBoolValue("do-bind-init", false);
|
|
||||||
if (doInit) {
|
|
||||||
instance->bind();
|
|
||||||
instance->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
double minTime = arg->getDoubleValue("min-time-sec", 0.0);
|
|
||||||
globals->get_subsystem_mgr()->add(name.c_str(), instance,
|
|
||||||
group, minTime);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool do_remove_subsystem(const SGPropertyNode * arg)
|
static bool do_remove_subsystem(const SGPropertyNode * arg)
|
||||||
|
@ -282,6 +309,7 @@ static struct {
|
||||||
} built_ins [] = {
|
} built_ins [] = {
|
||||||
{ "add-subsystem", do_add_subsystem },
|
{ "add-subsystem", do_add_subsystem },
|
||||||
{ "remove-subsystem", do_remove_subsystem },
|
{ "remove-subsystem", do_remove_subsystem },
|
||||||
|
{ "subsystem-running", do_check_subsystem_running },
|
||||||
{ "reinit", do_reinit },
|
{ "reinit", do_reinit },
|
||||||
{ "suspend", do_suspend },
|
{ "suspend", do_suspend },
|
||||||
{ "resume", do_resume },
|
{ "resume", do_resume },
|
||||||
|
|
Loading…
Add table
Reference in a new issue