YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
WeakPtrCache< T > Class Template Referenceabstract

Template for a cache of weak_ptr's to objects. More...

#include <WeakPtrCache.h>

Public Types

helper types
using type = T
 object_type
 
using shared_ptr_type = std::shared_ptr< T >
 std::shared_ptr to T More...
 
using weak_ptr_type = std::weak_ptr< T >
 std::weak_ptr to T More...
 
using cache_type = std::set< weak_ptr_type, std::owner_less< weak_ptr_type > >
 A std::set of weak_ptr_type. More...
 

Public Member Functions

virtual bool equal (const shared_ptr_type &A, const shared_ptr_type &B) const =0
 override to implement equality checking
 
weak_ptr_type find (shared_ptr_type t) const
 
shared_ptr_type operator[] (shared_ptr_type t)
 
bool empty () const
 
size_t size () const
 
size_t count_expired () const
 
void removeExpired ()
 remove expired Cache_ elements
 
virtual std::ostream & print (std::ostream &os) const
 stream the cache elements as a table
 
constructors and assignment operators
 WeakPtrCache ()=default
 Default constructor (defaulted)
 
 WeakPtrCache (const WeakPtrCache &)=default
 copy constructor (defaulted)
 
 WeakPtrCache (WeakPtrCache &&)=default
 move constructor (defaulted)
 
 WeakPtrCache (std::vector< shared_ptr_type > V)
 Construct cache from vector.
 
virtual ~WeakPtrCache ()=default
 virtual desctructor (defaulted)
 
WeakPtrCacheoperator= (const WeakPtrCache &)=default
 copy assignment operator (defaulted)
 
WeakPtrCacheoperator= (WeakPtrCache &&)=default
 move assignment operator (defaulted)
 
access to cache
cache_type::iterator begin ()
 
cache_type::const_iterator begin () const
 
cache_type::iterator end ()
 
cache_type::const_iterator end () const
 

Protected Member Functions

virtual void addToCache (shared_ptr_type t)
 add element to cache
 

Private Attributes

cache_type Cache_
 set of weak pointers to objects
 

Detailed Description

template<class T>
class yap::WeakPtrCache< T >

Template for a cache of weak_ptr's to objects.

Author
Daniel Greenwald

Member Typedef Documentation

using cache_type = std::set<weak_ptr_type, std::owner_less<weak_ptr_type> >

A std::set of weak_ptr_type.

cache storage type

using shared_ptr_type = std::shared_ptr<T>

std::shared_ptr to T

shared_ptr_type

using weak_ptr_type = std::weak_ptr<T>

std::weak_ptr to T

weak_ptr_type

Member Function Documentation

cache_type::iterator begin ( void  )
inline
Returns
iterator to begin
cache_type::const_iterator begin ( void  ) const
inline
Returns
const_iterator to begin
size_t count_expired ( ) const
inline
Returns
number of expired Cache_ elements
bool empty ( ) const
inline
Returns
whether empty
cache_type::iterator end ( void  )
inline
Returns
iterator to end
cache_type::const_iterator end ( void  ) const
inline
Returns
const_iterator to end
weak_ptr_type find ( shared_ptr_type  t) const
inline

check if cache contains element equating to t

Parameters
tshared_ptr to object to search for equivalent of
shared_ptr_type operator[] ( shared_ptr_type  t)
inline
Returns
shared_ptr from Cache, if it exists, otherwise adds it to cache.
Parameters
tShared ptr to object to retrieve from or add to cache
size_t size ( void  ) const
inline
Returns
size

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