Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::common::CloneCache< CacheType > Class Template Reference

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

#include <clone_cache.h>

Public Member Functions

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

Public Attributes

const bool supports_update

Protected Member Functions

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

Protected Attributes

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

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

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_

◆ setCacheSize()

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

Set the cache size.

Parameters
sizeThe size of the cache.

◆ getCacheSize()

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

Get the set cache size.

Returns
The set size of the cache.

◆ 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