X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGBinding.cxx;h=db501d4073de354b7740d07497a67edb2c25a3b3;hb=691be54ca2b4d76f2e32f165c2513727c32a4de7;hp=e65b4d2a8bf584a3928f9f06bd1605e7b1f8e17b;hpb=3e023b77dde9526d7efe8af00fa57c2143893983;p=simgear.git diff --git a/simgear/structure/SGBinding.cxx b/simgear/structure/SGBinding.cxx index e65b4d2a..db501d40 100644 --- a/simgear/structure/SGBinding.cxx +++ b/simgear/structure/SGBinding.cxx @@ -7,9 +7,16 @@ * $Id$ */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include #include #include "SGBinding.hxx" +#include + SGBinding::SGBinding() : _command(0), _arg(new SGPropertyNode), @@ -17,6 +24,14 @@ SGBinding::SGBinding() { } +SGBinding::SGBinding(const std::string& commandName) + : _command(0), + _arg(0), + _setting(0) +{ + _command_name = commandName; +} + SGBinding::SGBinding(const SGPropertyNode* node, SGPropertyNode* root) : _command(0), _arg(0), @@ -56,9 +71,17 @@ SGBinding::fire () const _command = SGCommandMgr::instance()->getCommand(_command_name); if (_command == 0) { SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding"); - } else if (!(*_command)(_arg)) { - SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command " - << _command_name); + } else + { + try { + if (!(*_command)(_arg)) { + SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command " + << _command_name); + } + } catch (sg_exception& e) { + SG_LOG(SG_GENERAL, SG_ALERT, "command '" << _command_name << "' failed with exception\n" + << "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")"); + } } } } @@ -84,3 +107,10 @@ SGBinding::fire (double setting) const fire(); } } + +void fireBindingList(const SGBindingList& aBindings) +{ + BOOST_FOREACH(SGBinding_ptr b, aBindings) { + b->fire(); + } +}