Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added private data pointer for storage #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ros_gz_example_gazebo/include/ros_gz_example_gazebo/FullSystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

namespace ros_gz_example_gazebo
{
// This is the a forward declaration for a private data member
// class used to store data during plugin operation.
class FullSystemPrivate;

// This is the main plugin's class. It must inherit from System and at least
// one other interface.
// Here we use `ISystemPostUpdate`, which is used to get results after
Expand All @@ -38,6 +42,12 @@ namespace ros_gz_example_gazebo
public gz::sim::ISystemPostUpdate,
public gz::sim::ISystemReset
{
// Class constructor
public: FullSystem();

// Class destructor
public: ~FullSystem() override;

// Plugins inheriting ISystemConfigure must implement the Configure
// callback. This is called when a system is initially loaded.
// The _entity variable contains the entity that the system is attached to
Expand Down Expand Up @@ -78,6 +88,10 @@ namespace ros_gz_example_gazebo
// This is called when simulation is reset/rewound to initial conditions.
public: void Reset(const gz::sim::UpdateInfo &_info,
gz::sim::EntityComponentManager &_ecm) override;

// A private unique pointer is created of type `FullSystemPrivate`.
// This can be used to store valures during plugin operation.
private: std::unique_ptr<FullSystemPrivate> dataPtr;
};
}
#endif
20 changes: 20 additions & 0 deletions ros_gz_example_gazebo/src/FullSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ GZ_ADD_PLUGIN(
namespace ros_gz_example_gazebo
{

class FullSystemPrivate
{
// This class can be used to define internal variables,
// functions and subscription callbacks.
// Store values extracted from the SDF.
// Store Gazebo transport information including
// publishers and subscribers.
};

FullSystem::FullSystem()
: dataPtr(std::make_unique<FullSystemPrivate>())
{
// Do nothing
}

FullSystem::~FullSystem()
{
// Do nothing
}
Comment on lines +60 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FullSystem::~FullSystem()
{
// Do nothing
}
FullSystem::~FullSystem() = default;


void FullSystem::Configure(const gz::sim::Entity &_entity,
const std::shared_ptr<const sdf::Element> &_element,
gz::sim::EntityComponentManager &_ecm,
Expand Down