Skip to content

Commit

Permalink
Deprecation warnings for Plugin (#350)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed May 24, 2022
1 parent b0f3e51 commit 1e626ed
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 24 deletions.
3 changes: 3 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ release will remove the deprecated code.
be used instead, which properly handles submeshes having no material index
applied to them.

1. All the plugin APIs are deprecated, use the gz-plugin library instead. See
the [migration guide](https://github.com/ignitionrobotics/ign-plugin/blob/ign-plugin1/MIGRATION.md).

### Additions

1. **geospatial** component that loads heightmap images and DEMs
Expand Down
2 changes: 1 addition & 1 deletion include/ignition/common/Plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace ignition

/// \brief Default constructor. This is kept private to ensure that
/// Plugins are always managed by a PluginPtr object.
private: Plugin();
private: IGN_DEPRECATED(5) Plugin();

/// \brief Type-agnostic retriever for interfaces
private: void *PrivateGetInterface(
Expand Down
3 changes: 2 additions & 1 deletion include/ignition/common/PluginInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <functional>
#include <string>
#include <unordered_map>
#include <gz/common/Export.hh>

namespace ignition
{
Expand All @@ -35,7 +36,7 @@ namespace ignition


/// \brief Holds info required to construct a plugin
struct PluginInfo
struct IGN_DEPRECATED(5) PluginInfo
{
/// \brief The name of the plugin
std::string name;
Expand Down
2 changes: 1 addition & 1 deletion include/ignition/common/PluginLoader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace ignition
class IGNITION_COMMON_VISIBLE PluginLoader
{
/// \brief Constructor
public: PluginLoader();
public: IGN_DEPRECATED(5) PluginLoader();

/// \brief Destructor
public: ~PluginLoader();
Expand Down
2 changes: 2 additions & 0 deletions include/ignition/common/PluginMacros.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "ignition/common/detail/PluginMacros.hh"

// Deprecated, use gz-plugin

// --------------- Specialize a plugin interface (optional) -------------------

/// \brief Call this macro inside a public scope of an interface in order to get
Expand Down
16 changes: 9 additions & 7 deletions include/ignition/common/PluginPtr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,20 @@ namespace ignition
/// \brief Default constructor. Creates a PluginPtr object that does not
/// point to any plugin instance. IsEmpty() will return true until a
/// plugin instance is provided.
public: TemplatePluginPtr();
public: IGN_DEPRECATED(5) TemplatePluginPtr();

/// \brief Copy constructor. This PluginPtr will now point at the same
/// plugin instance as _other, and they will share ownership.
/// \param[in] _other Pointer to plugin being copied.
public: TemplatePluginPtr(const TemplatePluginPtr &_other);
public: IGN_DEPRECATED(5) TemplatePluginPtr(
const TemplatePluginPtr &_other);

/// \brief Move constructor. This PluginPtr will take ownership of the
/// plugin instance held by _other. If this PluginPtr was holding an
/// instance to another plugin, that instance will be deleted if no other
/// PluginPtr is referencing it.
/// \param[in] _other Pointer to plugin being moved.
public: TemplatePluginPtr(TemplatePluginPtr &&_other);
public: IGN_DEPRECATED(5) TemplatePluginPtr(TemplatePluginPtr &&_other);

/// \brief Casting constructor. This PluginPtr will now point at the same
/// plugin instance as _other, and they will share ownership. This
Expand All @@ -83,7 +84,7 @@ namespace ignition
/// \param[in] _other Another PluginPtr object. It may have a different
/// kind of specialization.
public: template <typename OtherPluginType>
TemplatePluginPtr(
IGN_DEPRECATED(5) TemplatePluginPtr(
const TemplatePluginPtr<OtherPluginType> &_other);

/// \brief Copy assignment operator. This PluginPtr will now point at the
Expand Down Expand Up @@ -206,7 +207,8 @@ namespace ignition
/// \param[in] _info A PluginInfo instance that was generated by
/// PluginLoader. Alternatively, this can take a nullptr to create an
/// empty PluginPtr.
private: explicit TemplatePluginPtr(const PluginInfo *_info);
private: explicit IGN_DEPRECATED(5) TemplatePluginPtr(
const PluginInfo *_info);

/// \brief Pointer to the plugin wrapper that this PluginPtr is managing.
private: std::unique_ptr<PluginType> dataPtr;
Expand All @@ -218,11 +220,11 @@ namespace ignition

/// \brief Typical usage for TemplatePluginPtr is to just hold a generic
/// Plugin type.
using PluginPtr = TemplatePluginPtr<Plugin>;
using PluginPtr IGN_DEPRECATED(5) = TemplatePluginPtr<Plugin>;

/// \brief This produces a PluginPtr whose Plugin wrapper only grants access
/// to const-qualified interfaces of the plugin instance.
using ConstPluginPtr = TemplatePluginPtr<const Plugin>;
using ConstPluginPtr IGN_DEPRECATED(5) = TemplatePluginPtr<const Plugin>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/ignition/common/SpecializedPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace ignition
template <class> friend class TemplatePluginPtr;

/// \brief Default constructor
private: SpecializedPlugin();
private: IGN_DEPRECATED(5) SpecializedPlugin();

/// \brief type is an empty placeholder class which is used by the private
/// member functions to provide two overloads: a high-performance one for
Expand Down
4 changes: 2 additions & 2 deletions include/ignition/common/SpecializedPluginPtr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ namespace ignition
/// ignition/common/PluginMacros.hh into a public location of its class
/// definition.
template <typename... SpecInterfaces>
using SpecializedPluginPtr =
using SpecializedPluginPtr IGN_DEPRECATED(5) =
TemplatePluginPtr< SpecializedPlugin<SpecInterfaces...> >;

/// \brief This alias creates a specialized PluginPtr whose interfaces are
/// all const-qualified.
template <typename... SpecInterfaces>
using ConstSpecializedPluginPtr =
using ConstSpecializedPluginPtr IGN_DEPRECATED(5) =
TemplatePluginPtr< const SpecializedPlugin<SpecInterfaces...> >;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*
*/

#include "gz/utils/SuppressWarning.hh"
#include "ignition/common/Console.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include "ignition/common/Plugin.hh"
#include "ignition/common/PluginInfo.hh"
#include "ignition/common/Console.hh"
#include "PluginUtils.hh"

namespace ignition
Expand Down Expand Up @@ -184,3 +186,4 @@ namespace ignition
}
}
}
IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
8 changes: 6 additions & 2 deletions src/PluginLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
#include <sstream>
#include <unordered_map>

#include "gz/utils/SuppressWarning.hh"
#include "ignition/common/Console.hh"
#include "ignition/common/StringUtils.hh"
#include "ignition/common/Util.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include "ignition/common/PluginInfo.hh"
#include "ignition/common/PluginLoader.hh"
#include "ignition/common/PluginPtr.hh"
#include "ignition/common/StringUtils.hh"
#include "ignition/common/Util.hh"

#include "PluginUtils.hh"

Expand Down Expand Up @@ -315,3 +318,4 @@ namespace ignition
}
}
}
IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
7 changes: 6 additions & 1 deletion src/PluginLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include <algorithm>
#include <fstream>

#include <gz/utils/SuppressWarning.hh>

#include "ignition/common/config.hh"
#include "ignition/common/PluginLoader.hh"
#include "ignition/common/SystemPaths.hh"
#include "ignition/common/TempDirectory.hh"

Expand All @@ -36,6 +37,9 @@ class TestTempDirectory : public ignition::common::TempDirectory
}
};

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include "ignition/common/PluginLoader.hh"

/////////////////////////////////////////////////
TEST(PluginLoader, InitialNoInterfacesImplemented)
{
Expand Down Expand Up @@ -94,3 +98,4 @@ TEST(PluginLoader, InstantiateUnloadedPlugin)
pm.Instantiate("plugin::that::is::not::loaded");
EXPECT_FALSE(plugin);
}
IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
3 changes: 2 additions & 1 deletion src/PluginUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define IGNITION_COMMON_PLUGINUTILS_HH_

#include <string>
#include "ignition/common/Export.hh"
#include "ignition/common/StringUtils.hh"

namespace ignition
Expand All @@ -28,7 +29,7 @@ namespace ignition
/// \brief Format the name to start with "::"
/// \param[in] _name The name of a plugin or interface
/// \return The input, but with "::" prepended if it was not there already.
inline std::string NormalizeName(const std::string &_name)
inline std::string IGN_DEPRECATED(5) NormalizeName(const std::string &_name)
{
std::string name = _name;
if (!StartsWith(_name, "::"))
Expand Down
3 changes: 3 additions & 0 deletions src/PluginUtils_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
*/
#include <gtest/gtest.h>
#include <string>
#include "gz/utils/SuppressWarning.hh"

#include "PluginUtils.hh"

using namespace ignition;

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
/////////////////////////////////////////////////
TEST(PluginUtils, NormalizeName)
{
Expand All @@ -33,3 +35,4 @@ TEST(PluginUtils, NormalizeName)
EXPECT_EQ("::ignition::math", common::NormalizeName("ignition::math"));
EXPECT_EQ("::ignition::math", common::NormalizeName("::ignition::math"));
}
IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
10 changes: 7 additions & 3 deletions test/integration/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@
#include <iostream>
#include "ignition/common/Console.hh"
#include "ignition/common/Filesystem.hh"
#include "ignition/common/PluginLoader.hh"
#include "ignition/common/SystemPaths.hh"
#include "ignition/common/PluginPtr.hh"
#include "ignition/common/SpecializedPluginPtr.hh"
#include "gz/utils/SuppressWarning.hh"

#include "DummyPluginsPath.h"
#include "plugins/DummyPlugins.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include "ignition/common/PluginLoader.hh"
#include "ignition/common/PluginPtr.hh"
#include "ignition/common/SpecializedPluginPtr.hh"

/////////////////////////////////////////////////
TEST(PluginLoader, LoadBadPlugins)
{
Expand Down Expand Up @@ -434,3 +437,4 @@ TEST(PluginPtr, QueryInterfaceSharedPtr)
SetSomeValues(setter);
CheckSomeValues(getInt, getDouble, getName);
}
IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
11 changes: 9 additions & 2 deletions test/performance/plugin_specialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@
#include <iomanip>
#include <cmath>

#include "ignition/common/PluginLoader.hh"
#include "gz/utils/SuppressWarning.hh"

#include "ignition/common/SystemPaths.hh"
#include "ignition/common/SpecializedPluginPtr.hh"
#include "ignition/common/Console.hh"

#include "DummyPluginsPath.h"
#include "plugins/DummyPlugins.hh"


IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include "ignition/common/PluginLoader.hh"
#include "ignition/common/SpecializedPluginPtr.hh"


#define IGN_CREATE_SPEC_INTERFACE(name)\
class name { public: IGN_COMMON_SPECIALIZE_INTERFACE(name) };

Expand Down Expand Up @@ -227,3 +232,5 @@ TEST(PluginSpecialization, AccessTime)
<< "ns\n" << std::endl;
}
}

IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
5 changes: 5 additions & 0 deletions test/plugins/BadPluginAPIVersionNew.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

#include <limits>
#include "ignition/common/PluginMacros.hh"
#include "gz/utils/SuppressWarning.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION

extern "C" {
std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONPluginInfoSize =
Expand All @@ -35,3 +38,5 @@ extern "C" std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONMultiPluginInfo(
return 0u;
}

IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

4 changes: 4 additions & 0 deletions test/plugins/BadPluginAPIVersionOld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/

#include "ignition/common/PluginMacros.hh"
#include "gz/utils/SuppressWarning.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION

extern "C" {
std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONPluginInfoSize =
Expand All @@ -33,3 +36,4 @@ extern "C" std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONMultiPluginInfo(
return 0u;
}

IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
4 changes: 4 additions & 0 deletions test/plugins/BadPluginAlign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/

#include "ignition/common/PluginMacros.hh"
#include "gz/utils/SuppressWarning.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION

extern "C" {
std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONPluginInfoSize =
Expand All @@ -34,3 +37,4 @@ extern "C" std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONMultiPluginInfo(
return 0u;
}

IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
4 changes: 4 additions & 0 deletions test/plugins/BadPluginSize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/

#include "ignition/common/PluginMacros.hh"
#include "gz/utils/SuppressWarning.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION

extern "C" {
std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONPluginInfoSize =
Expand All @@ -34,3 +37,4 @@ extern "C" std::size_t DETAIL_IGN_PLUGIN_VISIBLE IGNCOMMONMultiPluginInfo(
return 0u;
}

IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
4 changes: 4 additions & 0 deletions test/plugins/DummyPlugins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*/

#include "ignition/common/PluginMacros.hh"
#include "gz/utils/SuppressWarning.hh"
#include "DummyPlugins.hh"

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION

namespace test
{
Expand Down Expand Up @@ -87,3 +89,5 @@ IGN_COMMON_BEGIN_ADDING_PLUGINS
IGN_COMMON_ADD_PLUGIN(test::util::DummyMultiPlugin, test::util::DummySetterBase)
IGN_COMMON_ADD_PLUGIN(test::util::DummyMultiPlugin, test::util::DummyGetSomeObjectBase)
IGN_COMMON_FINISH_ADDING_PLUGINS

IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
4 changes: 4 additions & 0 deletions test/static_assertions/plugin_bad_const_assignment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*
*/

#include <gz/utils/SuppressWarning.hh>

IGN_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include "ignition/common/PluginPtr.hh"

int main()
Expand All @@ -23,3 +26,4 @@ int main()
ignition::common::PluginPtr ptr;
ptr = const_ptr;
}
IGN_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
Loading

0 comments on commit 1e626ed

Please sign in to comment.