From a464d1b2b2bb421f06597f10f1d2cc6867cb77ba Mon Sep 17 00:00:00 2001
From: torsten <torsten>
Date: Thu, 15 Apr 2010 12:31:12 +0000
Subject: [PATCH] use simgear::PropertyList instead of
 std::vector<SGPropertyNode_ptr>

---
 src/Autopilot/xmlauto.cxx              |  4 ++--
 src/Autopilot/xmlauto.hxx              |  8 +++++---
 src/Input/FGCommonInput.cxx            |  4 +++-
 src/Input/FGDeviceConfigurationMap.cxx |  6 ++++--
 src/Input/FGEventInput.cxx             | 10 ++++++----
 src/Input/FGJoystickInput.cxx          |  8 +++++---
 src/Input/FGKeyboardInput.cxx          |  6 ++++--
 src/Input/fgjs.cxx                     |  9 +++++----
 8 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/src/Autopilot/xmlauto.cxx b/src/Autopilot/xmlauto.cxx
index 2a3349ad8..1c1498d5c 100644
--- a/src/Autopilot/xmlauto.cxx
+++ b/src/Autopilot/xmlauto.cxx
@@ -1003,13 +1003,13 @@ void FGXMLAutopilotGroup::reinit()
 
 void FGXMLAutopilotGroup::init()
 {
-    vector<SGPropertyNode_ptr> autopilotNodes = fgGetNode( "/sim/systems", true )->getChildren("autopilot");
+    PropertyList autopilotNodes = fgGetNode( "/sim/systems", true )->getChildren("autopilot");
     if( autopilotNodes.size() == 0 ) {
         SG_LOG( SG_ALL, SG_WARN, "No autopilot configuration specified for this model!");
         return;
     }
 
-    for( vector<SGPropertyNode_ptr>::size_type i = 0; i < autopilotNodes.size(); i++ ) {
+    for( PropertyList::size_type i = 0; i < autopilotNodes.size(); i++ ) {
         SGPropertyNode_ptr pathNode = autopilotNodes[i]->getNode( "path" );
         if( pathNode == NULL ) {
             SG_LOG( SG_ALL, SG_WARN, "No autopilot configuration file specified for this autopilot!");
diff --git a/src/Autopilot/xmlauto.hxx b/src/Autopilot/xmlauto.hxx
index d3b5fa34e..45a90d56b 100644
--- a/src/Autopilot/xmlauto.hxx
+++ b/src/Autopilot/xmlauto.hxx
@@ -49,6 +49,8 @@ and writes properties used only by a few aircraft.
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/props/condition.hxx>
 
+using simgear::PropertyList;
+
 typedef SGSharedPtr<class FGXMLAutoInput> FGXMLAutoInput_ptr;
 typedef SGSharedPtr<class FGPeriodicalValue> FGPeriodicalValue_ptr;
 
@@ -122,7 +124,7 @@ class FGXMLAutoInputList : public std::vector<FGXMLAutoInput_ptr> {
 class FGXMLAutoComponent : public SGReferenced {
 
 private:
-    std::vector <SGPropertyNode_ptr> output_list;
+    PropertyList output_list;
 
     SGSharedPtr<const SGCondition> _condition;
     SGPropertyNode_ptr enable_prop;
@@ -201,7 +203,7 @@ public:
         // helpful for things like flight directors which position
         // their vbars from the autopilot computations.
         if ( honor_passive && passive_mode->getBoolValue() ) return;
-        for( std::vector <SGPropertyNode_ptr>::iterator it = output_list.begin(); it != output_list.end(); ++it)
+        for( PropertyList::iterator it = output_list.begin(); it != output_list.end(); ++it)
           (*it)->setDoubleValue( clamp( value ) );
     }
 
@@ -212,7 +214,7 @@ public:
         // helpful for things like flight directors which position
         // their vbars from the autopilot computations.
         if ( honor_passive && passive_mode->getBoolValue() ) return;
-        for( std::vector <SGPropertyNode_ptr>::iterator it = output_list.begin(); it != output_list.end(); ++it)
+        for( PropertyList::iterator it = output_list.begin(); it != output_list.end(); ++it)
           (*it)->setBoolValue( value ); // don't use clamp here, bool is clamped anyway
     }
 
diff --git a/src/Input/FGCommonInput.cxx b/src/Input/FGCommonInput.cxx
index a94537d47..3e9d92aa9 100644
--- a/src/Input/FGCommonInput.cxx
+++ b/src/Input/FGCommonInput.cxx
@@ -32,10 +32,12 @@
 
 #include <simgear/math/SGMath.hxx>
 
+using simgear::PropertyList;
+
 void FGCommonInput::read_bindings (const SGPropertyNode * node, binding_list_t * binding_list, int modifiers, const string & module )
 {
   SG_LOG(SG_INPUT, SG_DEBUG, "Reading all bindings");
-  vector<SGPropertyNode_ptr> bindings = node->getChildren("binding");
+  PropertyList bindings = node->getChildren("binding");
   static string nasal = "nasal";
   for (unsigned int i = 0; i < bindings.size(); i++) {
     const char *cmd = bindings[i]->getStringValue("command");
diff --git a/src/Input/FGDeviceConfigurationMap.cxx b/src/Input/FGDeviceConfigurationMap.cxx
index 431a6fa5e..5ad2a0bd7 100644
--- a/src/Input/FGDeviceConfigurationMap.cxx
+++ b/src/Input/FGDeviceConfigurationMap.cxx
@@ -35,6 +35,8 @@
 #include <simgear/props/props_io.hxx>
 #include <Main/globals.hxx>
 
+using simgear::PropertyList;
+
 FGDeviceConfigurationMap::FGDeviceConfigurationMap( const char * relative_path, SGPropertyNode_ptr aBase, const char * aChildname ) :
   base(aBase),
   childname(aChildname)
@@ -45,10 +47,10 @@ FGDeviceConfigurationMap::FGDeviceConfigurationMap( const char * relative_path,
   int index = 1000;
   scan_dir( path, &index);
 
-  vector<SGPropertyNode_ptr> childNodes = base->getChildren(childname);
+  PropertyList childNodes = base->getChildren(childname);
   for (int k = (int)childNodes.size() - 1; k >= 0; k--) {
     SGPropertyNode *n = childNodes[k];
-    vector<SGPropertyNode_ptr> names = n->getChildren("name");
+    PropertyList names = n->getChildren("name");
     if (names.size() ) // && (n->getChildren("axis").size() || n->getChildren("button").size()))
       for (unsigned int j = 0; j < names.size(); j++)
         (*this)[names[j]->getStringValue()] = n;
diff --git a/src/Input/FGEventInput.cxx b/src/Input/FGEventInput.cxx
index 928c20c24..31e6fc978 100644
--- a/src/Input/FGEventInput.cxx
+++ b/src/Input/FGEventInput.cxx
@@ -29,6 +29,8 @@
 #include <simgear/io/sg_file.hxx>
 #include <Scripting/NasalSys.hxx>
 
+using simgear::PropertyList;
+
 FGEventSetting::FGEventSetting( SGPropertyNode_ptr base ) :
   value(0.0)
 {
@@ -93,8 +95,8 @@ FGInputEvent::FGInputEvent( FGInputDevice * aDevice, SGPropertyNode_ptr node ) :
   
   read_bindings( node, bindings, KEYMOD_NONE, device->GetNasalModule() );
 
-  vector<SGPropertyNode_ptr> settingNodes = node->getChildren("setting");
-  for( vector<SGPropertyNode_ptr>::iterator it = settingNodes.begin(); it != settingNodes.end(); it++ )
+  PropertyList settingNodes = node->getChildren("setting");
+  for( PropertyList::iterator it = settingNodes.begin(); it != settingNodes.end(); it++ )
     settings.push_back( new FGEventSetting( *it ) );
 }
 
@@ -235,8 +237,8 @@ void FGInputDevice::Configure( SGPropertyNode_ptr aDeviceNode )
 
   nasalModule = string("__event:") + GetName();
 
-  vector<SGPropertyNode_ptr> eventNodes = deviceNode->getChildren( "event" );
-  for( vector<SGPropertyNode_ptr>::iterator it = eventNodes.begin(); it != eventNodes.end(); it++ )
+  PropertyList eventNodes = deviceNode->getChildren( "event" );
+  for( PropertyList::iterator it = eventNodes.begin(); it != eventNodes.end(); it++ )
     AddHandledEvent( FGInputEvent::NewObject( this, *it ) );
 
   debugEvents = deviceNode->getBoolValue("debug-events", debugEvents );
diff --git a/src/Input/FGJoystickInput.cxx b/src/Input/FGJoystickInput.cxx
index 5c3b82b2e..349782d5b 100644
--- a/src/Input/FGJoystickInput.cxx
+++ b/src/Input/FGJoystickInput.cxx
@@ -27,6 +27,8 @@
 #include <Main/fg_props.hxx>
 #include <Scripting/NasalSys.hxx>
 
+using simgear::PropertyList;
+
 FGJoystickInput::axis::axis ()
   : last_value(9999999),
     tolerance(0.002),
@@ -166,7 +168,7 @@ void FGJoystickInput::postinit()
     string module = str.str();
     nasalsys->createModule(module.c_str(), module.c_str(), "", 0);
 
-    vector<SGPropertyNode_ptr> nasal = js_node->getChildren("nasal");
+    PropertyList nasal = js_node->getChildren("nasal");
     unsigned int j;
     for (j = 0; j < nasal.size(); j++) {
       nasal[j]->setStringValue("module", module.c_str());
@@ -176,7 +178,7 @@ void FGJoystickInput::postinit()
     //
     // Initialize the axes.
     //
-    vector<SGPropertyNode_ptr> axes = js_node->getChildren("axis");
+    PropertyList axes = js_node->getChildren("axis");
     size_t nb_axes = axes.size();
     for (j = 0; j < nb_axes; j++ ) {
       const SGPropertyNode * axis_node = axes[j];
@@ -219,7 +221,7 @@ void FGJoystickInput::postinit()
     //
     // Initialize the buttons.
     //
-    vector<SGPropertyNode_ptr> buttons = js_node->getChildren("button");
+    PropertyList buttons = js_node->getChildren("button");
     char buf[32];
     for (j = 0; j < buttons.size() && j < nbuttons; j++) {
       const SGPropertyNode * button_node = buttons[j];
diff --git a/src/Input/FGKeyboardInput.cxx b/src/Input/FGKeyboardInput.cxx
index f4d20d66c..94c485c6a 100644
--- a/src/Input/FGKeyboardInput.cxx
+++ b/src/Input/FGKeyboardInput.cxx
@@ -27,6 +27,8 @@
 #include <Scripting/NasalSys.hxx>
 #include <plib/pu.h>
 
+using simgear::PropertyList;
+
 static int getModifiers ()
 {
   return fgGetKeyModifiers() >> 1;
@@ -94,13 +96,13 @@ void FGKeyboardInput::postinit()
   }
 
   FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
-  vector<SGPropertyNode_ptr> nasal = key_nodes->getChildren("nasal");
+  PropertyList nasal = key_nodes->getChildren("nasal");
   for (unsigned int j = 0; j < nasal.size(); j++) {
     nasal[j]->setStringValue("module", module.c_str());
     nasalsys->handleCommand(nasal[j]);
   }
 
-  vector<SGPropertyNode_ptr> keys = key_nodes->getChildren("key");
+  PropertyList keys = key_nodes->getChildren("key");
   for (unsigned int i = 0; i < keys.size(); i++) {
     int index = keys[i]->getIndex();
     SG_LOG(SG_INPUT, SG_DEBUG, "Binding key " << index);
diff --git a/src/Input/fgjs.cxx b/src/Input/fgjs.cxx
index 9391c022a..f1930b0e3 100644
--- a/src/Input/fgjs.cxx
+++ b/src/Input/fgjs.cxx
@@ -58,6 +58,7 @@ using std::string;
 
 #include "jsinput.h"
 
+using simgear::PropertyList;
 
 bool confirmAnswer() {
     char answer;
@@ -136,8 +137,8 @@ int main( int argc, char *argv[] ) {
         cout << e.getFormattedMessage ();
     }
 
-    vector<SGPropertyNode_ptr> axes = templatetree->getChildren("axis");
-    for(vector<SGPropertyNode_ptr>::iterator iter = axes.begin(); iter != axes.end(); iter++) {
+    PropertyList axes = templatetree->getChildren("axis");
+    for(PropertyList::iterator iter = axes.begin(); iter != axes.end(); iter++) {
         cout << "Move the control you wish to use for " << (*iter)->getStringValue("desc")
              << " " << (*iter)->getStringValue("direction") << endl;
         cout << "Pressing a button skips this axis" << endl;
@@ -164,8 +165,8 @@ int main( int argc, char *argv[] ) {
         cout << endl;
     }
 
-    vector<SGPropertyNode_ptr> buttons = templatetree->getChildren("button");
-    for(vector<SGPropertyNode_ptr>::iterator iter = buttons.begin(); iter != buttons.end(); iter++) {
+    PropertyList buttons = templatetree->getChildren("button");
+    for(PropertyList::iterator iter = buttons.begin(); iter != buttons.end(); iter++) {
         cout << "Press the button you wish to use for " << (*iter)->getStringValue("desc") << endl;
         cout << "Moving a joystick axis skips this button" << endl;
         fflush( stdout );