Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
tesseract_common::CloneCache< CacheType > Class Template Reference

Used to create a cache of objects. More...

#include <clone_cache.h>

Public Member Functions

std::shared_ptr< CacheType > clone ()
 Gets a clone of original_. More...
 
 CloneCache (std::shared_ptr< CacheType > original, const long &cache_size=5)
 
long getCacheSize () const
 Get the set cache size. More...
 
long getCurrentCacheSize () const
 Get the current size of the cache. More...
 
const std::shared_ptr< CacheType > & operator-> ()
 
void setCacheSize (long size)
 Set the cache size. More...
 
void updateCache ()
 If original_ has changed it will update or rebuild the cache of objects. More...
 

Public Attributes

const bool supports_update
 

Protected Member Functions

void createClone ()
 
std::shared_ptr< CacheType > getClone () const
 

Protected Attributes

std::deque< std::shared_ptr< CacheType > > cache_
 A vector of cached objects. More...
 
std::mutex cache_mutex_
 The mutex used when reading and writing to cache_. More...
 
std::size_t cache_size_ { 5 }
 The assigned cache size. More...
 
std::shared_ptr< CacheType > original_
 

Detailed Description

template<typename CacheType>
class tesseract_common::CloneCache< CacheType >

Used to create a cache of objects.

CacheType needs the following methods CacheType::Ptr clone() const; int getRevision() const; bool update(Const CacheType::ConstPtr&); // optional

Definition at line 51 of file clone_cache.h.

Constructor & Destructor Documentation

◆ CloneCache()

template<typename CacheType >
tesseract_common::CloneCache< CacheType >::CloneCache ( std::shared_ptr< CacheType >  original,
const long &  cache_size = 5 
)
inline

Definition at line 58 of file clone_cache.h.

Member Function Documentation

◆ clone()

template<typename CacheType >
std::shared_ptr<CacheType> tesseract_common::CloneCache< CacheType >::clone ( )
inline

Gets a clone of original_.

Returns
A shared_ptr to a new clone of original_

Definition at line 79 of file clone_cache.h.

◆ createClone()

template<typename CacheType >
void tesseract_common::CloneCache< CacheType >::createClone ( )
inlineprotected

Definition at line 195 of file clone_cache.h.

◆ getCacheSize()

template<typename CacheType >
long tesseract_common::CloneCache< CacheType >::getCacheSize ( ) const
inline

Get the set cache size.

Returns
The set size of the cache.

Definition at line 139 of file clone_cache.h.

◆ getClone()

template<typename CacheType >
std::shared_ptr<CacheType> tesseract_common::CloneCache< CacheType >::getClone ( ) const
inlineprotected

Definition at line 209 of file clone_cache.h.

◆ getCurrentCacheSize()

template<typename CacheType >
long tesseract_common::CloneCache< CacheType >::getCurrentCacheSize ( ) const
inline

Get the current size of the cache.

Returns
The current size fo the cache

Definition at line 145 of file clone_cache.h.

◆ operator->()

template<typename CacheType >
const std::shared_ptr<CacheType>& tesseract_common::CloneCache< CacheType >::operator-> ( )
inline

Definition at line 73 of file clone_cache.h.

◆ setCacheSize()

template<typename CacheType >
void tesseract_common::CloneCache< CacheType >::setCacheSize ( long  size)
inline

Set the cache size.

Parameters
sizeThe size of the cache.

Definition at line 126 of file clone_cache.h.

◆ updateCache()

template<typename CacheType >
void tesseract_common::CloneCache< CacheType >::updateCache ( )
inline

If original_ has changed it will update or rebuild the cache of objects.

Definition at line 152 of file clone_cache.h.

Member Data Documentation

◆ cache_

template<typename CacheType >
std::deque<std::shared_ptr<CacheType> > tesseract_common::CloneCache< CacheType >::cache_
protected

A vector of cached objects.

Definition at line 230 of file clone_cache.h.

◆ cache_mutex_

template<typename CacheType >
std::mutex tesseract_common::CloneCache< CacheType >::cache_mutex_
mutableprotected

The mutex used when reading and writing to cache_.

Definition at line 233 of file clone_cache.h.

◆ cache_size_

template<typename CacheType >
std::size_t tesseract_common::CloneCache< CacheType >::cache_size_ { 5 }
protected

The assigned cache size.

Definition at line 227 of file clone_cache.h.

◆ original_

template<typename CacheType >
std::shared_ptr<CacheType> tesseract_common::CloneCache< CacheType >::original_
protected

Definition at line 224 of file clone_cache.h.

◆ supports_update

template<typename CacheType >
const bool tesseract_common::CloneCache< CacheType >::supports_update

Definition at line 192 of file clone_cache.h.


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


tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:40