From 0de065b0ec38d45ab4b10ed60e2cfa411fb453f2 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 6 Nov 2002 18:57:31 +0000 Subject: [PATCH] Added fgLoadProps to load properties from a path relative to FG_ROOT. --- src/GUI/gui.cxx | 4 +--- src/Main/fg_commands.cxx | 8 ++------ src/Main/fg_init.cxx | 4 +--- src/Main/fg_props.cxx | 10 ++++++++++ src/Main/fg_props.hxx | 8 ++++++++ src/Main/fgfs.cxx | 15 +++++++++++++++ src/Main/fgfs.hxx | 6 +++--- src/Main/options.cxx | 4 +--- 8 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 582215022..4290659eb 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -78,11 +78,9 @@ unsigned int Menu_size; void initMenu() { SGPropertyNode main; - SGPath spath( globals->get_fg_root() ); - spath.append( "menu.xml" ); try { - readProperties(spath.c_str(), &main); + fgLoadProps("menu.xml", &main); } catch (const sg_exception &ex) { SG_LOG(SG_GENERAL, SG_ALERT, "Error processing the menu file."); return; diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index f6db36d84..4f6284709 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -205,13 +205,9 @@ do_panel_mouse_click (const SGPropertyNode * arg) static bool do_preferences_load (const SGPropertyNode * arg) { - const string &path = arg->getStringValue("path", "preferences.xml"); - SGPath props_path(globals->get_fg_root()); - props_path.append(path); - SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences from " - << props_path.str()); try { - readProperties(props_path.str(), globals->get_props()); + fgLoadProps(arg->getStringValue("path", "preferences.xml"), + globals->get_props()); } catch (const sg_exception &e) { guiErrorMessage("Error reading global preferences: ", e); return false; diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index af0c1d25c..a603ef61f 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -389,10 +389,8 @@ bool fgInitConfig ( int argc, char **argv ) { fgSetDefaults(); // Read global preferences from $FG_ROOT/preferences.xml - SGPath props_path(globals->get_fg_root()); - props_path.append("preferences.xml"); SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences"); - readProperties(props_path.str(), globals->get_props()); + fgLoadProps("preferences.xml", globals->get_props()); SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences"); // Detect the required language as early as possible diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index c82aec138..74a3a6578 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include STL_IOSTREAM @@ -679,6 +680,15 @@ fgLoadFlight (istream &input) } +void +fgLoadProps (const char * path, SGPropertyNode * props) +{ + SGPath loadpath(globals->get_fg_root()); + loadpath.append(path); + readProperties(loadpath.c_str(), props); +} + + //////////////////////////////////////////////////////////////////////// // Property convenience functions. diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 1f9a1f87d..0e5f311ac 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -64,6 +64,14 @@ extern bool fgSaveFlight (ostream &output, bool write_all = false); extern bool fgLoadFlight (istream &input); +/** + * Load properties from a file relative to $FG_ROOT. + * + * @param file The file name relative to $FG_ROOT. + */ +extern void fgLoadProps (const char * path, SGPropertyNode * props); + + //////////////////////////////////////////////////////////////////////// // Convenience functions for getting property values. diff --git a/src/Main/fgfs.cxx b/src/Main/fgfs.cxx index f6727b4f8..b85497fb6 100644 --- a/src/Main/fgfs.cxx +++ b/src/Main/fgfs.cxx @@ -21,6 +21,21 @@ FGSubsystem::~FGSubsystem () { } +void +FGSubsystem::init () +{ +} + +void +FGSubsystem::bind () +{ +} + +void +FGSubsystem::unbind () +{ +} + void FGSubsystem::suspend () { diff --git a/src/Main/fgfs.hxx b/src/Main/fgfs.hxx index 942eee317..a1cc83b90 100644 --- a/src/Main/fgfs.hxx +++ b/src/Main/fgfs.hxx @@ -145,7 +145,7 @@ public: * in the constructor, so that FlightGear can control the * initialization order.

*/ - virtual void init () = 0; + virtual void init (); /** @@ -155,7 +155,7 @@ public: * publishes. It will be invoked after init, but before any * invocations of update.

*/ - virtual void bind () = 0; + virtual void bind (); /** @@ -165,7 +165,7 @@ public: * publishes. It will be invoked by FlightGear (not the destructor) * just before the subsystem is removed.

*/ - virtual void unbind () = 0; + virtual void unbind (); /** diff --git a/src/Main/options.cxx b/src/Main/options.cxx index abbbcd1d4..24e3a191b 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1160,13 +1160,11 @@ fgUsage (bool verbose) SGPropertyNode *locale = globals->get_locale(); SGPropertyNode options_root; - SGPath opath( globals->get_fg_root() ); - opath.append( "options.xml" ); cout << "" << endl; try { - readProperties(opath.c_str(), &options_root); + fgLoadProps("options.xml", &options_root); } catch (const sg_exception &ex) { cout << "Unable to read the help file." << endl; cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl; -- 2.39.5