Public Member Functions | Protected Types | Protected Attributes | List of all members
hardware_interface::InterfaceManager Class Reference

Manager for hardware interface registrations. More...

#include <interface_manager.h>

Inheritance diagram for hardware_interface::InterfaceManager:
Inheritance graph
[legend]

Public Member Functions

template<class T >
T * get ()
 Get an interface. More...
 
std::vector< std::string > getInterfaceResources (std::string iface_type) const
 Get the resource names registered to an interface, specified by type. More...
 
std::vector< std::string > getNames () const
 Lists the demangled names of all registered interfaces. More...
 
template<class T >
void registerInterface (T *iface)
 Register an interface. More...
 
void registerInterfaceManager (InterfaceManager *iface_man)
 Register another interface manager. More...
 

Protected Types

typedef std::vector< InterfaceManager * > InterfaceManagerVector
 
typedef std::map< std::string, void * > InterfaceMap
 
typedef std::map< std::string, std::vector< std::string > > ResourceMap
 
typedef std::map< std::string, size_t > SizeMap
 

Protected Attributes

std::vector< ResourceManagerBase * > interface_destruction_list_
 
InterfaceManagerVector interface_managers_
 
InterfaceMap interfaces_
 
InterfaceMap interfaces_combo_
 
SizeMap num_ifaces_registered_
 
ResourceMap resources_
 This will allow us to check the resources based on the demangled type name of the interface. More...
 

Detailed Description

Manager for hardware interface registrations.

This class enables the registration of interfaces based on their class type, handling all the required demangling and storage. The registration ensures the presence of at most one interface instance per type. Accessors for interface listing are provided. Additionally, combinations of interfaces as required in CombinedRobotHW are handled transparently.

Definition at line 122 of file interface_manager.h.

Member Typedef Documentation

◆ InterfaceManagerVector

Definition at line 303 of file interface_manager.h.

◆ InterfaceMap

typedef std::map<std::string, void*> hardware_interface::InterfaceManager::InterfaceMap
protected

Definition at line 302 of file interface_manager.h.

◆ ResourceMap

typedef std::map<std::string, std::vector<std::string> > hardware_interface::InterfaceManager::ResourceMap
protected

Definition at line 305 of file interface_manager.h.

◆ SizeMap

typedef std::map<std::string, size_t> hardware_interface::InterfaceManager::SizeMap
protected

Definition at line 304 of file interface_manager.h.

Member Function Documentation

◆ get()

template<class T >
T* hardware_interface::InterfaceManager::get ( )
inline

Get an interface.

If this class and its registered sub-managers only have one registered instance of the requested interface type, this will be returned. If multiple instances of the interface type were registered and the type is a ResourceManager, this call will try to combine them into a single handle. In all other cases, nullptr will be returned.

Note
As this class can only store one instance of each interface type, the only way multiple instances of the same interface type can be registered is through the registration of sub-managers.
If there are multiple registered interfaces of the requested type and they are not ResourceManager, this method will not be able to combine them and will return nullptr.
Template Parameters
TThe interface type
Returns
A handle for the stored interfaces of type T or nullptr

Definition at line 183 of file interface_manager.h.

◆ getInterfaceResources()

std::vector<std::string> hardware_interface::InterfaceManager::getInterfaceResources ( std::string  iface_type) const
inline

Get the resource names registered to an interface, specified by type.

This will return the list of all registered resources for ResourceManager interfaces and an empty list for all others.

Parameters
iface_typeThe demangled type name of an interface
Returns
A vector of resource names registered to this interface

Definition at line 283 of file interface_manager.h.

◆ getNames()

std::vector<std::string> hardware_interface::InterfaceManager::getNames ( ) const
inline

Lists the demangled names of all registered interfaces.

This includes the interfaces directly registered to this instance and the interfaces registered to registered managers. As multiple interfaces of the same type will get merged on access, duplicates are omitted.

Returns
Vector of demangled interface names of registered interfaces.

Definition at line 250 of file interface_manager.h.

◆ registerInterface()

template<class T >
void hardware_interface::InterfaceManager::registerInterface ( T *  iface)
inline

Register an interface.

This associates the name of the type of interface to be registered with the given pointer.

Note
The registration of an interface will replace previously registered instances of its type
Template Parameters
TThe interface type
Parameters
ifaceA pointer to the interface to store

Definition at line 138 of file interface_manager.h.

◆ registerInterfaceManager()

void hardware_interface::InterfaceManager::registerInterfaceManager ( InterfaceManager iface_man)
inline

Register another interface manager.

This manager will be integrated transparently into all further access methods.

Parameters
iface_manA pointer to the interface manager to store

Definition at line 157 of file interface_manager.h.

Member Data Documentation

◆ interface_destruction_list_

std::vector<ResourceManagerBase*> hardware_interface::InterfaceManager::interface_destruction_list_
protected

Definition at line 311 of file interface_manager.h.

◆ interface_managers_

InterfaceManagerVector hardware_interface::InterfaceManager::interface_managers_
protected

Definition at line 309 of file interface_manager.h.

◆ interfaces_

InterfaceMap hardware_interface::InterfaceManager::interfaces_
protected

Definition at line 307 of file interface_manager.h.

◆ interfaces_combo_

InterfaceMap hardware_interface::InterfaceManager::interfaces_combo_
protected

Definition at line 308 of file interface_manager.h.

◆ num_ifaces_registered_

SizeMap hardware_interface::InterfaceManager::num_ifaces_registered_
protected

Definition at line 310 of file interface_manager.h.

◆ resources_

ResourceMap hardware_interface::InterfaceManager::resources_
protected

This will allow us to check the resources based on the demangled type name of the interface.

Definition at line 313 of file interface_manager.h.


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


hardware_interface
Author(s): Wim Meeussen, Adolfo Rodriguez Tsouroukdissian
autogenerated on Mon Dec 7 2020 03:15:43