Ignition Common

API Reference

4.5.0
SpecializedPlugin< SpecInterface > Class Template Reference

This class allows Plugin instances to have high-speed access to interfaces that can be anticipated at compile time. The plugin does not have to actually offer the specialized interface in order to get this performance improvement. This template is variadic, so it can support arbitrarily many interfaces. More...

#include <SpecializedPlugin.hh>

Public Member Functions

template<class Interface >
bool HasInterface () const
 
template<class Interface >
Interface * QueryInterface ()
 
template<class Interface >
const Interface * QueryInterface () const
 
template<class Interface >
std::shared_ptr< Interface > QueryInterfaceSharedPtr ()
 
template<class Interface >
std::shared_ptr< const Interface > QueryInterfaceSharedPtr () const
 
- Public Member Functions inherited from Plugin
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...
 

Additional Inherited Members

- Public Types inherited from Plugin
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...
 

Detailed Description

template<class SpecInterface>
class ignition::common::SpecializedPlugin< SpecInterface >

This class allows Plugin instances to have high-speed access to interfaces that can be anticipated at compile time. The plugin does not have to actually offer the specialized interface in order to get this performance improvement. This template is variadic, so it can support arbitrarily many interfaces.

Usage example:

using MySpecialPluginPtr = SpecializedPluginPtr<
MyInterface1, FooInterface, MyInterface2, BarInterface>;
MySpecialPluginPtr plugin = loader->Instantiate(pluginName);

Then, calling the function

plugin->QueryInterface<FooInterface>();

will have extremely high-speed associated with it. It will provide direct access to the the FooInterface* of plugin. If plugin does not actually offer FooInterface, then it will return a nullptr, still at extremely high speed.

Only interfaces that have been "specialized" can be passed as arguments to the SpecializedPlugin template. To specialize an interface, simply put the macro IGN_COMMON_SPECIALIZE_INTERFACE(~) from ignition/common/PluginMacros.hh into a public location of its class definition.

Member Function Documentation

◆ HasInterface()

bool HasInterface ( ) const

◆ QueryInterface() [1/2]

Interface* QueryInterface ( )

◆ QueryInterface() [2/2]

const Interface* QueryInterface ( ) const

◆ QueryInterfaceSharedPtr() [1/2]

std::shared_ptr<Interface> QueryInterfaceSharedPtr ( )

◆ QueryInterfaceSharedPtr() [2/2]

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

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