* $Id$
*/
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
+
+#include <boost/foreach.hpp>
#include <simgear/compiler.h>
#include "SGBinding.hxx"
+#include <simgear/structure/exception.hxx>
+
SGBinding::SGBinding()
: _command(0),
_arg(new SGPropertyNode),
{
}
+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),
_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() << ")");
+ }
}
}
}
fire();
}
}
+
+void fireBindingList(const SGBindingList& aBindings)
+{
+ BOOST_FOREACH(SGBinding_ptr b, aBindings) {
+ b->fire();
+ }
+}