Gazebo Common

API Reference

4.7.0
gz/common/PluginMacros.hh File Reference
#include <gz/common/config.hh>
#include "gz/common/detail/PluginMacros.hh"

Go to the source code of this file.

Macros

#define IGN_COMMON_ADD_PLUGIN(plugin, interface)   DETAIL_IGN_COMMON_ADD_PLUGIN(plugin, interface)
 Add a plugin and interface from this shared library. This macro must be called consecutively on each class that this shared library wants to provide as a plugin or interface. This macro must be called in between IGN_COMMON_BEGIN_ADDING_PLUGINS and IGN_COMMON_FINISH_ADDING_PLUGINS. If a plugin provides multiple interfaces, then simply call this macro repeatedly on the plugin, once for each interface. The multiple interfaces will automatically be collapsed into one plugin that provides all of them. More...
 
#define IGN_COMMON_BEGIN_ADDING_PLUGINS   DETAIL_IGN_COMMON_BEGIN_ADDING_PLUGINS
 Begin registering a set of plugins that are contained within this shared library. After invoking this macro, use a sequence of calls to IGN_COMMON_ADD_PLUGIN(~,~), passing in a different plugin and interface name to each call. When all the plugins and interfaces have been added, call IGN_COMMON_FINISH_ADDING_PLUGINS. More...
 
#define IGN_COMMON_FINISH_ADDING_PLUGINS   DETAIL_IGN_COMMON_FINISH_ADDING_PLUGINS
 Call this macro after all calls to IGN_COMMON_ADD_PLUGIN have been finished. More...
 
#define IGN_COMMON_REGISTER_SINGLE_PLUGIN(plugin, interface)
 Register a shared library with only one plugin and one interface. This macro is NOT compatible with IGN_COMMON_ADD_PLUGIN or any of the above macros for adding multiple plugins and/or multiple interfaces. This is simply a convenience function if you want to add one plugin with one interface from your library. More...
 
#define IGN_COMMON_SPECIALIZE_INTERFACE(interfaceName)   DETAIL_IGN_COMMON_SPECIALIZE_INTERFACE(interfaceName)
 Call this macro inside a public scope of an interface in order to get performance benefits for that interface in a SpecializedPlugin. Pass in the fully qualified name of the interface class (i.e. explicitly include the namespaces of the class). More...
 

Macro Definition Documentation

◆ IGN_COMMON_ADD_PLUGIN

#define IGN_COMMON_ADD_PLUGIN (   plugin,
  interface 
)    DETAIL_IGN_COMMON_ADD_PLUGIN(plugin, interface)

Add a plugin and interface from this shared library. This macro must be called consecutively on each class that this shared library wants to provide as a plugin or interface. This macro must be called in between IGN_COMMON_BEGIN_ADDING_PLUGINS and IGN_COMMON_FINISH_ADDING_PLUGINS. If a plugin provides multiple interfaces, then simply call this macro repeatedly on the plugin, once for each interface. The multiple interfaces will automatically be collapsed into one plugin that provides all of them.

◆ IGN_COMMON_BEGIN_ADDING_PLUGINS

#define IGN_COMMON_BEGIN_ADDING_PLUGINS   DETAIL_IGN_COMMON_BEGIN_ADDING_PLUGINS

Begin registering a set of plugins that are contained within this shared library. After invoking this macro, use a sequence of calls to IGN_COMMON_ADD_PLUGIN(~,~), passing in a different plugin and interface name to each call. When all the plugins and interfaces have been added, call IGN_COMMON_FINISH_ADDING_PLUGINS.

Be sure to only use this macro in the global namespace, and only use it once in your library.

◆ IGN_COMMON_FINISH_ADDING_PLUGINS

#define IGN_COMMON_FINISH_ADDING_PLUGINS   DETAIL_IGN_COMMON_FINISH_ADDING_PLUGINS

Call this macro after all calls to IGN_COMMON_ADD_PLUGIN have been finished.

◆ IGN_COMMON_REGISTER_SINGLE_PLUGIN

#define IGN_COMMON_REGISTER_SINGLE_PLUGIN (   plugin,
  interface 
)
Value:
IGN_COMMON_ADD_PLUGIN(plugin, interface)\
IGN_COMMON_FINISH_ADDING_PLUGINS

Register a shared library with only one plugin and one interface. This macro is NOT compatible with IGN_COMMON_ADD_PLUGIN or any of the above macros for adding multiple plugins and/or multiple interfaces. This is simply a convenience function if you want to add one plugin with one interface from your library.

◆ IGN_COMMON_SPECIALIZE_INTERFACE

#define IGN_COMMON_SPECIALIZE_INTERFACE (   interfaceName)    DETAIL_IGN_COMMON_SPECIALIZE_INTERFACE(interfaceName)

Call this macro inside a public scope of an interface in order to get performance benefits for that interface in a SpecializedPlugin. Pass in the fully qualified name of the interface class (i.e. explicitly include the namespaces of the class).

Usage example:

namespace mylibrary {
namespace ns {
class SomeInterface
{
public:
IGN_COMMON_SPECIALIZE_INTERFACE(mylibrary::ns::SomeInterface)
// ... declarations of interface functions ...
};
} // namespace ns
} // namespace mylibrary

Interfaces with this macro can be utilized by SpecializedPlugin to get high-speed access to this type of interface. Note that this performance benefit is available even if the plugin that gets loaded does not offer this interface; you just get high-speed access to a nullptr instead. Always be sure to verify the existence of an interface that you query from a plugin by checking whether it's a nullptr!

#define IGN_COMMON_SPECIALIZE_INTERFACE(interfaceName)
Call this macro inside a public scope of an interface in order to get performance benefits for that i...
Definition: gz/common/PluginMacros.hh:53
#define IGN_COMMON_ADD_PLUGIN(plugin, interface)
Add a plugin and interface from this shared library. This macro must be called consecutively on each ...
Definition: gz/common/PluginMacros.hh:121