From a464d1b2b2bb421f06597f10f1d2cc6867cb77ba Mon Sep 17 00:00:00 2001 From: torsten Date: Thu, 15 Apr 2010 12:31:12 +0000 Subject: [PATCH 1/2] use simgear::PropertyList instead of std::vector --- 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 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::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 #include +using simgear::PropertyList; + typedef SGSharedPtr FGXMLAutoInput_ptr; typedef SGSharedPtr FGPeriodicalValue_ptr; @@ -122,7 +124,7 @@ class FGXMLAutoInputList : public std::vector { class FGXMLAutoComponent : public SGReferenced { private: - std::vector output_list; + PropertyList output_list; SGSharedPtr _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 ::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 ::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 +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 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 #include
+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 childNodes = base->getChildren(childname); + PropertyList childNodes = base->getChildren(childname); for (int k = (int)childNodes.size() - 1; k >= 0; k--) { SGPropertyNode *n = childNodes[k]; - vector 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 #include +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 settingNodes = node->getChildren("setting"); - for( vector::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 eventNodes = deviceNode->getChildren( "event" ); - for( vector::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
#include +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 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 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 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 #include +using simgear::PropertyList; + static int getModifiers () { return fgGetKeyModifiers() >> 1; @@ -94,13 +96,13 @@ void FGKeyboardInput::postinit() } FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal"); - vector 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 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 axes = templatetree->getChildren("axis"); - for(vector::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 buttons = templatetree->getChildren("button"); - for(vector::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 ); From 3e4a592282543cb25c6babffb9aa70d46f44e055 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Mon, 19 Apr 2010 12:22:30 +0200 Subject: [PATCH 2/2] Move using declaration out of header file --- src/Autopilot/xmlauto.cxx | 2 ++ src/Autopilot/xmlauto.hxx | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Autopilot/xmlauto.cxx b/src/Autopilot/xmlauto.cxx index 1c1498d5c..fe51f37b1 100644 --- a/src/Autopilot/xmlauto.cxx +++ b/src/Autopilot/xmlauto.cxx @@ -40,6 +40,8 @@ using std::cout; using std::endl; +using simgear::PropertyList; + FGPeriodicalValue::FGPeriodicalValue( SGPropertyNode_ptr root ) { SGPropertyNode_ptr minNode = root->getChild( "min" ); diff --git a/src/Autopilot/xmlauto.hxx b/src/Autopilot/xmlauto.hxx index 45a90d56b..a29d49e23 100644 --- a/src/Autopilot/xmlauto.hxx +++ b/src/Autopilot/xmlauto.hxx @@ -49,8 +49,6 @@ and writes properties used only by a few aircraft. #include #include -using simgear::PropertyList; - typedef SGSharedPtr FGXMLAutoInput_ptr; typedef SGSharedPtr FGPeriodicalValue_ptr; @@ -124,7 +122,7 @@ class FGXMLAutoInputList : public std::vector { class FGXMLAutoComponent : public SGReferenced { private: - PropertyList output_list; + simgear::PropertyList output_list; SGSharedPtr _condition; SGPropertyNode_ptr enable_prop; @@ -203,7 +201,8 @@ public: // helpful for things like flight directors which position // their vbars from the autopilot computations. if ( honor_passive && passive_mode->getBoolValue() ) return; - for( PropertyList::iterator it = output_list.begin(); it != output_list.end(); ++it) + for( simgear::PropertyList::iterator it = output_list.begin(); + it != output_list.end(); ++it) (*it)->setDoubleValue( clamp( value ) ); } @@ -214,7 +213,8 @@ public: // helpful for things like flight directors which position // their vbars from the autopilot computations. if ( honor_passive && passive_mode->getBoolValue() ) return; - for( PropertyList::iterator it = output_list.begin(); it != output_list.end(); ++it) + for( simgear::PropertyList::iterator it = output_list.begin(); + it != output_list.end(); ++it) (*it)->setBoolValue( value ); // don't use clamp here, bool is clamped anyway }