mn::container::basic_shared_list< T, TLockType > Class Template Reference

A simple list of shared_ptr items. More...

#include <mn_shared_list.hpp>

+ Inheritance diagram for mn::container::basic_shared_list< T, TLockType >:
+ Collaboration diagram for mn::container::basic_shared_list< T, TLockType >:

Public Types

using self_type = basic_shared_list< T, TLockType >
 
using lock_type = TLockType
 
using pointer_type = pointer::shared_atomic_ptr< T >
 
using value_type = typename base_type::value_type
 
using reference = typename base_type::value_type &
 
using const_reference = const typename base_type::value_type &
 
using pointer = typename base_type::value_type *
 
using const_pointer = const typename base_type::value_type *
 
using allocator_type = typename base_type::allocator_type
 
using size_type = typename base_type::size_type
 
using node_type = typename base_type::node_type
 
using deleter = typename base_type::deleter
 
using iterator = typename base_type::iterator
 
using const_iterator = typename base_type::const_iterator
 
- Public Types inherited from mn::container::basic_list< T, TAllocator, TDeleter >
using self_type = basic_list< T, TAllocator, TDeleter >
 
using value_type = T
 
using allocator_type = TAllocator
 
using size_type = mn::size_t
 
using node_type = basic_node< T >
 
using deleter = TDeleter
 
using iterator = list_node_iterator< node_type *, const value_type *, const value_type & >
 
using const_iterator = list_node_iterator< const node_type *, const value_type *, const value_type & >
 

Public Member Functions

 basic_shared_list (const allocator_type &allocator=allocator_type())
 Creates a basic_shared_list with no elements. More...
 
 basic_shared_list (lock_type &lLock, const allocator_type &allocator=allocator_type()) noexcept
 Creates a basic_shared_list with no elements. More...
 
template<class InputIterator >
 basic_shared_list (InputIterator first, InputIterator last, const allocator_type &allocator=allocator_type()) noexcept
 Builds a basic_shared_list from a range. More...
 
 basic_shared_list (const basic_shared_list &rhs) noexcept
 Construct a new basic shared list object. More...
 
iterator begin_save (unsigned long xTicksToWait=portMAX_DELAY)
 Get the read/write iterator that points to the first element from the list. More...
 
const_iterator begin_save () const
 Get the read/write iterator that points to the first element from the list. More...
 
iterator end_save (unsigned long xTicksToWait=portMAX_DELAY)
 Get the read/write iterator that points to the last element from the list. More...
 
const_iterator end_save (unsigned long xTicksToWait=portMAX_DELAY) const
 Get the read/write iterator that points to the last element from the list. More...
 
const_reference front_save (unsigned long xTicksToWait=portMAX_DELAY) const
 Get a read/write reference to the data at the first element. More...
 
reference front_save ()
 Get a read/write reference to the data at the first element . More...
 
const_reference back_save (unsigned long xTicksToWait=portMAX_DELAY) const
 Get a read/write reference to the data at the last element. More...
 
reference back_save (unsigned long xTicksToWait=portMAX_DELAY)
 Get a read/write reference to the data at the last element. More...
 
void push_front_save (pointer pValue, unsigned long xTicksToWait=portMAX_DELAY)
 Add data to the front of the list. More...
 
void push_back_save (pointer pValue, unsigned long xTicksToWait=portMAX_DELAY)
 Add data to the back of the list. More...
 
void push_front_save (pointer_type pValue, unsigned long xTicksToWait=portMAX_DELAY)
 Add data to the front of the list. More...
 
void push_back_save (pointer_type pValue, unsigned long xTicksToWait=portMAX_DELAY)
 Add data to the back of the list. More...
 
void pop_back_save (unsigned long xTicksToWait=portMAX_DELAY)
 Removes last element. More...
 
void pop_front_save (unsigned long xTicksToWait=portMAX_DELAY)
 Removes first element. More...
 
iterator insert (iterator pos, pointer value, unsigned long xTicksToWait=portMAX_DELAY)
 Inserts given value into the list before specified iterator. More...
 
iterator insert_save (iterator pos, pointer_type value, unsigned long xTicksToWait=portMAX_DELAY)
 Inserts given value into the list before specified iterator. More...
 
iterator erase_save (iterator it, unsigned long xTicksToWait=portMAX_DELAY)
 remove given value into the list before specified iterator. More...
 
iterator erase_save (iterator first, iterator last, unsigned long xTicksToWait=portMAX_DELAY)
 Remove a range of elements. More...
 
base_typelist (unsigned long xTicksToWait=portMAX_DELAY) noexcept
 Get the used list of this object. More...
 
const base_typelist (unsigned long xTicksToWait=portMAX_DELAY) const noexcept
 Get the used list of this object. More...
 
int lock (unsigned long xTicksToWait=portMAX_DELAY)
 Lock this object. More...
 
int unlock ()
 Unlock this object. More...
 
- Public Member Functions inherited from mn::container::basic_list< T, TAllocator, TDeleter >
 basic_list (const allocator_type &allocator=allocator_type())
 Construct a new basic list object. More...
 
template<class InputIterator >
 basic_list (InputIterator first, InputIterator last, const allocator_type &allocator=allocator_type())
 Construct a new basic list object. More...
 
 basic_list (const basic_list &rhs)
 Construct a new basic list object. More...
 
 ~basic_list ()
 Destroy the basic list object. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
const T & front () const
 
T & front ()
 
const T & back () const
 
T & back ()
 
void push_front (const T &value)
 
void pop_front ()
 
void push_back (const T &value)
 
void pop_back ()
 
iterator insert (iterator pos, const T &value)
 
iterator erase (iterator it)
 
iterator erase (iterator first, iterator last)
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 
bool empty () const
 
void clear ()
 
size_type size () const
 
allocator_typeget_allocator () noexcept
 
deleter_type & get_deleter () noexcept
 
void set_allocator (const allocator_type &allocator)
 
basic_listoperator= (const basic_list &rhs)
 

Protected Attributes

lock_type m_lockObject
 The lock object. More...
 

Private Types

using base_type = list< pointer::shared_atomic_ptr< T > >
 The base type of this object. More...
 

Additional Inherited Members

- Static Public Attributes inherited from mn::container::basic_list< T, TAllocator, TDeleter >
static const size_type NodeSize = sizeof(node_type)
 

Detailed Description

template<typename T, typename TLockType = mn::mutex_t>
class mn::container::basic_shared_list< T, TLockType >

A simple list of shared_ptr items.

Template Parameters
TThe type for an element.
TLockTypeType of the lock object.
Note
Only thread safe when you use all functions with end with _save. For example: insert_save(..) or push_back_save(..)

Member Typedef Documentation

◆ allocator_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::allocator_type = typename base_type::allocator_type

◆ base_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::base_type = list< pointer::shared_atomic_ptr<T> >
private

The base type of this object.

◆ const_iterator

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::const_iterator = typename base_type::const_iterator

◆ const_pointer

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::const_pointer = const typename base_type::value_type*

◆ const_reference

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::const_reference = const typename base_type::value_type&

◆ deleter

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::deleter = typename base_type::deleter

◆ iterator

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::iterator = typename base_type::iterator

◆ lock_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::lock_type = TLockType

◆ node_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::node_type = typename base_type::node_type

◆ pointer

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::pointer = typename base_type::value_type*

◆ pointer_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::pointer_type = pointer::shared_atomic_ptr<T>

◆ reference

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::reference = typename base_type::value_type&

◆ self_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::self_type = basic_shared_list<T, TLockType>

◆ size_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::size_type = typename base_type::size_type

◆ value_type

template<typename T , typename TLockType = mn::mutex_t>
using mn::container::basic_shared_list< T, TLockType >::value_type = typename base_type::value_type

Constructor & Destructor Documentation

◆ basic_shared_list() [1/4]

template<typename T , typename TLockType = mn::mutex_t>
mn::container::basic_shared_list< T, TLockType >::basic_shared_list ( const allocator_type allocator = allocator_type())
inline

Creates a basic_shared_list with no elements.

◆ basic_shared_list() [2/4]

template<typename T , typename TLockType = mn::mutex_t>
mn::container::basic_shared_list< T, TLockType >::basic_shared_list ( lock_type lLock,
const allocator_type allocator = allocator_type() 
)
inlinenoexcept

Creates a basic_shared_list with no elements.

Parameters
lLockReference of the lock object.

◆ basic_shared_list() [3/4]

template<typename T , typename TLockType = mn::mutex_t>
template<class InputIterator >
mn::container::basic_shared_list< T, TLockType >::basic_shared_list ( InputIterator  first,
InputIterator  last,
const allocator_type allocator = allocator_type() 
)
inlinenoexcept

Builds a basic_shared_list from a range.

Parameters
firstAn input iterator.
lastAn input iterator.
allocatorAn allocator object.

Create a basic_shared_list consisting of copies of the elements from [@afirst,@alast).

◆ basic_shared_list() [4/4]

template<typename T , typename TLockType = mn::mutex_t>
mn::container::basic_shared_list< T, TLockType >::basic_shared_list ( const basic_shared_list< T, TLockType > &  rhs)
inlinenoexcept

Construct a new basic shared list object.

Member Function Documentation

◆ back_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
reference mn::container::basic_shared_list< T, TLockType >::back_save ( unsigned long  xTicksToWait = portMAX_DELAY)
inline

Get a read/write reference to the data at the last element.

Returns
A read/write reference to the data at the last element.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ back_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
const_reference mn::container::basic_shared_list< T, TLockType >::back_save ( unsigned long  xTicksToWait = portMAX_DELAY) const
inline

Get a read/write reference to the data at the last element.

Returns
A read/write reference to the data at the last element.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ begin_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
const_iterator mn::container::basic_shared_list< T, TLockType >::begin_save ( ) const
inline

Get the read/write iterator that points to the first element from the list.

Returns
The read/write iterator that points to the first element from the list.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ begin_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
iterator mn::container::basic_shared_list< T, TLockType >::begin_save ( unsigned long  xTicksToWait = portMAX_DELAY)
inline

Get the read/write iterator that points to the first element from the list.

Returns
The read/write iterator that points to the first element from the list.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ end_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
iterator mn::container::basic_shared_list< T, TLockType >::end_save ( unsigned long  xTicksToWait = portMAX_DELAY)
inline

Get the read/write iterator that points to the last element from the list.

Returns
The read/write iterator that points to the last element from the list.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ end_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
const_iterator mn::container::basic_shared_list< T, TLockType >::end_save ( unsigned long  xTicksToWait = portMAX_DELAY) const
inline

Get the read/write iterator that points to the last element from the list.

Returns
The read/write iterator that points to the last element from the list.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ erase_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
iterator mn::container::basic_shared_list< T, TLockType >::erase_save ( iterator  first,
iterator  last,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Remove a range of elements.

Parameters
firstIterator pointing to the first element to be erased.
lastIterator pointing to one past the last element to be
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
An iterator pointing to the element pointed to by last prior to erasing (or end()).

◆ erase_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
iterator mn::container::basic_shared_list< T, TLockType >::erase_save ( iterator  it,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

remove given value into the list before specified iterator.

Parameters
itAn iterator into the list.
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
An iterator pointing to the next element (or end()).

◆ front_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
reference mn::container::basic_shared_list< T, TLockType >::front_save ( )
inline

Get a read/write reference to the data at the first element .

Returns
A read/write reference to the data at the first element.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ front_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
const_reference mn::container::basic_shared_list< T, TLockType >::front_save ( unsigned long  xTicksToWait = portMAX_DELAY) const
inline

Get a read/write reference to the data at the first element.

Returns
A read/write reference to the data at the first element.
Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ insert()

template<typename T , typename TLockType = mn::mutex_t>
iterator mn::container::basic_shared_list< T, TLockType >::insert ( iterator  pos,
pointer  value,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Inserts given value into the list before specified iterator.

Parameters
posAn iterator into the list.
valueData to be inserted.
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
An iterator that points to the inserted data.

◆ insert_save()

template<typename T , typename TLockType = mn::mutex_t>
iterator mn::container::basic_shared_list< T, TLockType >::insert_save ( iterator  pos,
pointer_type  value,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Inserts given value into the list before specified iterator.

Parameters
posAn iterator into the list.
valueData to be inserted.
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
An iterator that points to the inserted data.

◆ list() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
const base_type& mn::container::basic_shared_list< T, TLockType >::list ( unsigned long  xTicksToWait = portMAX_DELAY) const
inlinenoexcept

Get the used list of this object.

Parameters
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
The list.

◆ list() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
base_type& mn::container::basic_shared_list< T, TLockType >::list ( unsigned long  xTicksToWait = portMAX_DELAY)
inlinenoexcept

Get the used list of this object.

Parameters
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
The list.

◆ lock()

template<typename T , typename TLockType = mn::mutex_t>
int mn::container::basic_shared_list< T, TLockType >::lock ( unsigned long  xTicksToWait = portMAX_DELAY)
inline

Lock this object.

Parameters
xTicksToWaitHow long to wait to get the lock until giving up.
Returns
The error code from the using lock object.

◆ pop_back_save()

template<typename T , typename TLockType = mn::mutex_t>
void mn::container::basic_shared_list< T, TLockType >::pop_back_save ( unsigned long  xTicksToWait = portMAX_DELAY)
inline

Removes last element.

Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ pop_front_save()

template<typename T , typename TLockType = mn::mutex_t>
void mn::container::basic_shared_list< T, TLockType >::pop_front_save ( unsigned long  xTicksToWait = portMAX_DELAY)
inline

Removes first element.

Parameters
xTicksToWaitHow long to wait to get the lock until giving up.

◆ push_back_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
void mn::container::basic_shared_list< T, TLockType >::push_back_save ( pointer  pValue,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Add data to the back of the list.

Parameters
pValueData to be added.
xTicksToWaitHow long to wait to get the lock until giving up.

◆ push_back_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
void mn::container::basic_shared_list< T, TLockType >::push_back_save ( pointer_type  pValue,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Add data to the back of the list.

Parameters
pValueData to be added.
xTicksToWaitHow long to wait to get the lock until giving up.

◆ push_front_save() [1/2]

template<typename T , typename TLockType = mn::mutex_t>
void mn::container::basic_shared_list< T, TLockType >::push_front_save ( pointer  pValue,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Add data to the front of the list.

Parameters
pValueData to be added.
xTicksToWaitHow long to wait to get the lock until giving up.

◆ push_front_save() [2/2]

template<typename T , typename TLockType = mn::mutex_t>
void mn::container::basic_shared_list< T, TLockType >::push_front_save ( pointer_type  pValue,
unsigned long  xTicksToWait = portMAX_DELAY 
)
inline

Add data to the front of the list.

Parameters
pValueData to be added.
xTicksToWaitHow long to wait to get the lock until giving up.

◆ unlock()

template<typename T , typename TLockType = mn::mutex_t>
int mn::container::basic_shared_list< T, TLockType >::unlock ( )
inline

Unlock this object.

Returns
The error code from the using lock object.

Member Data Documentation

◆ m_lockObject

template<typename T , typename TLockType = mn::mutex_t>
lock_type mn::container::basic_shared_list< T, TLockType >::m_lockObject
protected

The lock object.


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