state-observation 1.8.0
General implementation of observers.
Loading...
Searching...
No Matches
stateObservation::measurements::ContactsManager< ContactT > Struct Template Reference

Structure that implements all the necessary functions to manage the map of contacts. Handles their detection and updates the list of the detected contacts, newly removed contacts, etc., to apply the appropriate functions on them. More...

#include <ContactsManager.hpp>

Collaboration diagram for stateObservation::measurements::ContactsManager< ContactT >:
[legend]

Public Member Functions

template<typename OnNewContact, typename OnMaintainedContact, typename OnRemovedContact, typename OnAddedContact = std::nullptr_t>
void updateContacts (const std::set< std::string > &latestContactList, OnNewContact onNewContact, OnMaintainedContact onMaintainedContact, OnRemovedContact onRemovedContact, OnAddedContact onAddedContact=nullptr)
 Updates the list of contacts to inform whether they are newly set, removed, etc., and execute actions accordingly.
std::unordered_map< std::string, ContactT > & contacts ()
 Get the map of all the contacts.
bool contactsDetected () const noexcept
ContactT * findContact (const std::string &name)
 Accessor for the a contact associated to a surface contained in the map.

Protected Member Functions

template<typename OnAddedContact = std::nullptr_t>
ContactT & addContactToManager (const std::string &name, OnAddedContact onAddedContact=nullptr)
 Insert a contact to the map of contacts.

Protected Attributes

std::unordered_map< std::string, ContactT > listContacts_
std::set< std::string > currentContactsList_
unsigned idx_ = 0
bool contactsDetected_ = false

Detailed Description

template<typename ContactT>
struct stateObservation::measurements::ContactsManager< ContactT >

Structure that implements all the necessary functions to manage the map of contacts. Handles their detection and updates the list of the detected contacts, newly removed contacts, etc., to apply the appropriate functions on them.

The template allows to define other kinds of contacts and thus add custom parameters to them.

Definition at line 18 of file ContactsManager.hpp.

Member Function Documentation

◆ addContactToManager()

template<typename ContactT>
template<typename OnAddedContact = std::nullptr_t>
ContactT & stateObservation::measurements::ContactsManager< ContactT >::addContactToManager ( const std::string & name,
OnAddedContact onAddedContact = nullptr )
protected

Insert a contact to the map of contacts.

Parameters
nameThe name of the contact
onAddedContactfunction to call when a contact is added to the manager
Returns
ContactT &

◆ updateContacts()

template<typename ContactT>
template<typename OnNewContact, typename OnMaintainedContact, typename OnRemovedContact, typename OnAddedContact = std::nullptr_t>
void stateObservation::measurements::ContactsManager< ContactT >::updateContacts ( const std::set< std::string > & latestContactList,
OnNewContact onNewContact,
OnMaintainedContact onMaintainedContact,
OnRemovedContact onRemovedContact,
OnAddedContact onAddedContact = nullptr )

Updates the list of contacts to inform whether they are newly set, removed, etc., and execute actions accordingly.

Parameters
latestContactListSet containing the names of all contacts detected on the latest iteration.
onNewContactFunction to call on a newly detected contact
onMaintainedContactFunction to call on a contact maintainted since the last iteration
onRemovedContactFunction to call on a removed contact
onAddedContactfunction to call when a contact is added to the manager
Returns
void

◆ contacts()

template<typename ContactT>
std::unordered_map< std::string, ContactT > & stateObservation::measurements::ContactsManager< ContactT >::contacts ( )
inline

Get the map of all the contacts.

Returns
std::unordered_map<std::string, ContactT>&

Definition at line 53 of file ContactsManager.hpp.

◆ contactsDetected()

template<typename ContactT>
bool stateObservation::measurements::ContactsManager< ContactT >::contactsDetected ( ) const
inlinenoexcept

Returns true if any contact is detected

Definition at line 59 of file ContactsManager.hpp.

◆ findContact()

template<typename ContactT>
ContactT * stateObservation::measurements::ContactsManager< ContactT >::findContact ( const std::string & name)
inline

Accessor for the a contact associated to a surface contained in the map.

Returns a null pointer if the contact does not exist

Parameters
nameThe name of the contact to access
Returns
ContactT *

Definition at line 69 of file ContactsManager.hpp.

Member Data Documentation

◆ listContacts_

template<typename ContactT>
std::unordered_map<std::string, ContactT> stateObservation::measurements::ContactsManager< ContactT >::listContacts_
protected

Definition at line 81 of file ContactsManager.hpp.

◆ currentContactsList_

template<typename ContactT>
std::set<std::string> stateObservation::measurements::ContactsManager< ContactT >::currentContactsList_
protected

Definition at line 84 of file ContactsManager.hpp.

◆ idx_

template<typename ContactT>
unsigned stateObservation::measurements::ContactsManager< ContactT >::idx_ = 0
protected

Definition at line 87 of file ContactsManager.hpp.

◆ contactsDetected_

template<typename ContactT>
bool stateObservation::measurements::ContactsManager< ContactT >::contactsDetected_ = false
protected

True if any contact is detected, false otherwise

Definition at line 89 of file ContactsManager.hpp.


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