PLaSK library

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
plask::CacheBase< Key, ValuePtr, DeleteStrategy > Struct Template Reference

`#include <plask/utils/cache.hpp>`

Inheritance diagram for plask::CacheBase< Key, ValuePtr, DeleteStrategy >:
[legend]
Collaboration diagram for plask::CacheBase< Key, ValuePtr, DeleteStrategy >:
[legend]

## Public Types
typedef ValuePtr::element_type | Value

## Public Member Functions
| ~CacheBase ()
| Clear cache.
void | append (Key *index, ValuePtr value)
| Append entry to cache.
void | append (plask::shared_ptr< Key > index, ValuePtr value)
| Append entry to cache.
plask::shared_ptr< Value > | operator() (Key *index, Value *value)
| Construct shared pointer to value and append cache entry which consists of given index and constructed shared pointer.
plask::shared_ptr< Value > | operator() (Key *index, shared_ptr< Value > value)
| Append cache entry which consists of given index and value and return value.
plask::shared_ptr< Value > | operator() (plask::shared_ptr< Key > index, Value *value)
| Construct shared pointer to value and append cache entry which consists of given index and constructed shared pointer.
plask::shared_ptr< Value > | operator() (plask::shared_ptr< Key > index, shared_ptr< Value > value)
| Construct shared pointer to value and append cache entry which consists of given index and constructed shared pointer.
void | clear ()
| Remove all entries from this cache.

## Detailed Description

template<typename Key, typename ValuePtr, template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>
struct plask::CacheBase< Key, ValuePtr, DeleteStrategy >

Definition at line 76 of file cache.hpp.

## Member Typedef Documentation

## ◆ Value

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

typedef ValuePtr::element_type plask::CacheBase< Key, ValuePtr, DeleteStrategy >::Value

Definition at line 78 of file cache.hpp.

## Constructor & Destructor Documentation

## ◆ ~CacheBase()

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

plask::CacheBase< Key, ValuePtr, DeleteStrategy >::~CacheBase | ( |  | ) |
| inline

Clear cache.

Definition at line 81 of file cache.hpp.

## Member Function Documentation

## ◆ append() [1/2]

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

void plask::CacheBase< Key, ValuePtr, DeleteStrategy >::append | ( | Key * | index,
|  | ValuePtr | value
| ) |  |
| inline

Append entry to cache.

Parameters

  index | key of entry
  value | value of entry

Definition at line 90 of file cache.hpp.

## ◆ append() [2/2]

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

void plask::CacheBase< Key, ValuePtr, DeleteStrategy >::append | ( | plask::shared_ptr< Key > | index,
|  | ValuePtr | value
| ) |  |
| inline

Append entry to cache.

Parameters

  index | key of entry
  value | value of entry

Definition at line 101 of file cache.hpp.

## ◆ clear()

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

void plask::CacheBase< Key, ValuePtr, DeleteStrategy >::clear | ( |  | ) |
| inline

Remove all entries from this cache.

Definition at line 190 of file cache.hpp.

## ◆ operator()() [1/4]

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

plask::shared_ptr< Value > plask::CacheBase< Key, ValuePtr, DeleteStrategy >::operator() | ( | Key * | index,
|  | shared_ptr< Value > | value
| ) |  |
| inline

Append cache entry which consists of given index and value and return value.

This is useful in methods which wants to append new value to cache and return it:

plask::shared_ptr<Value> get(plask::shared_ptr<Key> index) {
if (auto res = my_cache.get(index))
return res;
else
return my_cache(index.get(), calculate_value_for(index));
}

Parameters

  index,value | entry data

Returns
  shared pointer to value

Definition at line 141 of file cache.hpp.

## ◆ operator()() [2/4]

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

plask::shared_ptr< Value > plask::CacheBase< Key, ValuePtr, DeleteStrategy >::operator() | ( | Key * | index,
|  | Value * | value
| ) |  |
| inline

Construct shared pointer to value and append cache entry which consists of given index and constructed shared pointer.

This is useful in methods which wants to append new value to cache and return it:

plask::shared_ptr<Value> get(plask::shared_ptr<Key> index) {
if (auto res = my_cache.get(index))
return res;
else
return my_cache(index.get(), calculate_value_for(index));
}

Parameters

  index,value | entry data

Returns
  shared pointer to value

Definition at line 120 of file cache.hpp.

## ◆ operator()() [3/4]

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

plask::shared_ptr< Value > plask::CacheBase< Key, ValuePtr, DeleteStrategy >::operator() | ( | plask::shared_ptr< Key > | index,
|  | shared_ptr< Value > | value
| ) |  |
| inline

Construct shared pointer to value and append cache entry which consists of given index and constructed shared pointer.

This is useful in methods which wants to append new value to cache and return it:

plask::shared_ptr<Value> get(plask::shared_ptr<Key> index) {
if (auto res = my_cache.get(index))
return res;
else
return my_cache(index, calculate_value_for(index));
}

Parameters

  index,value | entry data

Returns
  value

Definition at line 182 of file cache.hpp.

## ◆ operator()() [4/4]

template<typename Key , typename ValuePtr , template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>

plask::shared_ptr< Value > plask::CacheBase< Key, ValuePtr, DeleteStrategy >::operator() | ( | plask::shared_ptr< Key > | index,
|  | Value * | value
| ) |  |
| inline

Construct shared pointer to value and append cache entry which consists of given index and constructed shared pointer.

This is useful in methods which wants to append new value to cache and return it:

plask::shared_ptr<Value> get(plask::shared_ptr<Key> index) {
if (auto res = my_cache.get(index))
return res;
else
return my_cache(index, calculate_value_for(index));
}

Parameters

  index,value | entry data

Returns
  value

Definition at line 161 of file cache.hpp.

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

- plask/utils/cache.hpp