Gazebo Common

API Reference

5.7.0

#include <Plugin.hh>

Public Types

using InterfaceMap = std::map< std::string, void * >
 The InterfaceMap type needs to get used in several places, like PluginPrivate and SpecializedPlugin<T>. We make the typedef public so that those other classes can use it without needing to be friends of Plugin. End-users should not have any need for this typedef. More...
 

Public Member Functions

virtual ~Plugin ()
 Virtual destructor. More...
 
template<class Interface >
bool HasInterface () const
 Returns true if this Plugin has the specified type of interface. Note that this function only works when the Interface type is specialized using the macro IGN_COMMON_SPECIALIZE_INTERFACE. For more general interfaces which do not meet this condition, use QueryInterface<Interface>(_interfaceName). More...
 
bool HasInterface (const std::string &_interfaceName) const
 Returns true if this Plugin has the specified type of interface, otherwise returns false. More...
 
template<class Interface >
Interface * QueryInterface ()
 Get an interface of the specified type. Note that this function only works when the Interface type is specialized using the macro IGN_COMMON_SPECIALIZE_INTERFACE. For more general interfaces which do not meet this condition, use QueryInterface<Interface>(_interfaceName). More...
 
template<class Interface >
const Interface * QueryInterface () const
 const-qualified version of QueryInterface<Interface>() More...
 
template<class Interface >
Interface * QueryInterface (const std::string &_interfaceName)
 Get an interface with the given name, casted to the specified class type. The template argument Interface must exactly match the underlying type associated with _interfaceName, or else the behavior of this function is undefined. More...
 
template<class Interface >
const Interface * QueryInterface (const std::string &_interfaceName) const
 const-qualified version of QueryInterface<Interface>(std::string) More...
 
template<class Interface >
std::shared_ptr< Interface > QueryInterfaceSharedPtr ()
 Get the requested interface as a std::shared_ptr. Note that this function only works when the Interface type is specialized using the macro IGN_COMMON_SPECIALIZE_INTERFACE. For more general interfaces which do not meet this condition, use QueryInterfaceSharedPtr<Interface>(const std::string&). More...
 
template<class Interface >
std::shared_ptr< const Interface > QueryInterfaceSharedPtr () const
 Same as QueryInterfaceSharedPtr<Interface>(), but it returns a std::shared_ptr to a const-qualified Interface. More...
 
template<class Interface >
std::shared_ptr< Interface > QueryInterfaceSharedPtr (const std::string &_interfaceName)
 Get the requested interface as a std::shared_ptr. The template argument Interface must exactly match the underlying type associated with _interfaceName, or else the behavior of this function is undefined. More...
 
template<class Interface >
std::shared_ptr< const Interface > QueryInterfaceSharedPtr (const std::string &_interfaceName) const
 Same as QueryInterfaceSharedPtr<Interface>(std::string), but it returns a std::shared_ptr to a const-qualified Interface. More...
 

Member Typedef Documentation

◆ InterfaceMap

The InterfaceMap type needs to get used in several places, like PluginPrivate and SpecializedPlugin<T>. We make the typedef public so that those other classes can use it without needing to be friends of Plugin. End-users should not have any need for this typedef.

Constructor & Destructor Documentation

◆ ~Plugin()

virtual ~Plugin ( )
virtual

Virtual destructor.

Member Function Documentation

◆ HasInterface() [1/2]

bool HasInterface ( ) const

Returns true if this Plugin has the specified type of interface. Note that this function only works when the Interface type is specialized using the macro IGN_COMMON_SPECIALIZE_INTERFACE. For more general interfaces which do not meet this condition, use QueryInterface<Interface>(_interfaceName).

◆ HasInterface() [2/2]

bool HasInterface ( const std::string _interfaceName) const

Returns true if this Plugin has the specified type of interface, otherwise returns false.

Parameters
[in]_interfaceNameThe name of the desired interface, as a string.

◆ QueryInterface() [1/4]

Interface* QueryInterface ( )

Get an interface of the specified type. Note that this function only works when the Interface type is specialized using the macro IGN_COMMON_SPECIALIZE_INTERFACE. For more general interfaces which do not meet this condition, use QueryInterface<Interface>(_interfaceName).

Note that the interface pointer you receive is owned by the Plugin object. You MUST NOT ever try to deallocate it yourself. Moreover, the pointer will be invalidated once all Plugin objects that refer to the same Plugin instance are destructed. Use the QueryInterfaceSharedPtr function in order to get a reference-counting pointer to an interface of this Plugin object. The pointer will remain valid as long as the std::shared_ptr provided by QueryInterfaceSharedPtr is alive.

◆ QueryInterface() [2/4]

const Interface* QueryInterface ( ) const

const-qualified version of QueryInterface<Interface>()

◆ QueryInterface() [3/4]

Interface* QueryInterface ( const std::string _interfaceName)

Get an interface with the given name, casted to the specified class type. The template argument Interface must exactly match the underlying type associated with _interfaceName, or else the behavior of this function is undefined.

Note that the interface pointer you receive is owned by the Plugin object. You MUST NOT ever try to deallocate it yourself. Moreover, the pointer will be invalidated once all Plugin objects that refer to the same Plugin instance are destructed. Use the QueryInterfaceSharedPtr function in order to get a reference-counting pointer to an interface of this Plugin object. The pointer will remain valid as long as the std::shared_ptr provided by QueryInterfaceSharedPtr is alive.

Parameters
[in]_interfaceNameThe name of the desired interface, as a string.
Returns
A raw pointer to the specified interface. If the requested _interfaceName is not provided by this Plugin, this returns a nullptr. This pointer is invalidated when the reference count of the plugin instance drops to zero.

◆ QueryInterface() [4/4]

const Interface* QueryInterface ( const std::string _interfaceName) const

const-qualified version of QueryInterface<Interface>(std::string)

◆ QueryInterfaceSharedPtr() [1/4]

std::shared_ptr<Interface> QueryInterfaceSharedPtr ( )

Get the requested interface as a std::shared_ptr. Note that this function only works when the Interface type is specialized using the macro IGN_COMMON_SPECIALIZE_INTERFACE. For more general interfaces which do not meet this condition, use QueryInterfaceSharedPtr<Interface>(const std::string&).

◆ QueryInterfaceSharedPtr() [2/4]

std::shared_ptr<const Interface> QueryInterfaceSharedPtr ( ) const

Same as QueryInterfaceSharedPtr<Interface>(), but it returns a std::shared_ptr to a const-qualified Interface.

◆ QueryInterfaceSharedPtr() [3/4]

std::shared_ptr<Interface> QueryInterfaceSharedPtr ( const std::string _interfaceName)

Get the requested interface as a std::shared_ptr. The template argument Interface must exactly match the underlying type associated with _interfaceName, or else the behavior of this function is undefined.

This std::shared_ptr and the interface+plugin that it refers to will remain valid, even if all Plugin objects which refer to the plugin instance are destructed.

You MUST NOT attempt to pass a QueryInterface pointer into a std::shared_ptr yourself; that will result in double-delete memory errors. You must always call QueryInterfaceSharedPtr for a reference- counting pointer to an interface.

Parameters
[in]_interfaceNameThe name of the desired interface, as a string.
Returns
A reference-counting pointer to the specified interface. This will keep the interface valid and the plugin instance alive, even if all Plugin objects that refer to this plugin instance are destructed.

◆ QueryInterfaceSharedPtr() [4/4]

std::shared_ptr<const Interface> QueryInterfaceSharedPtr ( const std::string _interfaceName) const

Same as QueryInterfaceSharedPtr<Interface>(std::string), but it returns a std::shared_ptr to a const-qualified Interface.


The documentation for this class was generated from the following file:
>
The documentation for this class was generated from the following file: