Public Member Functions | Private Attributes | List of all members
BT::LockedPtr< T > Class Template Reference

The LockedPtr class is used to share a pointer to an object and a mutex that protects the read/write access to that object. More...

#include <locked_reference.hpp>

Public Member Functions

template<typename OtherT >
void assign (const OtherT &other)
 
const T * get () const
 
void lock ()
 
 LockedPtr ()=default
 
 LockedPtr (LockedPtr &&other)
 
 LockedPtr (LockedPtr const &)=delete
 
 LockedPtr (T *obj, std::mutex *obj_mutex)
 
 operator bool () const
 
T * operator-> ()
 
const T * operator-> () const
 
LockedPtroperator= (LockedPtr &&other)
 
LockedPtroperator= (LockedPtr const &)=delete
 
void unlock ()
 
 ~LockedPtr ()
 

Private Attributes

std::mutexmutex_ = nullptr
 
T * ref_ = nullptr
 

Detailed Description

template<typename T>
class BT::LockedPtr< T >

The LockedPtr class is used to share a pointer to an object and a mutex that protects the read/write access to that object.

As long as the object remains in scope, the mutex is locked, therefore you must destroy this instance as soon as the pointer was used.

Definition at line 16 of file locked_reference.hpp.

Constructor & Destructor Documentation

◆ LockedPtr() [1/4]

template<typename T >
BT::LockedPtr< T >::LockedPtr ( )
default

◆ LockedPtr() [2/4]

template<typename T >
BT::LockedPtr< T >::LockedPtr ( T *  obj,
std::mutex obj_mutex 
)
inline

Definition at line 21 of file locked_reference.hpp.

◆ ~LockedPtr()

template<typename T >
BT::LockedPtr< T >::~LockedPtr ( )
inline

Definition at line 26 of file locked_reference.hpp.

◆ LockedPtr() [3/4]

template<typename T >
BT::LockedPtr< T >::LockedPtr ( LockedPtr< T > const &  )
delete

◆ LockedPtr() [4/4]

template<typename T >
BT::LockedPtr< T >::LockedPtr ( LockedPtr< T > &&  other)
inline

Definition at line 37 of file locked_reference.hpp.

Member Function Documentation

◆ assign()

template<typename T >
template<typename OtherT >
void BT::LockedPtr< T >::assign ( const OtherT &  other)
inline

Definition at line 86 of file locked_reference.hpp.

◆ get()

template<typename T >
const T* BT::LockedPtr< T >::get ( ) const
inline

Definition at line 70 of file locked_reference.hpp.

◆ lock()

template<typename T >
void BT::LockedPtr< T >::lock ( )
inline

Definition at line 54 of file locked_reference.hpp.

◆ operator bool()

template<typename T >
BT::LockedPtr< T >::operator bool ( ) const
inline

Definition at line 49 of file locked_reference.hpp.

◆ operator->() [1/2]

template<typename T >
T* BT::LockedPtr< T >::operator-> ( )
inline

Definition at line 80 of file locked_reference.hpp.

◆ operator->() [2/2]

template<typename T >
const T* BT::LockedPtr< T >::operator-> ( ) const
inline

Definition at line 75 of file locked_reference.hpp.

◆ operator=() [1/2]

template<typename T >
LockedPtr& BT::LockedPtr< T >::operator= ( LockedPtr< T > &&  other)
inline

Definition at line 43 of file locked_reference.hpp.

◆ operator=() [2/2]

template<typename T >
LockedPtr& BT::LockedPtr< T >::operator= ( LockedPtr< T > const &  )
delete

◆ unlock()

template<typename T >
void BT::LockedPtr< T >::unlock ( )
inline

Definition at line 62 of file locked_reference.hpp.

Member Data Documentation

◆ mutex_

template<typename T >
std::mutex* BT::LockedPtr< T >::mutex_ = nullptr
private

Definition at line 108 of file locked_reference.hpp.

◆ ref_

template<typename T >
T* BT::LockedPtr< T >::ref_ = nullptr
private

Definition at line 107 of file locked_reference.hpp.


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


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:18