luna engine
software engine
Loading...
Searching...
No Matches
luna::utils::objectStorage< value > Class Template Reference

cached object memory class with a key handle. More...

#include <objectStorage.h>

Inheritance diagram for luna::utils::objectStorage< value >:
Collaboration diagram for luna::utils::objectStorage< value >:

Public Member Functions

std::pair< storageResult, value > operator[] (const storageObject &key)
 
 objectStorage ()
 deafault constructor whith default cache size of 200. More...
 
 objectStorage (size_t cacheSize)
 constructor with custom cache size. More...
 
std::pair< storageResult, value > putValue (storageObject *key, const value &_value)
 puts a value in the object storage. More...
 
std::pair< storageResult, value > getValue (const storageObject &key, const value &_value=value())
 gets a value from the object storage. More...
 
std::pair< storageResult, value > setValue (const storageObject &key, const value &_value)
 sets the value of a given key. More...
 
std::pair< storageResult, value > eraseValue (const storageObject &key)
 

Private Attributes

vectorCache< value > objectCache
 
std::unordered_map< storageObject, value > objectMemory
 

Detailed Description

template<typename value>
class luna::utils::objectStorage< value >

cached object memory class with a key handle.

Constructor & Destructor Documentation

◆ objectStorage() [1/2]

template<typename value >
luna::utils::objectStorage< value >::objectStorage ( )
inline

deafault constructor whith default cache size of 200.

Note
this constructor is recommended for dafult use.

◆ objectStorage() [2/2]

template<typename value >
luna::utils::objectStorage< value >::objectStorage ( size_t  cacheSize)
inline

constructor with custom cache size.

Note
recommended to not go above cacheSize of 1000 else cache could become slow!
recommended to use the deafult constructor unless you know what you are doing!
Parameters
size_tcacheSize

Member Function Documentation

◆ eraseValue()

template<typename value >
std::pair< storageResult, value > luna::utils::objectStorage< value >::eraseValue ( const storageObject key)
inline

◆ getValue()

template<typename value >
std::pair< storageResult, value > luna::utils::objectStorage< value >::getValue ( const storageObject key,
const value &  _value = value() 
)
inline

gets a value from the object storage.

Parameters
storageObjectkey
value_value
Returns
std::pair<storageResult, value> value is the input value.
See also
storageResult

◆ operator[]()

template<typename value >
std::pair< storageResult, value > luna::utils::objectStorage< value >::operator[] ( const storageObject key)
inline

◆ putValue()

template<typename value >
std::pair< storageResult, value > luna::utils::objectStorage< value >::putValue ( storageObject key,
const value &  _value 
)
inline

puts a value in the object storage.

Note
if the value of *key != it whill use this value instead of generating one.
Parameters
storageObject*key pointer to key
value_value value/object to be stored.
Returns
std::pair<storageResult, value> value is the input value.
See also
storageResult

◆ setValue()

template<typename value >
std::pair< storageResult, value > luna::utils::objectStorage< value >::setValue ( const storageObject key,
const value &  _value 
)
inline

sets the value of a given key.

Parameters
storageObjectkey
value_value
Returns
std::pair<storageResult, value> value is the input value.
See also
storageResult

Member Data Documentation

◆ objectCache

template<typename value >
vectorCache<value> luna::utils::objectStorage< value >::objectCache
private

◆ objectMemory

template<typename value >
std::unordered_map<storageObject, value> luna::utils::objectStorage< value >::objectMemory
private

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