From 721aa544c9400693ea6b59a5c9ad8e44a8a376e2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 26 Sep 2017 16:39:04 +0200 Subject: [PATCH] Use C++11 in the state-machine code --- simgear/structure/StateMachine.cxx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/simgear/structure/StateMachine.cxx b/simgear/structure/StateMachine.cxx index 178b9c61..2bff0f3f 100644 --- a/simgear/structure/StateMachine.cxx +++ b/simgear/structure/StateMachine.cxx @@ -19,16 +19,13 @@ * */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include "StateMachine.hxx" #include #include #include -#include #include #include @@ -44,7 +41,7 @@ typedef std::vector StatePtrVec; static void readBindingList(SGPropertyNode* desc, const std::string& name, SGPropertyNode* root, SGBindingList& result) { - BOOST_FOREACH(SGPropertyNode* b, desc->getChildren(name)) { + for (auto b : desc->getChildren(name)) { SGBinding* bind = new SGBinding; bind->read(b, root); result.push_back(bind); @@ -85,7 +82,7 @@ public: void computeEligibleTransitions() { _eligible.clear(); - BOOST_FOREACH(Transition_ptr t, _transitions) { + for (Transition_ptr t : _transitions) { if (t->applicableForState(_currentState)) { _eligible.push_back(t.ptr()); } @@ -358,7 +355,7 @@ void StateMachine::update(double aDt) Transition_ptr trigger; - BOOST_FOREACH(Transition* trans, d->_eligible) { + for (auto trans : d->_eligible) { if (trans->evaluate()) { if (trigger != Transition_ptr()) { SG_LOG(SG_GENERAL, SG_WARN, "ambiguous transitions! " @@ -379,7 +376,7 @@ void StateMachine::update(double aDt) StateMachine::State_ptr StateMachine::findStateByName(const std::string& aName) const { - BOOST_FOREACH(State_ptr sp, d->_states) { + for (auto sp : d->_states) { if (sp->name() == aName) { return sp; } @@ -435,7 +432,7 @@ void StateMachine::initFromPlist(SGPropertyNode* desc, SGPropertyNode* root) assert(d->_root); } - BOOST_FOREACH(SGPropertyNode* stateDesc, desc->getChildren("state")) { + for (auto stateDesc : desc->getChildren("state")) { std::string nm = stateDesc->getStringValue("name"); State_ptr st(new State(nm)); @@ -446,7 +443,7 @@ void StateMachine::initFromPlist(SGPropertyNode* desc, SGPropertyNode* root) addState(st); } // of states iteration - BOOST_FOREACH(SGPropertyNode* tDesc, desc->getChildren("transition")) { + for (auto tDesc : desc->getChildren("transition")) { std::string nm = tDesc->getStringValue("name"); State_ptr target = findStateByName(tDesc->getStringValue("target")); @@ -456,7 +453,7 @@ void StateMachine::initFromPlist(SGPropertyNode* desc, SGPropertyNode* root) t->setTriggerCondition(cond); t->setExcludeTarget(tDesc->getBoolValue("exclude-target", true)); - BOOST_FOREACH(SGPropertyNode* src, tDesc->getChildren("source")) { + for (auto src : tDesc->getChildren("source")) { State_ptr srcState = findStateByName(src->getStringValue()); t->addSourceState(srcState); }