OpenWalnut  1.5.0dev
Public Types | Public Member Functions | List of all members
WSharedAssociativeContainer< T > Class Template Reference

This class provides a common interface for thread-safe access to associative containers (set, multiset, map, multimap). More...

#include <WSharedAssociativeContainer.h>

+ Inheritance diagram for WSharedAssociativeContainer< T >:
+ Collaboration diagram for WSharedAssociativeContainer< T >:

Public Types

typedef T::const_iterator ConstIterator
 A typedef for the correct const iterator useful to traverse this sequence container. More...
 
typedef T::iterator Iterator
 A typedef for the correct iterator to traverse this sequence container. More...
 
typedef T::value_type value_type
 The type of the elements. More...
 
typedef T::key_type key_type
 The type of the key used in this associative container. More...
 
- Public Types inherited from WSharedObject< T >
typedef T ValueT
 The type protected by this shared object class. More...
 
typedef std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
 Type for read tickets. More...
 
typedef std::shared_ptr< WSharedObjectTicketWrite< T > > WriteTicket
 Type for write tickets. More...
 
typedef std::shared_ptr< WSharedObject< T > > SPtr
 Shared pointer abbreviation. More...
 
typedef std::shared_ptr< WSharedObject< T > > ConstSPtr
 Const shared ptr abbreviation. More...
 

Public Member Functions

 WSharedAssociativeContainer ()
 Default constructor. More...
 
virtual ~WSharedAssociativeContainer ()
 Destructor. More...
 
void clear ()
 Clears the container. More...
 
bool empty () const
 Return true if the container is empty. More...
 
size_t size () const
 The current size of the container. More...
 
size_t max_size () const
 The maximum size of a container. More...
 
size_t count (const key_type &x) const
 Count elements with a specific key. More...
 
size_t erase (const key_type &x)
 Erases the element with the specified key. More...
 
std::pair< Iterator, bool > insert (const value_type &x)
 Inserts the specified element. More...
 
- Public Member Functions inherited from WSharedObject< T >
 WSharedObject ()
 Default constructor. More...
 
virtual ~WSharedObject ()
 Destructor. More...
 
ReadTicket getReadTicket () const
 Returns a ticket to get read access to the contained data. More...
 
WriteTicket getWriteTicket (bool suppressNotify=false) const
 Returns a ticket to get write access to the contained data. More...
 
std::shared_ptr< WConditiongetChangeCondition () const
 This condition fires whenever the encapsulated object changed. More...
 

Additional Inherited Members

- Protected Attributes inherited from WSharedObject< T >
m_object
 The object wrapped by this class. More...
 
std::shared_ptr< std::shared_mutex > m_lock
 The lock to ensure thread safe access. More...
 
std::shared_ptr< WConditionm_changeCondition
 This condition set fires whenever the contained object changes. More...
 

Detailed Description

template<typename T>
class WSharedAssociativeContainer< T >

This class provides a common interface for thread-safe access to associative containers (set, multiset, map, multimap).

Definition at line 38 of file WSharedAssociativeContainer.h.

Member Typedef Documentation

◆ ConstIterator

template<typename T >
typedef T::const_iterator WSharedAssociativeContainer< T >::ConstIterator

A typedef for the correct const iterator useful to traverse this sequence container.

Definition at line 46 of file WSharedAssociativeContainer.h.

◆ Iterator

template<typename T >
typedef T::iterator WSharedAssociativeContainer< T >::Iterator

A typedef for the correct iterator to traverse this sequence container.

Definition at line 51 of file WSharedAssociativeContainer.h.

◆ key_type

template<typename T >
typedef T::key_type WSharedAssociativeContainer< T >::key_type

The type of the key used in this associative container.

Definition at line 61 of file WSharedAssociativeContainer.h.

◆ value_type

template<typename T >
typedef T::value_type WSharedAssociativeContainer< T >::value_type

The type of the elements.

Definition at line 56 of file WSharedAssociativeContainer.h.

Constructor & Destructor Documentation

◆ WSharedAssociativeContainer()

Default constructor.

Definition at line 131 of file WSharedAssociativeContainer.h.

◆ ~WSharedAssociativeContainer()

template<typename T >
WSharedAssociativeContainer< T >::~WSharedAssociativeContainer
virtual

Destructor.

Definition at line 138 of file WSharedAssociativeContainer.h.

Member Function Documentation

◆ clear()

template<typename T >
void WSharedAssociativeContainer< T >::clear

Clears the container.

Definition at line 144 of file WSharedAssociativeContainer.h.

References WSharedAssociativeContainer< T >::clear(), and WSharedObject< T >::getWriteTicket().

Referenced by WSharedAssociativeContainer< T >::clear().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ count()

template<typename T >
size_t WSharedAssociativeContainer< T >::count ( const key_type x) const

Count elements with a specific key.

The sense and non-sense of this method in a multi threaded environment is questionable.

Parameters
xthe key
Returns
the count, 0 if none found.

Definition at line 172 of file WSharedAssociativeContainer.h.

References WSharedAssociativeContainer< T >::count(), and WSharedObject< T >::getReadTicket().

Referenced by WSharedAssociativeContainer< T >::count().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty()

template<typename T >
bool WSharedAssociativeContainer< T >::empty

Return true if the container is empty.

The sense and non-sense of this method in a multi threaded environment is questionable.

Returns
true if empty

Definition at line 151 of file WSharedAssociativeContainer.h.

References WSharedAssociativeContainer< T >::empty(), and WSharedObject< T >::getReadTicket().

Referenced by WSharedAssociativeContainer< T >::empty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ erase()

template<typename T >
size_t WSharedAssociativeContainer< T >::erase ( const key_type x)

Erases the element with the specified key.

Parameters
xthe key
Returns
the number of elements erased

Definition at line 179 of file WSharedAssociativeContainer.h.

References WSharedAssociativeContainer< T >::erase(), and WSharedObject< T >::getWriteTicket().

Referenced by WSharedAssociativeContainer< T >::erase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

template<typename T >
std::pair< typename WSharedAssociativeContainer< T >::Iterator, bool > WSharedAssociativeContainer< T >::insert ( const value_type x)

Inserts the specified element.

Parameters
xthe element to add
Returns
a pair containing the Iterator pointing to the inserted element and the bool is true if the element not existed before.

Definition at line 186 of file WSharedAssociativeContainer.h.

References WSharedObject< T >::getWriteTicket(), and WSharedAssociativeContainer< T >::insert().

Referenced by WGEColormapping::applyInst(), WModuleFactory::create(), and WSharedAssociativeContainer< T >::insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ max_size()

template<typename T >
size_t WSharedAssociativeContainer< T >::max_size

The maximum size of a container.

Returns
the maximum size

Definition at line 165 of file WSharedAssociativeContainer.h.

References WSharedObject< T >::getReadTicket(), and WSharedAssociativeContainer< T >::max_size().

Referenced by WSharedAssociativeContainer< T >::max_size().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

template<typename T >
size_t WSharedAssociativeContainer< T >::size

The current size of the container.

0 if empty. The sense and non-sense of this method in a multi threaded environment is questionable.

Returns
the size.

Definition at line 158 of file WSharedAssociativeContainer.h.

References WSharedObject< T >::getReadTicket(), and WSharedAssociativeContainer< T >::size().

Referenced by WSharedAssociativeContainer< T >::size().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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