diff --git a/src/MainWindow.cc b/src/MainWindow.cc index df1e0fe5f..ad075b466 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -85,7 +85,7 @@ class MainWindow::Implementation public: std::string controlService{"/server_control"}; /// \brief Communication node - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; }; ///////////////////////////////////////////////// diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index 1feea96b6..973d043c5 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -70,7 +70,7 @@ class Topic::Implementation class Transport::Implementation { /// \brief Node for Commincation - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; /// \brief subscribed topics public: std::map topics; diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/camera_tracking/CameraTracking.cc index 55471d633..6f514edd6 100644 --- a/src/plugins/camera_tracking/CameraTracking.cc +++ b/src/plugins/camera_tracking/CameraTracking.cc @@ -160,7 +160,7 @@ class CameraTracking::Implementation }; ///////////////////////////////////////////////// -void CameraTrackingPrivate::Initialize() +void CameraTracking::Implementation::Initialize() { // Attach to the first camera we find for (unsigned int i = 0; i < scene->NodeCount(); ++i) @@ -170,7 +170,7 @@ void CameraTrackingPrivate::Initialize() if (cam) { this->camera = cam; - gzdbg << "CameraTrackingPrivate plugin is moving camera [" + gzdbg << "CameraTracking plugin is moving camera [" << this->camera->Name() << "]" << std::endl; break; } @@ -184,14 +184,14 @@ void CameraTrackingPrivate::Initialize() // move to this->moveToService = "/gui/move_to"; this->node.Advertise(this->moveToService, - &CameraTrackingPrivate::OnMoveTo, this); + &Implementation::OnMoveTo, this); gzmsg << "Move to service on [" << this->moveToService << "]" << std::endl; // follow this->followService = "/gui/follow"; this->node.Advertise(this->followService, - &CameraTrackingPrivate::OnFollow, this); + &Implementation::OnFollow, this); gzmsg << "Follow service on [" << this->followService << "]" << std::endl; @@ -199,7 +199,7 @@ void CameraTrackingPrivate::Initialize() this->moveToPoseService = "/gui/move_to/pose"; this->node.Advertise(this->moveToPoseService, - &CameraTrackingPrivate::OnMoveToPose, this); + &Implementation::OnMoveToPose, this); gzmsg << "Move to pose service on [" << this->moveToPoseService << "]" << std::endl; @@ -210,16 +210,16 @@ void CameraTrackingPrivate::Initialize() gzmsg << "Camera pose topic advertised on [" << this->cameraPoseTopic << "]" << std::endl; - // follow offset - this->followOffsetService = "/gui/follow/offset"; - this->node.Advertise(this->followOffsetService, - &CameraTrackingPrivate::OnFollowOffset, this); - gzmsg << "Follow offset service on [" - << this->followOffsetService << "]" << std::endl; + // follow offset + this->followOffsetService = "/gui/follow/offset"; + this->node.Advertise(this->followOffsetService, + &Implementation::OnFollowOffset, this); + gzmsg << "Follow offset service on [" + << this->followOffsetService << "]" << std::endl; } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnMoveTo(const msgs::StringMsg &_msg, +bool CameraTracking::Implementation::OnMoveTo(const msgs::StringMsg &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -230,7 +230,7 @@ bool CameraTrackingPrivate::OnMoveTo(const msgs::StringMsg &_msg, } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnFollow(const msgs::StringMsg &_msg, +bool CameraTracking::Implementation::OnFollow(const msgs::StringMsg &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -241,19 +241,19 @@ bool CameraTrackingPrivate::OnFollow(const msgs::StringMsg &_msg, } ///////////////////////////////////////////////// -void CameraTrackingPrivate::OnMoveToComplete() +void CameraTracking::Implementation::OnMoveToComplete() { this->moveToTarget.clear(); } ///////////////////////////////////////////////// -void CameraTrackingPrivate::OnMoveToPoseComplete() +void CameraTracking::Implementation::OnMoveToPoseComplete() { this->moveToPoseValue.reset(); } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnFollowOffset(const msgs::Vector3d &_msg, +bool CameraTracking::Implementation::OnFollowOffset(const msgs::Vector3d &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -268,7 +268,7 @@ bool CameraTrackingPrivate::OnFollowOffset(const msgs::Vector3d &_msg, } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnMoveToPose(const msgs::GUICamera &_msg, +bool CameraTracking::Implementation::OnMoveToPose(const msgs::GUICamera &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -295,7 +295,7 @@ bool CameraTrackingPrivate::OnMoveToPose(const msgs::GUICamera &_msg, } ///////////////////////////////////////////////// -void CameraTrackingPrivate::OnRender() +void CameraTracking::Implementation::OnRender() { std::lock_guard lock(this->mutex); @@ -313,7 +313,7 @@ void CameraTrackingPrivate::OnRender() // Move To { - GZ_PROFILE("CameraTrackingPrivate::OnRender MoveTo"); + GZ_PROFILE("CameraTracking::Implementation::OnRender MoveTo"); if (!this->moveToTarget.empty()) { if (this->moveToHelper.Idle()) @@ -323,7 +323,7 @@ void CameraTrackingPrivate::OnRender() if (target) { this->moveToHelper.MoveTo(this->camera, target, 0.5, - std::bind(&CameraTrackingPrivate::OnMoveToComplete, this)); + std::bind(&Implementation::OnMoveToComplete, this)); this->prevMoveToTime = std::chrono::system_clock::now(); } else @@ -345,14 +345,14 @@ void CameraTrackingPrivate::OnRender() // Move to pose { - GZ_PROFILE("CameraTrackingPrivate::OnRender MoveToPose"); + GZ_PROFILE("CameraTracking::Implementation::OnRender MoveToPose"); if (this->moveToPoseValue) { if (this->moveToHelper.Idle()) { this->moveToHelper.MoveTo(this->camera, *(this->moveToPoseValue), - 0.5, std::bind(&CameraTrackingPrivate::OnMoveToPoseComplete, this)); + 0.5, std::bind(&Implementation::OnMoveToPoseComplete, this)); this->prevMoveToTime = std::chrono::system_clock::now(); } else @@ -367,7 +367,7 @@ void CameraTrackingPrivate::OnRender() // Follow { - GZ_PROFILE("CameraTrackingPrivate::OnRender Follow"); + GZ_PROFILE("CameraTracking::Implementation::OnRender Follow"); // reset follow mode if target node got removed if (!this->followTarget.empty()) { diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/grid_config/GridConfig.cc index df934358a..402119a05 100644 --- a/src/plugins/grid_config/GridConfig.cc +++ b/src/plugins/grid_config/GridConfig.cc @@ -52,7 +52,7 @@ struct GridParam math::Color color{math::Color(0.7f, 0.7f, 0.7f, 1.0f)}; }; -class GridConfigPrivate +class GridConfig::Implementation { /// \brief List of grid names. public: QStringList nameList; @@ -84,7 +84,7 @@ class GridConfigPrivate ///////////////////////////////////////////////// GridConfig::GridConfig() - : gz::gui::Plugin(), dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/grid_config/GridConfig.hh b/src/plugins/grid_config/GridConfig.hh index 7d7d84de6..54ee01c3d 100644 --- a/src/plugins/grid_config/GridConfig.hh +++ b/src/plugins/grid_config/GridConfig.hh @@ -22,6 +22,8 @@ #include +#include + namespace gz::gui::plugins { class GridConfigPrivate; @@ -139,7 +141,7 @@ class GridConfig : public gz::gui::Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_GRIDCONFIG_HH_ diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/image_display/ImageDisplay.cc index b2fc2095b..85c648d23 100644 --- a/src/plugins/image_display/ImageDisplay.cc +++ b/src/plugins/image_display/ImageDisplay.cc @@ -35,7 +35,7 @@ namespace gz::gui::plugins { -class ImageDisplayPrivate +class ImageDisplay::Implementation { /// \brief List of topics publishing image messages. public: QStringList topicList; @@ -55,7 +55,7 @@ class ImageDisplayPrivate ///////////////////////////////////////////////// ImageDisplay::ImageDisplay() - : Plugin(), dataPtr(new ImageDisplayPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/image_display/ImageDisplay.hh b/src/plugins/image_display/ImageDisplay.hh index f142af7d5..ddacb30a4 100644 --- a/src/plugins/image_display/ImageDisplay.hh +++ b/src/plugins/image_display/ImageDisplay.hh @@ -36,10 +36,10 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { -class ImageDisplayPrivate; - class ImageProvider : public QQuickImageProvider { public: ImageProvider() @@ -130,7 +130,7 @@ class ImageDisplay_EXPORTS_API ImageDisplay : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_ diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.cc b/src/plugins/interactive_view_control/InteractiveViewControl.cc index e5e6d49ac..916722dbb 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.cc +++ b/src/plugins/interactive_view_control/InteractiveViewControl.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -46,7 +47,7 @@ namespace gz::gui::plugins { /// \brief Private data class for InteractiveViewControl -class InteractiveViewControlPrivate +class InteractiveViewControl::Implementation { /// \brief Perform rendering calls in the rendering thread. public: void OnRender(); @@ -147,7 +148,7 @@ class InteractiveViewControlPrivate }; ///////////////////////////////////////////////// -void InteractiveViewControlPrivate::OnRender() +void InteractiveViewControl::Implementation::OnRender() { if (!this->scene) { @@ -315,7 +316,7 @@ void InteractiveViewControlPrivate::OnRender() } ///////////////////////////////////////////////// -void InteractiveViewControlPrivate::UpdateReferenceVisual() +void InteractiveViewControl::Implementation::UpdateReferenceVisual() { if (!this->refVisual || !this->enableRefVisual) return; @@ -331,8 +332,8 @@ void InteractiveViewControlPrivate::UpdateReferenceVisual() } ///////////////////////////////////////////////// -bool InteractiveViewControlPrivate::OnViewControl(const msgs::StringMsg &_msg, - msgs::Boolean &_res) +bool InteractiveViewControl::Implementation::OnViewControl( + const msgs::StringMsg &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -355,8 +356,8 @@ bool InteractiveViewControlPrivate::OnViewControl(const msgs::StringMsg &_msg, } ///////////////////////////////////////////////// -bool InteractiveViewControlPrivate::OnReferenceVisual(const msgs::Boolean &_msg, - msgs::Boolean &_res) +bool InteractiveViewControl::Implementation::OnReferenceVisual( + const msgs::Boolean &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); this->enableRefVisual = _msg.data(); @@ -366,7 +367,7 @@ bool InteractiveViewControlPrivate::OnReferenceVisual(const msgs::Boolean &_msg, } ///////////////////////////////////////////////// -bool InteractiveViewControlPrivate::OnViewControlSensitivity( +bool InteractiveViewControl::Implementation::OnViewControlSensitivity( const msgs::Double &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -387,7 +388,7 @@ bool InteractiveViewControlPrivate::OnViewControlSensitivity( ///////////////////////////////////////////////// InteractiveViewControl::InteractiveViewControl() - : Plugin(), dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -404,7 +405,7 @@ void InteractiveViewControl::LoadConfig( // camera view control mode this->dataPtr->cameraViewControlService = "/gui/camera/view_control"; this->dataPtr->node.Advertise(this->dataPtr->cameraViewControlService, - &InteractiveViewControlPrivate::OnViewControl, this->dataPtr.get()); + &Implementation::OnViewControl, this->dataPtr.get()); gzmsg << "Camera view controller topic advertised on [" << this->dataPtr->cameraViewControlService << "]" << std::endl; @@ -412,7 +413,7 @@ void InteractiveViewControl::LoadConfig( this->dataPtr->cameraRefVisualService = "/gui/camera/view_control/reference_visual"; this->dataPtr->node.Advertise(this->dataPtr->cameraRefVisualService, - &InteractiveViewControlPrivate::OnReferenceVisual, this->dataPtr.get()); + &Implementation::OnReferenceVisual, this->dataPtr.get()); gzmsg << "Camera reference visual topic advertised on [" << this->dataPtr->cameraRefVisualService << "]" << std::endl; @@ -421,7 +422,7 @@ void InteractiveViewControl::LoadConfig( "/gui/camera/view_control/sensitivity"; this->dataPtr->node.Advertise( this->dataPtr->cameraViewControlSensitivityService, - &InteractiveViewControlPrivate::OnViewControlSensitivity, + &Implementation::OnViewControlSensitivity, this->dataPtr.get()); gzmsg << "Camera view control sensitivity advertised on [" << this->dataPtr->cameraViewControlSensitivityService << "]" @@ -501,7 +502,6 @@ bool InteractiveViewControl::eventFilter(QObject *_obj, QEvent *_event) return QObject::eventFilter(_obj, _event); } } // namespace gz::gui::plugins - // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::InteractiveViewControl, gz::gui::Plugin) diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.hh b/src/plugins/interactive_view_control/InteractiveViewControl.hh index 74583788a..e6cb1f0aa 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.hh +++ b/src/plugins/interactive_view_control/InteractiveViewControl.hh @@ -22,6 +22,8 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { class InteractiveViewControlPrivate; @@ -64,7 +66,7 @@ class InteractiveViewControl : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_INTERACTIVEVIEWCONTROL_HH_ diff --git a/src/plugins/key_publisher/KeyPublisher.cc b/src/plugins/key_publisher/KeyPublisher.cc index 1cec6767d..0a3eac2be 100644 --- a/src/plugins/key_publisher/KeyPublisher.cc +++ b/src/plugins/key_publisher/KeyPublisher.cc @@ -17,6 +17,7 @@ #include +#include #include #include @@ -27,7 +28,7 @@ namespace gz::gui::plugins { -class KeyPublisherPrivate +class KeyPublisher::Implementation { /// \brief Node for communication public: gz::transport::Node node; @@ -49,7 +50,8 @@ class KeyPublisherPrivate }; ///////////////////////////////////////////////// -KeyPublisher::KeyPublisher(): Plugin(), dataPtr(new KeyPublisherPrivate) +KeyPublisher::KeyPublisher(): + dataPtr(gz::utils::MakeUniqueImpl()) { // Advertise publisher node this->dataPtr->pub = this->dataPtr->node.Advertise @@ -57,9 +59,7 @@ KeyPublisher::KeyPublisher(): Plugin(), dataPtr(new KeyPublisherPrivate) } ///////////////////////////////////////////////// -KeyPublisher::~KeyPublisher() -{ -} +KeyPublisher::~KeyPublisher() = default; ///////////////////////////////////////////////// void KeyPublisher::LoadConfig(const tinyxml2::XMLElement *) @@ -82,7 +82,6 @@ bool KeyPublisher::eventFilter(QObject *_obj, QEvent *_event) return QObject::eventFilter(_obj, _event); } } // namespace gz::gui::plugins - // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::KeyPublisher, gz::gui::Plugin) diff --git a/src/plugins/key_publisher/KeyPublisher.hh b/src/plugins/key_publisher/KeyPublisher.hh index eba98e616..24e46a5bc 100644 --- a/src/plugins/key_publisher/KeyPublisher.hh +++ b/src/plugins/key_publisher/KeyPublisher.hh @@ -33,12 +33,11 @@ #include #include +#include #include namespace gz::gui::plugins { - class KeyPublisherPrivate; - /// \brief Publish keyboard stokes to "keyboard/keypress" topic. /// /// ## Configuration @@ -64,7 +63,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_KEYPUBLISHER_HH_ diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/marker_manager/MarkerManager.cc index 4c9e5c44d..811e86435 100644 --- a/src/plugins/marker_manager/MarkerManager.cc +++ b/src/plugins/marker_manager/MarkerManager.cc @@ -52,7 +52,7 @@ namespace gz::gui::plugins { /// \brief Private data class for MarkerManager -class MarkerManagerPrivate +class MarkerManager::Implementation { /// \brief Update markers based on msgs received public: void OnRender(); @@ -123,7 +123,7 @@ class MarkerManagerPrivate std::map> visuals; /// \brief Gazebo node - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; /// \brief Topic name for the marker service public: std::string topicName = "/marker"; @@ -143,7 +143,7 @@ class MarkerManagerPrivate }; ///////////////////////////////////////////////// -void MarkerManagerPrivate::Initialize() +void MarkerManager::Implementation::Initialize() { if (!this->scene) { @@ -160,7 +160,7 @@ void MarkerManagerPrivate::Initialize() // Advertise the list service if (!this->node.Advertise(this->topicName + "/list", - &MarkerManagerPrivate::OnList, this)) + &Implementation::OnList, this)) { gzerr << "Unable to advertise to the " << this->topicName << "/list service.\n"; @@ -170,7 +170,7 @@ void MarkerManagerPrivate::Initialize() // Advertise to the marker service if (!this->node.Advertise(this->topicName, - &MarkerManagerPrivate::OnMarkerMsg, this)) + &Implementation::OnMarkerMsg, this)) { gzerr << "Unable to advertise to the " << this->topicName << " service.\n"; @@ -180,7 +180,7 @@ void MarkerManagerPrivate::Initialize() // Advertise to the marker_array service if (!this->node.Advertise(this->topicName + "_array", - &MarkerManagerPrivate::OnMarkerMsgArray, this)) + &Implementation::OnMarkerMsgArray, this)) { gzerr << "Unable to advertise to the " << this->topicName << "_array service.\n"; @@ -190,7 +190,7 @@ void MarkerManagerPrivate::Initialize() } ///////////////////////////////////////////////// -void MarkerManagerPrivate::OnRender() +void MarkerManager::Implementation::OnRender() { if (!this->scene) { @@ -246,7 +246,7 @@ void MarkerManagerPrivate::OnRender() } ///////////////////////////////////////////////// -bool MarkerManagerPrivate::OnList(gz::msgs::Marker_V &_rep) +bool MarkerManager::Implementation::OnList(gz::msgs::Marker_V &_rep) { std::lock_guard lock(this->mutex); _rep.clear_marker(); @@ -266,14 +266,14 @@ bool MarkerManagerPrivate::OnList(gz::msgs::Marker_V &_rep) } ///////////////////////////////////////////////// -void MarkerManagerPrivate::OnMarkerMsg(const gz::msgs::Marker &_req) +void MarkerManager::Implementation::OnMarkerMsg(const gz::msgs::Marker &_req) { std::lock_guard lock(this->mutex); this->markerMsgs.push_back(_req); } ///////////////////////////////////////////////// -bool MarkerManagerPrivate::OnMarkerMsgArray( +bool MarkerManager::Implementation::OnMarkerMsgArray( const gz::msgs::Marker_V&_req, gz::msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -284,7 +284,7 @@ bool MarkerManagerPrivate::OnMarkerMsgArray( } ////////////////////////////////////////////////// -bool MarkerManagerPrivate::ProcessMarkerMsg(const gz::msgs::Marker &_msg) +bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_msg) { // Get the namespace, if it exists. Otherwise, use the global namespace std::string ns; @@ -450,7 +450,7 @@ bool MarkerManagerPrivate::ProcessMarkerMsg(const gz::msgs::Marker &_msg) } ///////////////////////////////////////////////// -void MarkerManagerPrivate::SetVisual(const gz::msgs::Marker &_msg, +void MarkerManager::Implementation::SetVisual(const gz::msgs::Marker &_msg, const rendering::VisualPtr &_visualPtr) { // Set Visual Scale @@ -500,7 +500,7 @@ void MarkerManagerPrivate::SetVisual(const gz::msgs::Marker &_msg, } ///////////////////////////////////////////////// -void MarkerManagerPrivate::SetMarker(const gz::msgs::Marker &_msg, +void MarkerManager::Implementation::SetMarker(const gz::msgs::Marker &_msg, const rendering::MarkerPtr &_markerPtr) { _markerPtr->SetLayer(_msg.layer()); @@ -560,8 +560,8 @@ void MarkerManagerPrivate::SetMarker(const gz::msgs::Marker &_msg, } ///////////////////////////////////////////////// -rendering::MaterialPtr MarkerManagerPrivate::MsgToMaterial( - const gz::msgs::Marker &_msg) +rendering::MaterialPtr +MarkerManager::Implementation::MsgToMaterial(const gz::msgs::Marker &_msg) { rendering::MaterialPtr material = this->scene->CreateMaterial(); @@ -595,8 +595,8 @@ rendering::MaterialPtr MarkerManagerPrivate::MsgToMaterial( } ///////////////////////////////////////////////// -gz::rendering::MarkerType MarkerManagerPrivate::MsgToType( - const gz::msgs::Marker &_msg) +gz::rendering::MarkerType +MarkerManager::Implementation::MsgToType(const gz::msgs::Marker &_msg) { gz::msgs::Marker_Type marker = this->msg.type(); if (marker != _msg.type() && _msg.type() != gz::msgs::Marker::NONE) @@ -636,7 +636,7 @@ gz::rendering::MarkerType MarkerManagerPrivate::MsgToType( } ///////////////////////////////////////////////// -void MarkerManagerPrivate::OnWorldStatsMsg( +void MarkerManager::Implementation::OnWorldStatsMsg( const gz::msgs::WorldStatistics &_msg) { std::lock_guard lock(this->mutex); @@ -659,14 +659,12 @@ void MarkerManagerPrivate::OnWorldStatsMsg( ///////////////////////////////////////////////// MarkerManager::MarkerManager() - : Plugin(), dataPtr(new MarkerManagerPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } ///////////////////////////////////////////////// -MarkerManager::~MarkerManager() -{ -} +MarkerManager::~MarkerManager() = default; ///////////////////////////////////////////////// void MarkerManager::LoadConfig(const tinyxml2::XMLElement * _pluginElem) @@ -742,7 +740,7 @@ void MarkerManager::LoadConfig(const tinyxml2::XMLElement * _pluginElem) { // Subscribe to world_stats if (!this->dataPtr->node.Subscribe(statsTopic, - &MarkerManagerPrivate::OnWorldStatsMsg, this->dataPtr.get())) + &Implementation::OnWorldStatsMsg, this->dataPtr.get())) { gzerr << "Failed to subscribe to [" << statsTopic << "]" << std::endl; } diff --git a/src/plugins/marker_manager/MarkerManager.hh b/src/plugins/marker_manager/MarkerManager.hh index d5eb5f49e..c0fe1ba02 100644 --- a/src/plugins/marker_manager/MarkerManager.hh +++ b/src/plugins/marker_manager/MarkerManager.hh @@ -18,14 +18,13 @@ #ifndef GZ_GUI_PLUGINS_MARKERMANAGER_HH_ #define GZ_GUI_PLUGINS_MARKERMANAGER_HH_ +#include #include #include "gz/gui/Plugin.hh" namespace gz::gui::plugins { -class MarkerManagerPrivate; - /// \brief This plugin will be in charge of handling the markers in the /// scene. It will allow to add, modify or remove markers. /// @@ -56,7 +55,7 @@ class MarkerManager : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_MARKERMANAGER_HH_ diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/navsat_map/NavSatMap.cc index b97fc468d..86333c373 100644 --- a/src/plugins/navsat_map/NavSatMap.cc +++ b/src/plugins/navsat_map/NavSatMap.cc @@ -31,7 +31,7 @@ namespace gz::gui::plugins { -class NavSatMapPrivate +class NavSatMap::Implementation { /// \brief List of topics publishing navSat messages. public: QStringList topicList; @@ -48,14 +48,12 @@ class NavSatMapPrivate ///////////////////////////////////////////////// NavSatMap::NavSatMap() - : Plugin(), dataPtr(new NavSatMapPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } ///////////////////////////////////////////////// -NavSatMap::~NavSatMap() -{ -} +NavSatMap::~NavSatMap() = default; ///////////////////////////////////////////////// void NavSatMap::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -80,7 +78,7 @@ void NavSatMap::LoadConfig(const tinyxml2::XMLElement *_pluginElem) if (topic.empty() && !topicPicker) { gzwarn << "Can't hide topic picker without a default topic." << std::endl; - topicPicker = true; + topicPicker = true; } this->PluginItem()->setProperty("showPicker", topicPicker); diff --git a/src/plugins/navsat_map/NavSatMap.hh b/src/plugins/navsat_map/NavSatMap.hh index 729dd77c6..6006de458 100644 --- a/src/plugins/navsat_map/NavSatMap.hh +++ b/src/plugins/navsat_map/NavSatMap.hh @@ -88,7 +88,7 @@ class NavSatMap : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_ diff --git a/src/plugins/plotting/TransportPlotting.cc b/src/plugins/plotting/TransportPlotting.cc index 7121e33a0..a37808a34 100644 --- a/src/plugins/plotting/TransportPlotting.cc +++ b/src/plugins/plotting/TransportPlotting.cc @@ -15,14 +15,11 @@ * */ #include +#include #include "TransportPlotting.hh" namespace gz::gui::plugins { -TransportPlotting::~TransportPlotting() -{ -} - ////////////////////////////////////////// void TransportPlotting::LoadConfig(const tinyxml2::XMLElement *) { @@ -31,12 +28,12 @@ void TransportPlotting::LoadConfig(const tinyxml2::XMLElement *) } ////////////////////////////////////////// -TransportPlotting::TransportPlotting() : Plugin(), - dataPtr(new PlottingInterface) -{ -} -} // namespace gz::gui::plugins +TransportPlotting::TransportPlotting() = default; + +////////////////////////////////////////// +TransportPlotting::~TransportPlotting() = default; +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::TransportPlotting, gz::gui::Plugin) diff --git a/src/plugins/plotting/TransportPlotting.hh b/src/plugins/plotting/TransportPlotting.hh index 44f7fd69c..2efeed8a5 100644 --- a/src/plugins/plotting/TransportPlotting.hh +++ b/src/plugins/plotting/TransportPlotting.hh @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -35,15 +36,10 @@ class TransportPlotting : public gz::gui::Plugin public: TransportPlotting(); /// \brief Destructor - public: ~TransportPlotting(); + public: ~TransportPlotting() override; // Documentation inherited public: void LoadConfig(const tinyxml2::XMLElement *) override; - - /// \brief Interface with the UI to Handle Transport Plotting - GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_TRANSPORTPLOTTING_HH_ diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/point_cloud/PointCloud.cc index 5a50cfbed..4a7e54129 100644 --- a/src/plugins/point_cloud/PointCloud.cc +++ b/src/plugins/point_cloud/PointCloud.cc @@ -21,6 +21,7 @@ #include "gz/msgs/pointcloud_packed.pb.h" #include +#include #include #include #include @@ -46,7 +47,7 @@ namespace gz::gui::plugins { /// \brief Private data class for PointCloud -class PointCloudPrivate +class PointCloud::Implementation { /// \brief Makes a request to populate the scene with markers public: void PublishMarkers(); @@ -55,7 +56,7 @@ class PointCloudPrivate public: void ClearMarkers(); /// \brief Transport node - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; /// \brief Name of topic for PointCloudPacked public: std::string pointCloudTopic{""}; @@ -99,8 +100,7 @@ class PointCloudPrivate ///////////////////////////////////////////////// PointCloud::PointCloud() - : gz::gui::Plugin(), - dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -354,7 +354,7 @@ void PointCloud::OnFloatVService( } ////////////////////////////////////////////////// -void PointCloudPrivate::PublishMarkers() +void PointCloud::Implementation::PublishMarkers() { GZ_PROFILE("PointCloud::PublishMarkers"); @@ -433,7 +433,7 @@ void PointCloudPrivate::PublishMarkers() } ////////////////////////////////////////////////// -void PointCloudPrivate::ClearMarkers() +void PointCloud::Implementation::ClearMarkers() { if (this->pointCloudTopic.empty()) return; diff --git a/src/plugins/point_cloud/PointCloud.hh b/src/plugins/point_cloud/PointCloud.hh index 616f3fa14..28fcfe8a5 100644 --- a/src/plugins/point_cloud/PointCloud.hh +++ b/src/plugins/point_cloud/PointCloud.hh @@ -25,10 +25,10 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { -class PointCloudPrivate; - /// \brief Visualize `gz::msgs::PointCloudPacked` messages in a 3D /// scene. /// @@ -232,7 +232,7 @@ class PointCloud : public gz::gui::Plugin /// \internal /// \brief Pointer to private data - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_POINTCLOUD_HH_ diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/publisher/Publisher.cc index 670c906bc..cbcf4ce9f 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/publisher/Publisher.cc @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -25,7 +26,7 @@ namespace gz::gui::plugins { -class PublisherPrivate +class Publisher::Implementation { /// \brief Message type public: QString msgType = "gz.msgs.StringMsg"; @@ -51,14 +52,12 @@ class PublisherPrivate ///////////////////////////////////////////////// Publisher::Publisher() - : Plugin(), dataPtr(new PublisherPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } ///////////////////////////////////////////////// -Publisher::~Publisher() -{ -} +Publisher::~Publisher() = default; ///////////////////////////////////////////////// void Publisher::LoadConfig(const tinyxml2::XMLElement *_pluginElem) diff --git a/src/plugins/publisher/Publisher.hh b/src/plugins/publisher/Publisher.hh index e7d81affe..5219f7762 100644 --- a/src/plugins/publisher/Publisher.hh +++ b/src/plugins/publisher/Publisher.hh @@ -21,6 +21,7 @@ #include #include "gz/gui/Plugin.hh" +#include #ifndef _WIN32 # define Publisher_EXPORTS_API @@ -34,7 +35,6 @@ namespace gz::gui::plugins { -class PublisherPrivate; /// \brief Widget which publishes a custom Gazebo Transport message. /// /// ## Configuration @@ -140,7 +140,7 @@ class Publisher_EXPORTS_API Publisher : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_PUBLISHER_HH_ diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/screenshot/Screenshot.cc index 58f62fa1e..a14387516 100644 --- a/src/plugins/screenshot/Screenshot.cc +++ b/src/plugins/screenshot/Screenshot.cc @@ -16,6 +16,7 @@ */ #include "Screenshot.hh" +#include #include #include @@ -34,7 +35,7 @@ namespace gz::gui::plugins { -class ScreenshotPrivate +class Screenshot::Implementation { /// \brief Node for communication public: gz::transport::Node node; @@ -57,8 +58,7 @@ class ScreenshotPrivate ///////////////////////////////////////////////// Screenshot::Screenshot() - : gui::Plugin(), - dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { std::string home; common::env(GZ_HOMEDIR, home); diff --git a/src/plugins/screenshot/Screenshot.hh b/src/plugins/screenshot/Screenshot.hh index c0728dcbf..253b92c31 100644 --- a/src/plugins/screenshot/Screenshot.hh +++ b/src/plugins/screenshot/Screenshot.hh @@ -25,10 +25,10 @@ #include "gz/gui/qt.h" #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { -class ScreenshotPrivate; - /// \brief Provides a button and a transport service for taking a screenshot /// of current 3D scene. /// @@ -117,7 +117,7 @@ signals: void savedScreenshot(); /// \internal /// \brief Pointer to private data. -private: std::unique_ptr dataPtr; +private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_SCREENSHOT_HH_ diff --git a/src/plugins/shutdown_button/ShutdownButton.hh b/src/plugins/shutdown_button/ShutdownButton.hh index 81d25efad..ec66e5c1e 100644 --- a/src/plugins/shutdown_button/ShutdownButton.hh +++ b/src/plugins/shutdown_button/ShutdownButton.hh @@ -41,7 +41,7 @@ class ShutdownButton_EXPORTS_API ShutdownButton: public gz::gui::Plugin public: ShutdownButton(); /// \brief Destructor - public: virtual ~ShutdownButton(); + public: ~ShutdownButton() override; // Documentation inherited public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/tape_measure/TapeMeasure.cc index 2fe70b345..d5d5736d7 100644 --- a/src/plugins/tape_measure/TapeMeasure.cc +++ b/src/plugins/tape_measure/TapeMeasure.cc @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace gz::gui::plugins { -class TapeMeasurePrivate +class TapeMeasure::Implementation { /// \brief Gazebo communication node. public: transport::Node node; @@ -90,8 +91,7 @@ class TapeMeasurePrivate ///////////////////////////////////////////////// TapeMeasure::TapeMeasure() - : gz::gui::Plugin(), - dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/tape_measure/TapeMeasure.hh b/src/plugins/tape_measure/TapeMeasure.hh index ccb4224b0..f60df3d2b 100644 --- a/src/plugins/tape_measure/TapeMeasure.hh +++ b/src/plugins/tape_measure/TapeMeasure.hh @@ -17,6 +17,7 @@ #ifndef GZ_GUI_PLUGINS_TAPEMEASURE_HH_ #define GZ_GUI_PLUGINS_TAPEMEASURE_HH_ +#include #include #include @@ -25,8 +26,6 @@ namespace gz::gui::plugins { -class TapeMeasurePrivate; - /// \brief Provides buttons for the tape measure tool. class TapeMeasure : public gz::gui::Plugin { @@ -95,7 +94,7 @@ class TapeMeasure : public gz::gui::Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_TAPEMEASURE_HH_ diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/teleop/Teleop.cc index e14309c3e..2022cf4ae 100644 --- a/src/plugins/teleop/Teleop.cc +++ b/src/plugins/teleop/Teleop.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -50,7 +51,7 @@ enum class KeyYaw{ namespace gz::gui::plugins { -class TeleopPrivate +class Teleop::Implementation { /// \brief Node for communication. public: gz::transport::Node node; @@ -102,7 +103,7 @@ class TeleopPrivate }; ///////////////////////////////////////////////// -Teleop::Teleop(): Plugin(), dataPtr(std::make_unique()) +Teleop::Teleop(): dataPtr(gz::utils::MakeUniqueImpl()) { // Initialize publisher using default topic. this->dataPtr->cmdVelPub = transport::Node::Publisher(); diff --git a/src/plugins/teleop/Teleop.hh b/src/plugins/teleop/Teleop.hh index 6f4949d38..9633c4c3a 100644 --- a/src/plugins/teleop/Teleop.hh +++ b/src/plugins/teleop/Teleop.hh @@ -20,10 +20,10 @@ #include -#include - #include #include +#include +#include #ifndef _WIN32 # define Teleop_EXPORTS_API @@ -37,8 +37,6 @@ namespace gz::gui::plugins { -class TeleopPrivate; - /// \brief Publish teleop stokes to a user selected topic, /// or to '/cmd_vel' if no topic is selected. /// Buttons, the keyboard or sliders can be used to move a @@ -85,10 +83,10 @@ class Teleop_EXPORTS_API Teleop : public Plugin public: Teleop(); /// \brief Destructor - public: virtual ~Teleop(); + public: ~Teleop() override; // Documentation inherited. - public: virtual void LoadConfig(const tinyxml2::XMLElement *) override; + public: void LoadConfig(const tinyxml2::XMLElement *) override; /// \brief Filters events of type 'keypress' and 'keyrelease'. protected: bool eventFilter(QObject *_obj, QEvent *_event) override; @@ -155,7 +153,7 @@ class Teleop_EXPORTS_API Teleop : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/topic_echo/TopicEcho.cc index 177668293..e91c28478 100644 --- a/src/plugins/topic_echo/TopicEcho.cc +++ b/src/plugins/topic_echo/TopicEcho.cc @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -25,13 +26,13 @@ namespace gz::gui::plugins { -class TopicEchoPrivate +class TopicEcho::Implementation { /// \brief Topic public: QString topic{"/echo"}; /// \brief A list of text data. - public: QStringListModel msgList; + public: QStringListModel msgList {nullptr}; /// \brief Size of the text buffer. The size is the number of /// messages. @@ -49,7 +50,7 @@ class TopicEchoPrivate ///////////////////////////////////////////////// TopicEcho::TopicEcho() - : Plugin(), dataPtr(new TopicEchoPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { // Connect model App()->Engine()->rootContext()->setContextProperty("TopicEchoMsgList", @@ -57,9 +58,7 @@ TopicEcho::TopicEcho() } ///////////////////////////////////////////////// -TopicEcho::~TopicEcho() -{ -} +TopicEcho::~TopicEcho() = default; ///////////////////////////////////////////////// void TopicEcho::LoadConfig(const tinyxml2::XMLElement * /*_pluginElem*/) diff --git a/src/plugins/topic_echo/TopicEcho.hh b/src/plugins/topic_echo/TopicEcho.hh index 1cde9bc08..ab33dd3c1 100644 --- a/src/plugins/topic_echo/TopicEcho.hh +++ b/src/plugins/topic_echo/TopicEcho.hh @@ -40,11 +40,10 @@ #include #include "gz/gui/Plugin.hh" +#include namespace gz::gui::plugins { -class TopicEchoPrivate; - /// \brief Echo messages coming through a Gazebo Transport topic. /// /// ## Configuration @@ -73,10 +72,10 @@ class TopicEcho_EXPORTS_API TopicEcho : public Plugin public: TopicEcho(); /// \brief Destructor - public: virtual ~TopicEcho(); + public: ~TopicEcho() override; // Documentation inherited - public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem); + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; /// \brief Get the topic as a string, for example /// '/echo' @@ -124,7 +123,7 @@ class TopicEcho_EXPORTS_API TopicEcho : public Plugin /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_TOPICECHO_HH_ diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/topic_viewer/TopicViewer.cc index 0d8aef595..0fb36f360 100644 --- a/src/plugins/topic_viewer/TopicViewer.cc +++ b/src/plugins/topic_viewer/TopicViewer.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -34,17 +35,20 @@ #include "TopicViewer.hh" -#define NAME_KEY "name" -#define TYPE_KEY "type" -#define TOPIC_KEY "topic" -#define PATH_KEY "path" -#define PLOT_KEY "plottable" - -#define NAME_ROLE 51 -#define TYPE_ROLE 52 -#define TOPIC_ROLE 53 -#define PATH_ROLE 54 -#define PLOT_ROLE 55 +namespace +{ +constexpr const char * NAME_KEY = "name"; +constexpr const char * TYPE_KEY = "type"; +constexpr const char * TOPIC_KEY = "topic"; +constexpr const char * PATH_KEY = "path"; +constexpr const char * PLOT_KEY = "plottable"; + +constexpr uint8_t NAME_ROLE = 51; +constexpr uint8_t TYPE_ROLE = 52; +constexpr uint8_t TOPIC_ROLE = 53; +constexpr uint8_t PATH_ROLE = 54; +constexpr uint8_t PLOT_ROLE = 55; +} // namespace namespace gz::gui::plugins { @@ -53,26 +57,27 @@ class TopicsModel : public QStandardItemModel /// \brief roles and names of the model public: QHash roleNames() const override { - QHash roles; - roles[NAME_ROLE] = NAME_KEY; - roles[TYPE_ROLE] = TYPE_KEY; - roles[TOPIC_ROLE] = TOPIC_KEY; - roles[PATH_ROLE] = PATH_KEY; - roles[PLOT_ROLE] = PLOT_KEY; - return roles; + return + { + {NAME_ROLE, NAME_KEY}, + {TYPE_ROLE, TYPE_KEY}, + {TOPIC_ROLE, TOPIC_KEY}, + {PATH_ROLE, PATH_KEY}, + {PLOT_ROLE, PLOT_KEY}, + }; } }; -class TopicViewerPrivate +class TopicViewer::Implementation { /// \brief Node for Commincation public: gz::transport::Node node; /// \brief Model to create it from the available topics and messages - public: TopicsModel *model; + public: TopicsModel *model {nullptr}; /// \brief Timer to update the model and keep track of its changes - public: QTimer *timer; + public: QTimer *timer {nullptr}; /// \brief topic: msgType map to keep track of the model current topics public: std::map currentTopics; @@ -136,7 +141,8 @@ class TopicViewerPrivate public: std::vector plotableTypes; }; -TopicViewer::TopicViewer() : Plugin(), dataPtr(new TopicViewerPrivate) +TopicViewer::TopicViewer() + : dataPtr(gz::utils::MakeUniqueImpl()) { using namespace google::protobuf; this->dataPtr->plotableTypes.push_back(FieldDescriptor::Type::TYPE_DOUBLE); @@ -158,9 +164,7 @@ TopicViewer::TopicViewer() : Plugin(), dataPtr(new TopicViewerPrivate) } ////////////////////////////////////////////////// -TopicViewer::~TopicViewer() -{ -} +TopicViewer::~TopicViewer() = default; ////////////////////////////////////////////////// void TopicViewer::LoadConfig(const tinyxml2::XMLElement *) @@ -176,7 +180,7 @@ QStandardItemModel *TopicViewer::Model() } ////////////////////////////////////////////////// -void TopicViewerPrivate::CreateModel() +void TopicViewer::Implementation::CreateModel() { this->model = new TopicsModel(); @@ -197,7 +201,7 @@ void TopicViewerPrivate::CreateModel() } ////////////////////////////////////////////////// -void TopicViewerPrivate::AddTopic(const std::string &_topic, +void TopicViewer::Implementation::AddTopic(const std::string &_topic, const std::string &_msg) { QStandardItem *topicItem = this->FactoryItem(_topic, _msg); @@ -212,7 +216,7 @@ void TopicViewerPrivate::AddTopic(const std::string &_topic, } ////////////////////////////////////////////////// -void TopicViewerPrivate::AddField(QStandardItem *_parentItem, +void TopicViewer::Implementation::AddField(QStandardItem *_parentItem, const std::string &_msgName, const std::string &_msgType) { @@ -274,7 +278,7 @@ void TopicViewerPrivate::AddField(QStandardItem *_parentItem, } ////////////////////////////////////////////////// -QStandardItem *TopicViewerPrivate::FactoryItem(const std::string &_name, +QStandardItem *TopicViewer::Implementation::FactoryItem(const std::string &_name, const std::string &_type, const std::string &_path, const std::string &_topic) @@ -296,7 +300,7 @@ QStandardItem *TopicViewerPrivate::FactoryItem(const std::string &_name, } ////////////////////////////////////////////////// -void TopicViewerPrivate::SetItemTopic(QStandardItem *_item) +void TopicViewer::Implementation::SetItemTopic(QStandardItem *_item) { std::string topic = this->TopicName(_item); QVariant Topic(QString::fromStdString(topic)); @@ -304,7 +308,7 @@ void TopicViewerPrivate::SetItemTopic(QStandardItem *_item) } ////////////////////////////////////////////////// -void TopicViewerPrivate::SetItemPath(QStandardItem *_item) +void TopicViewer::Implementation::SetItemPath(QStandardItem *_item) { std::string path = this->ItemPath(_item); QVariant Path(QString::fromStdString(path)); @@ -312,7 +316,8 @@ void TopicViewerPrivate::SetItemPath(QStandardItem *_item) } ////////////////////////////////////////////////// -std::string TopicViewerPrivate::TopicName(const QStandardItem *_item) const +std::string TopicViewer::Implementation::TopicName( + const QStandardItem *_item) const { QStandardItem *parent = _item->parent(); @@ -327,7 +332,8 @@ std::string TopicViewerPrivate::TopicName(const QStandardItem *_item) const } ////////////////////////////////////////////////// -std::string TopicViewerPrivate::ItemPath(const QStandardItem *_item) const +std::string TopicViewer::Implementation::ItemPath( + const QStandardItem *_item) const { std::deque path; while (_item) @@ -352,7 +358,7 @@ std::string TopicViewerPrivate::ItemPath(const QStandardItem *_item) const } ///////////////////////////////////////////////// -bool TopicViewerPrivate::IsPlotable( +bool TopicViewer::Implementation::IsPlotable( const google::protobuf::FieldDescriptor::Type &_type) { return std::find(this->plotableTypes.begin(), this->plotableTypes.end(), diff --git a/src/plugins/topic_viewer/TopicViewer.hh b/src/plugins/topic_viewer/TopicViewer.hh index c97bc90e6..dd64b5f5c 100644 --- a/src/plugins/topic_viewer/TopicViewer.hh +++ b/src/plugins/topic_viewer/TopicViewer.hh @@ -21,6 +21,7 @@ #include #include +#include #ifndef _WIN32 # define TopicViewer_EXPORTS_API @@ -35,7 +36,6 @@ namespace gz::gui::plugins { class TopicsModel; -class TopicViewerPrivate; /// \brief a Plugin to view the topics and their msgs & fields /// Field's informations can be passed by dragging them via the UI @@ -60,7 +60,7 @@ class TopicViewer_EXPORTS_API TopicViewer : public Plugin public slots: void UpdateModel(); /// \brief Pointer to private data. - private: std:: unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_TOPICVIEWER_HH_ diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.cc b/src/plugins/transport_scene_manager/TransportSceneManager.cc index 2502deac1..267baa6cf 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.cc +++ b/src/plugins/transport_scene_manager/TransportSceneManager.cc @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -57,7 +58,7 @@ namespace gz::gui::plugins { /// \brief Private data class for TransportSceneManager -class TransportSceneManagerPrivate +class TransportSceneManager::Implementation { /// \brief Make the scene service request and populate the scene public: void Request(); @@ -176,7 +177,7 @@ class TransportSceneManagerPrivate ///////////////////////////////////////////////// TransportSceneManager::TransportSceneManager() - : Plugin(), dataPtr(new TransportSceneManagerPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -252,12 +253,12 @@ void TransportSceneManager::LoadConfig(const tinyxml2::XMLElement *_pluginElem) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::InitializeTransport() +void TransportSceneManager::Implementation::InitializeTransport() { this->Request(); if (!this->node.Subscribe(this->poseTopic, - &TransportSceneManagerPrivate::OnPoseVMsg, this)) + &Implementation::OnPoseVMsg, this)) { gzerr << "Error subscribing to pose topic: " << this->poseTopic << std::endl; @@ -269,7 +270,7 @@ void TransportSceneManagerPrivate::InitializeTransport() } if (!this->node.Subscribe(this->deletionTopic, - &TransportSceneManagerPrivate::OnDeletionMsg, this)) + &Implementation::OnDeletionMsg, this)) { gzerr << "Error subscribing to deletion topic: " << this->deletionTopic << std::endl; @@ -281,7 +282,7 @@ void TransportSceneManagerPrivate::InitializeTransport() } if (!this->node.Subscribe(this->sceneTopic, - &TransportSceneManagerPrivate::OnSceneMsg, this)) + &Implementation::OnSceneMsg, this)) { gzerr << "Error subscribing to scene topic: " << this->sceneTopic << std::endl; @@ -308,7 +309,7 @@ bool TransportSceneManager::eventFilter(QObject *_obj, QEvent *_event) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::Request() +void TransportSceneManager::Implementation::Request() { // wait for the service to be advertized std::vector publishers; @@ -324,7 +325,7 @@ void TransportSceneManagerPrivate::Request() } if (publishers.empty() || !this->node.Request(this->service, - &TransportSceneManagerPrivate::OnSceneSrvMsg, this)) + &Implementation::OnSceneSrvMsg, this)) { gzerr << "Error making service request to [" << this->service << "]" << std::endl; @@ -332,7 +333,7 @@ void TransportSceneManagerPrivate::Request() } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnPoseVMsg(const msgs::Pose_V &_msg) +void TransportSceneManager::Implementation::OnPoseVMsg(const msgs::Pose_V &_msg) { std::lock_guard lock(this->msgMutex); for (int i = 0; i < _msg.pose_size(); ++i) @@ -351,7 +352,8 @@ void TransportSceneManagerPrivate::OnPoseVMsg(const msgs::Pose_V &_msg) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnDeletionMsg(const msgs::UInt32_V &_msg) +void TransportSceneManager::Implementation::OnDeletionMsg( + const msgs::UInt32_V &_msg) { std::lock_guard lock(this->msgMutex); std::copy(_msg.data().begin(), _msg.data().end(), @@ -359,7 +361,7 @@ void TransportSceneManagerPrivate::OnDeletionMsg(const msgs::UInt32_V &_msg) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnRender() +void TransportSceneManager::Implementation::OnRender() { if (nullptr == this->scene) { @@ -368,7 +370,7 @@ void TransportSceneManagerPrivate::OnRender() return; this->initializeTransport = std::thread( - &TransportSceneManagerPrivate::InitializeTransport, this); + &Implementation::InitializeTransport, this); } std::lock_guard lock(this->msgMutex); @@ -430,15 +432,15 @@ void TransportSceneManagerPrivate::OnRender() } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnSceneMsg(const msgs::Scene &_msg) +void TransportSceneManager::Implementation::OnSceneMsg(const msgs::Scene &_msg) { std::lock_guard lock(this->msgMutex); this->sceneMsgs.push_back(_msg); } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnSceneSrvMsg(const msgs::Scene &_msg, - const bool result) +void TransportSceneManager::Implementation::OnSceneSrvMsg( + const msgs::Scene &_msg, const bool result) { if (!result) { @@ -454,7 +456,7 @@ void TransportSceneManagerPrivate::OnSceneSrvMsg(const msgs::Scene &_msg, } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::LoadScene(const msgs::Scene &_msg) +void TransportSceneManager::Implementation::LoadScene(const msgs::Scene &_msg) { rendering::VisualPtr rootVis = this->scene->RootVisual(); @@ -487,7 +489,7 @@ void TransportSceneManagerPrivate::LoadScene(const msgs::Scene &_msg) } ///////////////////////////////////////////////// -rendering::VisualPtr TransportSceneManagerPrivate::LoadModel( +rendering::VisualPtr TransportSceneManager::Implementation::LoadModel( const msgs::Model &_msg) { rendering::VisualPtr modelVis; @@ -529,7 +531,7 @@ rendering::VisualPtr TransportSceneManagerPrivate::LoadModel( } ///////////////////////////////////////////////// -rendering::VisualPtr TransportSceneManagerPrivate::LoadLink( +rendering::VisualPtr TransportSceneManager::Implementation::LoadLink( const msgs::Link &_msg) { rendering::VisualPtr linkVis; @@ -570,7 +572,7 @@ rendering::VisualPtr TransportSceneManagerPrivate::LoadLink( } ///////////////////////////////////////////////// -rendering::VisualPtr TransportSceneManagerPrivate::LoadVisual( +rendering::VisualPtr TransportSceneManager::Implementation::LoadVisual( const msgs::Visual &_msg) { if (!_msg.has_geometry()) @@ -674,7 +676,7 @@ rendering::VisualPtr TransportSceneManagerPrivate::LoadVisual( } ///////////////////////////////////////////////// -rendering::GeometryPtr TransportSceneManagerPrivate::LoadGeometry( +rendering::GeometryPtr TransportSceneManager::Implementation::LoadGeometry( const msgs::Geometry &_msg, math::Vector3d &_scale, math::Pose3d &_localPose) { @@ -767,7 +769,7 @@ rendering::GeometryPtr TransportSceneManagerPrivate::LoadGeometry( } ///////////////////////////////////////////////// -rendering::MaterialPtr TransportSceneManagerPrivate::LoadMaterial( +rendering::MaterialPtr TransportSceneManager::Implementation::LoadMaterial( const msgs::Material &_msg) { rendering::MaterialPtr material = this->scene->CreateMaterial(); @@ -792,7 +794,7 @@ rendering::MaterialPtr TransportSceneManagerPrivate::LoadMaterial( } ///////////////////////////////////////////////// -rendering::LightPtr TransportSceneManagerPrivate::LoadLight( +rendering::LightPtr TransportSceneManager::Implementation::LoadLight( const msgs::Light &_msg) { rendering::LightPtr light; @@ -848,7 +850,8 @@ rendering::LightPtr TransportSceneManagerPrivate::LoadLight( } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::DeleteEntity(const unsigned int _entity) +void TransportSceneManager::Implementation::DeleteEntity( + const unsigned int _entity) { if (this->visuals.find(_entity) != this->visuals.end()) { diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.hh b/src/plugins/transport_scene_manager/TransportSceneManager.hh index 117f098d5..75e27fbb3 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.hh +++ b/src/plugins/transport_scene_manager/TransportSceneManager.hh @@ -22,10 +22,10 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { -class TransportSceneManagerPrivate; - /// \brief Provides a Gazebo Transport interface to /// `gz::gui::plugins::MinimalScene`. /// @@ -47,18 +47,17 @@ class TransportSceneManager : public Plugin public: TransportSceneManager(); /// \brief Destructor - public: virtual ~TransportSceneManager(); + public: ~TransportSceneManager() override; // Documentation inherited - public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem) - override; + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; // Documentation inherited private: bool eventFilter(QObject *_obj, QEvent *_event) override; /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_TRANSPORTSCENEMANAGER_HH_ diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/world_control/WorldControl.cc index edacf1ca3..86095179c 100644 --- a/src/plugins/world_control/WorldControl.cc +++ b/src/plugins/world_control/WorldControl.cc @@ -35,7 +35,7 @@ namespace gz::gui::plugins { -class WorldControlPrivate +class WorldControl::Implementation { /// \brief Send the world control event or call the control service. /// \param[in] _msg Message to send. @@ -71,14 +71,12 @@ class WorldControlPrivate ///////////////////////////////////////////////// WorldControl::WorldControl() - : Plugin(), dataPtr(new WorldControlPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } ///////////////////////////////////////////////// -WorldControl::~WorldControl() -{ -} +WorldControl::~WorldControl() = default; ///////////////////////////////////////////////// void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -329,7 +327,7 @@ void WorldControl::OnStep() } ///////////////////////////////////////////////// -void WorldControlPrivate::SendEventMsg(const msgs::WorldControl &_msg) +void WorldControl::Implementation::SendEventMsg(const msgs::WorldControl &_msg) { if (this->useEvent) { diff --git a/src/plugins/world_control/WorldControl.hh b/src/plugins/world_control/WorldControl.hh index 038b83b00..e944cf560 100644 --- a/src/plugins/world_control/WorldControl.hh +++ b/src/plugins/world_control/WorldControl.hh @@ -24,6 +24,8 @@ #include "gz/gui/Plugin.hh" +#include + #ifndef _WIN32 # define WorldControl_EXPORTS_API #else @@ -36,8 +38,6 @@ namespace gz::gui::plugins { -class WorldControlPrivate; - /// \brief This plugin provides a world control panel which may have a /// play / pause and step buttons. /// @@ -64,10 +64,10 @@ class WorldControl_EXPORTS_API WorldControl: public gz::gui::Plugin public: WorldControl(); /// \brief Destructor - public: virtual ~WorldControl(); + public: ~WorldControl() override; // Documentation inherited - public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem); + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; /// \brief Callback in main thread when diagnostics come in public slots: void ProcessMsg(); @@ -101,7 +101,7 @@ class WorldControl_EXPORTS_API WorldControl: public gz::gui::Plugin private: void OnWorldStatsMsg(const gz::msgs::WorldStatistics &_msg); // Private data - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_WORLDCONTROL_HH_ diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/world_stats/WorldStats.cc index 86be0aafa..96c2ecead 100644 --- a/src/plugins/world_stats/WorldStats.cc +++ b/src/plugins/world_stats/WorldStats.cc @@ -26,64 +26,52 @@ #include #include #include +#include #include "gz/gui/Helpers.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class WorldStats::Implementation { -namespace plugins -{ - class WorldStatsPrivate - { - /// \brief Message holding latest world statistics - public: gz::msgs::WorldStatistics msg; + /// \brief Message holding latest world statistics + public: gz::msgs::WorldStatistics msg; - /// \brief Mutex to protect msg - public: std::recursive_mutex mutex; + /// \brief Mutex to protect msg + public: std::recursive_mutex mutex; - /// \brief Communication node - public: gz::transport::Node node; + /// \brief Communication node + public: gz::transport::Node node; - /// \brief Holds real time factor - public: QString realTimeFactor; + /// \brief Holds real time factor + public: QString realTimeFactor; - /// \brief Holds sim time - public: QString simTime; + /// \brief Holds sim time + public: QString simTime; - /// \brief Holds real time - public: QString realTime; + /// \brief Holds real time + public: QString realTime; - /// \brief Holds iterations - public: QString iterations; + /// \brief Holds iterations + public: QString iterations; - /// \brief Time delayed version if simTime used for computing a low-pass - /// filtered RTF - public: std::optional simTimeDelayed; - - /// \brief Time delayed version if realTime used for computing a low-pass - /// filtered RTF - public: std::optional realTimeDelayed; - }; -} -} -} + /// \brief Time delayed version if simTime used for computing a low-pass + /// filtered RTF + public: std::optional simTimeDelayed; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Time delayed version if realTime used for computing a low-pass + /// filtered RTF + public: std::optional realTimeDelayed; +}; ///////////////////////////////////////////////// WorldStats::WorldStats() - : Plugin(), dataPtr(new WorldStatsPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } ///////////////////////////////////////////////// -WorldStats::~WorldStats() -{ -} +WorldStats::~WorldStats() = default; ///////////////////////////////////////////////// void WorldStats::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -341,7 +329,8 @@ void WorldStats::SetIterations(const QString &_iterations) this->dataPtr->iterations = _iterations; this->IterationsChanged(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(WorldStats, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::WorldStats, + gz::gui::Plugin) diff --git a/src/plugins/world_stats/WorldStats.hh b/src/plugins/world_stats/WorldStats.hh index 4ba244ee0..9b7b14ea3 100644 --- a/src/plugins/world_stats/WorldStats.hh +++ b/src/plugins/world_stats/WorldStats.hh @@ -25,6 +25,8 @@ #include "gz/gui/Export.hh" #include "gz/gui/Plugin.hh" +#include + #ifndef _WIN32 # define WorldStats_EXPORTS_API #else @@ -37,8 +39,6 @@ namespace gz::gui::plugins { -class WorldStatsPrivate; - /// \brief This plugin provides a time panel which may display: /// * Simulation time /// * Real time @@ -99,10 +99,10 @@ class WorldStats_EXPORTS_API WorldStats: public gz::gui::Plugin public: WorldStats(); /// \brief Destructor - public: virtual ~WorldStats(); + public: ~WorldStats() override; // Documentation inherited - public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem); + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; /// \brief Callback in main thread when diagnostics come in public slots: void ProcessMsg(); @@ -155,7 +155,7 @@ class WorldStats_EXPORTS_API WorldStats: public gz::gui::Plugin private: void OnWorldStatsMsg(const gz::msgs::WorldStatistics &_msg); // Private data - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_WORLDSTATS_HH_