Skip to content

Commit

Permalink
Deprecations, ign -> gz (#1631)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Aug 8, 2022
1 parent f8733fa commit ee48126
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 72 deletions.
13 changes: 8 additions & 5 deletions include/gz/sim/Events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@ namespace gz
using Stop = gz::common::EventT<void(void), struct StopTag>;

/// \brief Please use the LoadSdfPlugins event. The LoadPlugins event
/// will be deprecrated in Gazebo 7 (Garden). Also make sure to
/// is deprecrated in Gazebo 7 (Garden). Also make sure to
/// connect to only LoadSdfPlugins or LoadPlugins, and not both events.
///
/// Event used to load plugins for an entity into simulation.
/// Pass in the entity which will own the plugins, and an SDF element for
/// the entity, which may contain multiple `<plugin>` tags.
/// \note This will be deprecated in Gazebo 7 (Garden), please the use
/// sdf::Plugin interface.
using LoadPlugins = common::EventT<void(Entity, sdf::ElementPtr),
struct LoadPluginsTag>;
/// \deprecated Use the `sdf::Plugins` interface.
#ifdef _WIN32
using LoadPlugins =
#else
using LoadPlugins GZ_DEPRECATED(7) =
#endif
common::EventT<void(Entity, sdf::ElementPtr), struct LoadPluginsTag>;

/// \brief Event used to load plugins for an entity into simulation.
/// Pass in the entity which will own the plugins, and an SDF element for
Expand Down
6 changes: 3 additions & 3 deletions include/gz/sim/ServerConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace gz
/// \brief Get the plugin library filename.
/// \return Plugin library filename.
/// \deprecated Use `sdf::Plugin` interface.
public: const std::string & GZ_DEPRECATED(7) Filename() const;
public: const std::string GZ_DEPRECATED(7) & Filename() const;

/// \brief Set the type of the entity which should receive this
/// plugin. The type is used in conjuction with EntityName to
Expand All @@ -155,7 +155,7 @@ namespace gz
/// to load.
/// \return Interface name.
/// \deprecated Use `sdf::Plugin` interface.
public: const std::string & GZ_DEPRECATED(7) Name() const;
public: const std::string GZ_DEPRECATED(7) & Name() const;

/// \brief Set the name of the interface within the plugin library
/// to load.
Expand All @@ -166,7 +166,7 @@ namespace gz
/// \brief Plugin XML elements associated with this plugin.
/// \return SDF pointer.
/// \deprecated Use `sdf::Plugin` interface.
public: const sdf::ElementPtr & GZ_DEPRECATED(7) Sdf() const;
public: const sdf::ElementPtr GZ_DEPRECATED(7) & Sdf() const;

/// \brief Set the plugin XML elements associated with this plugin.
/// \param[in] _sdf SDF pointer, it will be cloned.
Expand Down
4 changes: 3 additions & 1 deletion src/LevelManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ void LevelManager::ReadLevelPerformerInfo()
// Load world plugins.
this->runner->EventMgr().Emit<events::LoadSdfPlugins>(this->worldEntity,
this->runner->sdfWorld->Plugins());
// Deprecate this in Garden

GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->runner->EventMgr().Emit<events::LoadPlugins>(this->worldEntity,
this->runner->sdfWorld->Element());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

// Store the world's SDF DOM to be used when saving the world to file
this->runner->entityCompMgr.CreateComponent(
Expand Down
10 changes: 10 additions & 0 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::World *_world)
_world->Plugins());
for (const sdf::Plugin &p : _world->Plugins())
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(worldEntity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

// Store the world's SDF DOM to be used when saving the world to file
Expand All @@ -352,8 +354,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model)
this->dataPtr->eventManager->Emit<events::LoadSdfPlugins>(entity, plugins);
for (const sdf::Plugin &p : plugins)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(entity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}
}
this->dataPtr->newModels.clear();
Expand All @@ -364,8 +368,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model)
this->dataPtr->eventManager->Emit<events::LoadSdfPlugins>(entity, plugins);
for (const sdf::Plugin &p : plugins)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(entity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}
}
this->dataPtr->newSensors.clear();
Expand All @@ -376,8 +382,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Model *_model)
this->dataPtr->eventManager->Emit<events::LoadSdfPlugins>(entity, plugins);
for (const sdf::Plugin &p : plugins)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(entity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}
}
this->dataPtr->newVisuals.clear();
Expand Down Expand Up @@ -514,8 +522,10 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Actor *_actor)
_actor->Plugins());
for (const sdf::Plugin &p : _actor->Plugins())
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
this->dataPtr->eventManager->Emit<events::LoadPlugins>(actorEntity,
p.ToElement());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

return actorEntity;
Expand Down
24 changes: 3 additions & 21 deletions src/ServerConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class gz::sim::ServerConfig::PluginInfoPrivate
const std::unique_ptr<ServerConfig::PluginInfoPrivate> &_info)
: entityName(_info->entityName),
entityType(_info->entityType),
plugin(_info->plugin),
filename(_info->filename),
name(_info->name)
plugin(_info->plugin)
{
this->sdf = plugin.Element();
}
Expand All @@ -66,8 +64,6 @@ class gz::sim::ServerConfig::PluginInfoPrivate
: entityName(std::move(_entityName)),
entityType(std::move(_entityType)),
plugin(std::move(_plugin)),
filename(plugin.Filename()),
name(plugin.Name()),
sdf(plugin.Element())
{
}
Expand All @@ -81,14 +77,6 @@ class gz::sim::ServerConfig::PluginInfoPrivate
/// \brief SDF plugin information.
public: sdf::Plugin plugin;

/// \brief _filename The plugin library.
// Remove this in Garden, and rely solely on the plugin variable.
// Requires: https://github.com/gazebosim/sdformat/pull/1055
public: std::string filename = "";

/// \brief Name of the plugin implementation.
public: std::string name = "";

/// \brief XML elements associated with this plugin
public: sdf::ElementPtr sdf = nullptr;
};
Expand Down Expand Up @@ -117,8 +105,6 @@ ServerConfig::PluginInfo::PluginInfo(const std::string &_entityName,
}
this->dataPtr->plugin.SetName(_name);
this->dataPtr->plugin.SetFilename(_filename);
this->dataPtr->filename = _filename;
this->dataPtr->name = _name;
this->dataPtr->entityName = _entityName;
this->dataPtr->entityType = _entityType;
}
Expand Down Expand Up @@ -174,27 +160,25 @@ void ServerConfig::PluginInfo::SetEntityType(const std::string &_entityType)
//////////////////////////////////////////////////
const std::string &ServerConfig::PluginInfo::Filename() const
{
return this->dataPtr->filename;
return this->dataPtr->plugin.Filename();
}

//////////////////////////////////////////////////
void ServerConfig::PluginInfo::SetFilename(const std::string &_filename)
{
this->dataPtr->plugin.SetFilename(_filename);
this->dataPtr->filename = _filename;
}

//////////////////////////////////////////////////
const std::string &ServerConfig::PluginInfo::Name() const
{
return this->dataPtr->name;
return this->dataPtr->plugin.Name();
}

//////////////////////////////////////////////////
void ServerConfig::PluginInfo::SetName(const std::string &_name)
{
this->dataPtr->plugin.SetName(_name);
this->dataPtr->name = _name;
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -231,8 +215,6 @@ sdf::Plugin &ServerConfig::PluginInfo::Plugin()
void ServerConfig::PluginInfo::SetPlugin(const sdf::Plugin &_plugin) const
{
this->dataPtr->plugin = _plugin;
this->dataPtr->filename = _plugin.Filename();
this->dataPtr->name = _plugin.Name();
}

/// \brief Private data for ServerConfig.
Expand Down
15 changes: 0 additions & 15 deletions src/ServerConfig_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,21 @@ TEST(ParsePluginsFromString, Valid)

EXPECT_EQ("default", plugin->EntityName());
EXPECT_EQ("world", plugin->EntityType());
EXPECT_EQ("TestWorldSystem", plugin->Filename());
EXPECT_EQ("TestWorldSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Plugin().Name());

plugin = std::next(plugin, 1);

EXPECT_EQ("box", plugin->EntityName());
EXPECT_EQ("model", plugin->EntityType());
EXPECT_EQ("TestModelSystem", plugin->Filename());
EXPECT_EQ("TestModelSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestModelSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestModelSystem", plugin->Plugin().Name());

plugin = std::next(plugin, 1);

EXPECT_EQ("default::box::link_1::camera", plugin->EntityName());
EXPECT_EQ("sensor", plugin->EntityType());
EXPECT_EQ("TestSensorSystem", plugin->Filename());
EXPECT_EQ("TestSensorSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Plugin().Name());
}

Expand Down Expand Up @@ -120,27 +114,21 @@ TEST(ParsePluginsFromFile, Valid)

EXPECT_EQ("default", plugin->EntityName());
EXPECT_EQ("world", plugin->EntityType());
EXPECT_EQ("TestWorldSystem", plugin->Filename());
EXPECT_EQ("TestWorldSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Plugin().Name());

plugin = std::next(plugin, 1);

EXPECT_EQ("box", plugin->EntityName());
EXPECT_EQ("model", plugin->EntityType());
EXPECT_EQ("TestModelSystem", plugin->Filename());
EXPECT_EQ("TestModelSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestModelSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestModelSystem", plugin->Plugin().Name());

plugin = std::next(plugin, 1);

EXPECT_EQ("default::box::link_1::camera", plugin->EntityName());
EXPECT_EQ("sensor", plugin->EntityType());
EXPECT_EQ("TestSensorSystem", plugin->Filename());
EXPECT_EQ("TestSensorSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestSensorSystem", plugin->Plugin().Name());
}

Expand Down Expand Up @@ -213,17 +201,14 @@ TEST(LoadPluginInfo, FromValidEnv)

EXPECT_EQ("*", plugin->EntityName());
EXPECT_EQ("world", plugin->EntityType());
EXPECT_EQ("TestWorldSystem", plugin->Filename());
EXPECT_EQ("TestWorldSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestWorldSystem", plugin->Plugin().Name());

plugin = std::next(plugin, 1);

EXPECT_EQ("box", plugin->EntityName());
EXPECT_EQ("model", plugin->EntityType());
EXPECT_EQ("TestModelSystem", plugin->Plugin().Filename());
EXPECT_EQ("gz::sim::TestModelSystem", plugin->Name());
EXPECT_EQ("gz::sim::TestModelSystem", plugin->Plugin().Name());

EXPECT_TRUE(common::unsetenv(sim::kServerConfigPathEnv));
Expand Down
31 changes: 18 additions & 13 deletions src/Server_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ TEST_P(ServerFixture, ServerConfigPluginInfo)

EXPECT_EQ("an_entity", plugins.front().EntityName());
EXPECT_EQ("model", plugins.front().EntityType());
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
EXPECT_EQ("filename", plugins.front().Filename());
EXPECT_EQ("interface", plugins.front().Name());
EXPECT_EQ(nullptr, plugins.front().Sdf());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

// Test operator=
{
Expand All @@ -131,9 +133,9 @@ TEST_P(ServerFixture, ServerConfigPluginInfo)

EXPECT_EQ(info.EntityName(), plugins.front().EntityName());
EXPECT_EQ(info.EntityType(), plugins.front().EntityType());
EXPECT_EQ(info.Filename(), plugins.front().Filename());
EXPECT_EQ(info.Name(), plugins.front().Name());
EXPECT_EQ(info.Sdf(), plugins.front().Sdf());
EXPECT_EQ(info.Plugin().Name(), plugins.front().Plugin().Name());
EXPECT_EQ(info.Plugin().Filename(), plugins.front().Plugin().Filename());
EXPECT_EQ(info.Plugin().Element(), plugins.front().Plugin().Element());
}

// Test copy constructor
Expand All @@ -142,9 +144,9 @@ TEST_P(ServerFixture, ServerConfigPluginInfo)

EXPECT_EQ(info.EntityName(), plugins.front().EntityName());
EXPECT_EQ(info.EntityType(), plugins.front().EntityType());
EXPECT_EQ(info.Filename(), plugins.front().Filename());
EXPECT_EQ(info.Name(), plugins.front().Name());
EXPECT_EQ(info.Sdf(), plugins.front().Sdf());
EXPECT_EQ(info.Plugin().Name(), plugins.front().Plugin().Name());
EXPECT_EQ(info.Plugin().Filename(), plugins.front().Plugin().Filename());
EXPECT_EQ(info.Plugin().Element(), plugins.front().Plugin().Element());
}

// Test server config copy constructor
Expand All @@ -155,9 +157,12 @@ TEST_P(ServerFixture, ServerConfigPluginInfo)

EXPECT_EQ(cfgPlugins.front().EntityName(), plugins.front().EntityName());
EXPECT_EQ(cfgPlugins.front().EntityType(), plugins.front().EntityType());
EXPECT_EQ(cfgPlugins.front().Filename(), plugins.front().Filename());
EXPECT_EQ(cfgPlugins.front().Name(), plugins.front().Name());
EXPECT_EQ(cfgPlugins.front().Sdf(), plugins.front().Sdf());
EXPECT_EQ(cfgPlugins.front().Plugin().Filename(),
plugins.front().Plugin().Filename());
EXPECT_EQ(cfgPlugins.front().Plugin().Name(),
plugins.front().Plugin().Name());
EXPECT_EQ(cfgPlugins.front().Plugin().Element(),
plugins.front().Plugin().Element());
}
}

Expand Down Expand Up @@ -622,7 +627,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(RunOnceUnpaused))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down Expand Up @@ -671,7 +676,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(RunOncePaused))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down Expand Up @@ -836,7 +841,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(AddSystemWhileRunning))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down Expand Up @@ -875,7 +880,7 @@ TEST_P(ServerFixture, GZ_UTILS_TEST_DISABLED_ON_WIN32(AddSystemAfterLoad))
sim::SystemLoader systemLoader;
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto mockSystemPlugin = systemLoader.LoadPlugin(sdfPlugin);
ASSERT_TRUE(mockSystemPlugin.has_value());

Expand Down
2 changes: 1 addition & 1 deletion test/integration/battery_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BatteryPluginTest : public InternalFixture<::testing::Test>

sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("libMockSystem.so");
sdfPlugin.SetFilename("MockSystem");
auto plugin = sm.LoadPlugin(sdfPlugin);
EXPECT_TRUE(plugin.has_value());
this->systemPtr = plugin.value();
Expand Down
7 changes: 4 additions & 3 deletions test/integration/reset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ class ResetFixture: public InternalFixture<::testing::Test>
{
InternalFixture::SetUp();

auto plugin = sm.LoadPlugin("libMockSystem.so",
"gz::sim::MockSystem",
nullptr);
sdf::Plugin sdfPlugin;
sdfPlugin.SetName("gz::sim::MockSystem");
sdfPlugin.SetFilename("MockSystem");
auto plugin = sm.LoadPlugin(sdfPlugin);
EXPECT_TRUE(plugin.has_value());
this->systemPtr = plugin.value();
this->mockSystem = static_cast<sim::MockSystem *>(
Expand Down
2 changes: 1 addition & 1 deletion test/integration/scene_broadcaster_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ TEST_P(SceneBroadcasterTest,
// Start server
gz::sim::ServerConfig serverConfig;
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) +
common::joinPaths("/", "test", "worlds", "particle_emitter2.sdf"));
common::joinPaths("/", "test", "worlds", "particle_emitter.sdf"));

sim::Server server(serverConfig);
EXPECT_FALSE(server.Running());
Expand Down
Loading

0 comments on commit ee48126

Please sign in to comment.