Skip to content

Commit

Permalink
@wip implptr plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Oct 5, 2023
1 parent f3e8923 commit 11b9da4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
10 changes: 4 additions & 6 deletions src/plugins/camera_fps/CameraFps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include <gz/utils/ImplPtr.hh>
#include <list>
#include <string>

Expand All @@ -31,9 +32,8 @@

namespace gz::gui::plugins
{

/// \brief Private data class for CameraFps
class CameraFpsPrivate
class CameraFps::Implementation
{
/// \brief Previous camera update time
public: std::optional<std::chrono::steady_clock::time_point>
Expand Down Expand Up @@ -83,14 +83,12 @@ void CameraFps::OnRender()

/////////////////////////////////////////////////
CameraFps::CameraFps()
: Plugin(), dataPtr(new CameraFpsPrivate)
: dataPtr(gz::utils::MakeUniqueImpl<Implementation>())
{
}

/////////////////////////////////////////////////
CameraFps::~CameraFps()
{
}
CameraFps::~CameraFps() = default;

/////////////////////////////////////////////////
void CameraFps::LoadConfig(const tinyxml2::XMLElement *)
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/camera_fps/CameraFps.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
#ifndef GZ_GUI_PLUGINS_CAMERAFPS_HH_
#define GZ_GUI_PLUGINS_CAMERAFPS_HH_

#include <gz/utils/ImplPtr.hh>
#include <memory>

#include "gz/gui/Plugin.hh"

namespace gz::gui::plugins
{
/// Forward declarations
class CameraFpsPrivate;

/// \brief This plugin displays the GUI camera's Framerate Per Second (FPS)
class CameraFps : public Plugin
{
Expand Down Expand Up @@ -69,7 +67,7 @@ class CameraFps : public Plugin

/// \internal
/// \brief Pointer to private data.
private: std::unique_ptr<CameraFpsPrivate> dataPtr;
GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
};
} // namespace gz::gui::plugins
#endif // GZ_GUI_PLUGINS_CAMERAFPS_HH_
12 changes: 6 additions & 6 deletions src/plugins/camera_tracking/CameraTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include <gz/utils/ImplPtr.hh>
#include <mutex>
#include <string>

Expand Down Expand Up @@ -44,7 +45,7 @@
namespace gz::gui::plugins
{
/// \brief Private data class for CameraTracking
class CameraTrackingPrivate
class CameraTracking::Implementation
{
/// \brief Perform rendering calls in the rendering thread.
public: void OnRender();
Expand Down Expand Up @@ -430,7 +431,7 @@ void CameraTrackingPrivate::OnRender()

/////////////////////////////////////////////////
CameraTracking::CameraTracking()
: Plugin(), dataPtr(new CameraTrackingPrivate)
: dataPtr(gz::utils::MakeUniqueImpl<Implementation>())
{
this->dataPtr->timer = new QTimer(this);
this->connect(this->dataPtr->timer, &QTimer::timeout, [=]()
Expand All @@ -449,9 +450,7 @@ CameraTracking::CameraTracking()
}

/////////////////////////////////////////////////
CameraTracking::~CameraTracking()
{
}
CameraTracking::~CameraTracking() = default;

/////////////////////////////////////////////////
void CameraTracking::LoadConfig(const tinyxml2::XMLElement *)
Expand All @@ -463,7 +462,8 @@ void CameraTracking::LoadConfig(const tinyxml2::XMLElement *)
}

/////////////////////////////////////////////////
void CameraTrackingPrivate::HandleKeyRelease(events::KeyReleaseOnScene *_e)
void CameraTracking::Implementation::HandleKeyRelease(
events::KeyReleaseOnScene *_e)
{
if (_e->Key().Key() == Qt::Key_Escape)
{
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/camera_tracking/CameraTracking.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef GZ_GUI_PLUGINS_CAMERATRACKING_HH_
#define GZ_GUI_PLUGINS_CAMERATRACKING_HH_

#include <gz/utils/ImplPtr.hh>
#include <memory>

#include "gz/gui/Plugin.hh"
Expand Down Expand Up @@ -58,7 +59,7 @@ class CameraTracking : public Plugin

/// \internal
/// \brief Pointer to private data.
private: std::unique_ptr<CameraTrackingPrivate> dataPtr;
GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
};
} // namespace gz::gui::plugins
#endif // GZ_GUI_PLUGINS_CAMERATRACKING_HH_

0 comments on commit 11b9da4

Please sign in to comment.