Skip to content

Commit

Permalink
Use std::bind and scoped using statement
Browse files Browse the repository at this point in the history
boost::bind changed its syntax for the placeholders,
so just switch to std::bind and add a scoped
using namespace std::placeholders to reduce
the size of the diff.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed Aug 8, 2020
1 parent 16f1581 commit 5d3d06e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
37 changes: 20 additions & 17 deletions gazebo/gui/model/ModelTreeWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*
*/

#include <functional>

#include "gazebo/common/Events.hh"

#include "gazebo/gui/GuiEvents.hh"
#include "gazebo/gui/model/ModelEditorEvents.hh"
#include "gazebo/gui/model/ModelPluginInspector.hh"
#include "gazebo/gui/model/ModelTreeWidget.hh"

using namespace boost::placeholders;
using namespace gazebo;
using namespace gui;

Expand Down Expand Up @@ -161,21 +162,23 @@ ModelTreeWidget::ModelTreeWidget(QWidget *_parent)
this->layout()->setContentsMargins(0, 0, 0, 0);

// Connections
using namespace std::placeholders;

this->connections.push_back(
gui::model::Events::ConnectSaveModel(
boost::bind(&ModelTreeWidget::OnSaveModel, this, _1)));
std::bind(&ModelTreeWidget::OnSaveModel, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectNewModel(
boost::bind(&ModelTreeWidget::OnNewModel, this)));
std::bind(&ModelTreeWidget::OnNewModel, this)));

this->connections.push_back(
gui::model::Events::ConnectModelPropertiesChanged(
boost::bind(&ModelTreeWidget::OnModelPropertiesChanged, this, _1, _2)));
std::bind(&ModelTreeWidget::OnModelPropertiesChanged, this, _1, _2)));

this->connections.push_back(
gui::model::Events::ConnectModelNameChanged(
boost::bind(&ModelTreeWidget::OnModelNameChanged, this, _1)));
std::bind(&ModelTreeWidget::OnModelNameChanged, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectNestedModelInserted(
Expand All @@ -184,51 +187,51 @@ ModelTreeWidget::ModelTreeWidget(QWidget *_parent)

this->connections.push_back(
gui::model::Events::ConnectLinkInserted(
boost::bind(&ModelTreeWidget::OnLinkInserted, this, _1)));
std::bind(&ModelTreeWidget::OnLinkInserted, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectJointInserted(
boost::bind(&ModelTreeWidget::OnJointInserted, this, _1, _2, _3, _4)));
std::bind(&ModelTreeWidget::OnJointInserted, this, _1, _2, _3, _4)));

this->connections.push_back(
gui::model::Events::ConnectModelPluginInserted(
boost::bind(&ModelTreeWidget::OnModelPluginInserted, this, _1)));
std::bind(&ModelTreeWidget::OnModelPluginInserted, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectNestedModelRemoved(
boost::bind(&ModelTreeWidget::OnNestedModelRemoved, this, _1)));
std::bind(&ModelTreeWidget::OnNestedModelRemoved, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectLinkRemoved(
boost::bind(&ModelTreeWidget::OnLinkRemoved, this, _1)));
std::bind(&ModelTreeWidget::OnLinkRemoved, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectJointRemoved(
boost::bind(&ModelTreeWidget::OnJointRemoved, this, _1)));
std::bind(&ModelTreeWidget::OnJointRemoved, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectModelPluginRemoved(
boost::bind(&ModelTreeWidget::OnModelPluginRemoved, this, _1)));
std::bind(&ModelTreeWidget::OnModelPluginRemoved, this, _1)));

this->connections.push_back(
gui::model::Events::ConnectJointNameChanged(
boost::bind(&ModelTreeWidget::OnJointNameChanged, this, _1, _2)));
std::bind(&ModelTreeWidget::OnJointNameChanged, this, _1, _2)));

this->connections.push_back(
event::Events::ConnectSetSelectedEntity(
boost::bind(&ModelTreeWidget::OnDeselectAll, this, _1, _2)));
std::bind(&ModelTreeWidget::OnDeselectAll, this, _1, _2)));

this->connections.push_back(
gui::model::Events::ConnectSetSelectedEntity(
boost::bind(&ModelTreeWidget::OnSetSelectedEntity, this, _1, _2)));
std::bind(&ModelTreeWidget::OnSetSelectedEntity, this, _1, _2)));

this->connections.push_back(
gui::model::Events::ConnectSetSelectedJoint(
boost::bind(&ModelTreeWidget::OnSetSelectedJoint, this, _1, _2)));
std::bind(&ModelTreeWidget::OnSetSelectedJoint, this, _1, _2)));

this->connections.push_back(
gui::model::Events::ConnectSetSelectedModelPlugin(
boost::bind(&ModelTreeWidget::OnSetSelectedModelPlugin, this, _1, _2)));
std::bind(&ModelTreeWidget::OnSetSelectedModelPlugin, this, _1, _2)));

this->ClearModelTree();
}
Expand Down
21 changes: 12 additions & 9 deletions gazebo/gui/model/SchematicViewWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

#include <functional>

#include <ignition/math/Color.hh>

#include "gazebo/rendering/Material.hh"
Expand All @@ -30,7 +32,6 @@
#include "gazebo/gui/model/ModelEditorEvents.hh"
#include "gazebo/gui/model/SchematicViewWidget.hh"

using namespace boost::placeholders;
using namespace gazebo;
using namespace gui;

Expand Down Expand Up @@ -83,32 +84,34 @@ void SchematicViewWidget::Reset()
/////////////////////////////////////////////////
void SchematicViewWidget::Init()
{
using namespace std::placeholders;

this->connections.push_back(gui::model::Events::ConnectLinkInserted(
boost::bind(&SchematicViewWidget::AddNode, this, _1)));
std::bind(&SchematicViewWidget::AddNode, this, _1)));

this->connections.push_back(gui::model::Events::ConnectLinkRemoved(
boost::bind(&SchematicViewWidget::RemoveNode, this, _1)));
std::bind(&SchematicViewWidget::RemoveNode, this, _1)));

this->connections.push_back(gui::model::Events::ConnectJointInserted(
boost::bind(&SchematicViewWidget::AddEdge, this, _1, _2, _3, _4, _5)));
std::bind(&SchematicViewWidget::AddEdge, this, _1, _2, _3, _4, _5)));

this->connections.push_back(gui::model::Events::ConnectJointRemoved(
boost::bind(&SchematicViewWidget::RemoveEdge, this, _1)));
std::bind(&SchematicViewWidget::RemoveEdge, this, _1)));

this->connections.push_back(gui::model::Events::ConnectJointChanged(
boost::bind(&SchematicViewWidget::UpdateEdge, this, _1, _2, _3, _4, _5)));
std::bind(&SchematicViewWidget::UpdateEdge, this, _1, _2, _3, _4, _5)));

this->connections.push_back(
event::Events::ConnectSetSelectedEntity(
boost::bind(&SchematicViewWidget::OnDeselectAll, this, _1, _2)));
std::bind(&SchematicViewWidget::OnDeselectAll, this, _1, _2)));

this->connections.push_back(
gui::model::Events::ConnectSetSelectedEntity(
boost::bind(&SchematicViewWidget::OnSetSelectedEntity, this, _1, _2)));
std::bind(&SchematicViewWidget::OnSetSelectedEntity, this, _1, _2)));

this->connections.push_back(
gui::model::Events::ConnectSetSelectedJoint(
boost::bind(&SchematicViewWidget::OnSetSelectedJoint, this, _1, _2)));
std::bind(&SchematicViewWidget::OnSetSelectedJoint, this, _1, _2)));
}

/////////////////////////////////////////////////
Expand Down
7 changes: 5 additions & 2 deletions test/plugins/ForceTorqueModelRemovalTestPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*
*/

#include <functional>

#include "plugins/ForceTorqueModelRemovalTestPlugin.hh"

#include "gazebo/sensors/ForceTorqueSensor.hh"

using namespace boost::placeholders;

using namespace gazebo;

GZ_REGISTER_SENSOR_PLUGIN(ForceTorqueModelRemovalTestPlugin)
Expand Down Expand Up @@ -53,7 +55,8 @@ void ForceTorqueModelRemovalTestPlugin::Load(sensors::SensorPtr _sensor,

// Create connection
this->updateConnection = gazebo::event::Events::ConnectWorldUpdateBegin(
boost::bind(&ForceTorqueModelRemovalTestPlugin::onUpdate, this, _1));
std::bind(&ForceTorqueModelRemovalTestPlugin::onUpdate, this,
std::placeholders::_1));
}

void ForceTorqueModelRemovalTestPlugin::onUpdate(
Expand Down

0 comments on commit 5d3d06e

Please sign in to comment.