Helios++
Helios software for LiDAR simulations
WavefrontObjCache Class Reference
Collaboration diagram for WavefrontObjCache:

Public Member Functions

size_t size () const
 Get the number of elements allocated in the cache. More...
 
size_t capacity () const
 Get the maximum number of elements that can be stored in the cache. More...
 
bool empty () const
 Checks whether the cache is empty. More...
 
bool contains (const std::string &key)
 Checks whether a value is already stored in the cache looking for its key. More...
 
void insert (const std::string &key, WavefrontObj *value)
 Inserts an element in the cache. More...
 
WavefrontObjget (const std::string &key)
 Returns a cache element by its key, if exists. More...
 
void deallocate ()
 Removes the last element in the list to make room to a new one. This function is called only if the cache is full.
 

Static Public Member Functions

static WavefrontObjCachegetInstance ()
 Get an instance of the cache (Singleton Pattern) More...
 

Private Member Functions

 WavefrontObjCache ()
 Default constructor for a default OBJ Cache.
 
 ~WavefrontObjCache ()
 Destructor with the responsibility of deallocating all the items stored in the Heap.
 

Private Attributes

map_type m_map
 
list_type m_list
 
size_t m_capacity
 

Member Function Documentation

◆ capacity()

size_t WavefrontObjCache::capacity ( ) const

Get the maximum number of elements that can be stored in the cache.

Returns
Number of elements that can be stored in the cache

◆ contains()

bool WavefrontObjCache::contains ( const std::string &  key)

Checks whether a value is already stored in the cache looking for its key.

Parameters
keyKey of the value to be checked
Returns
True if the value exists, False otherwise

◆ empty()

bool WavefrontObjCache::empty ( ) const

Checks whether the cache is empty.

Returns
True if the cache is empty, false otherwise

◆ get()

value_type WavefrontObjCache::get ( const std::string &  key)

Returns a cache element by its key, if exists.

Parameters
keyKey used to look for an element stored in the cache
Returns
The element if found, nullptr otherwise

◆ getInstance()

WavefrontObjCache & WavefrontObjCache::getInstance ( )
static

Get an instance of the cache (Singleton Pattern)

Returns
Instance of the cache itself ready to be used.

◆ insert()

void WavefrontObjCache::insert ( const std::string &  key,
WavefrontObj value 
)

Inserts an element in the cache.

Parameters
keyKey of the value used in future searches
valueElement to be stored

◆ size()

size_t WavefrontObjCache::size ( ) const

Get the number of elements allocated in the cache.

Returns
Number of elements allocated in the cache

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