PLaSK library

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

Cache values of type Value using Key type to index it. More...

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

Inheritance diagram for plask::StrongCache< Key, Value, DeleteStrategy >:
[legend]
Collaboration diagram for plask::StrongCache< Key, Value, DeleteStrategy >:
[legend]

## Public Member Functions
plask::shared_ptr< Value > | get (Key *index) const
| Try get object from cache.
plask::shared_ptr< Value > | get (plask::shared_ptr< Key > index) const
| Try get object from cache.
Public Member Functions inherited from plask::CacheBase< Key, ValuePtr, DeleteStrategy >
| ~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.

## Additional Inherited Members
Public Types inherited from plask::CacheBase< Key, ValuePtr, DeleteStrategy >
typedef ValuePtr::element_type | Value

## Detailed Description

template<typename Key, typename Value, template< typename SKey, typename SValuePtr > class DeleteStrategy = CacheRemoveOnlyWhenDeleted>
struct plask::StrongCache< Key, Value, DeleteStrategy >

Cache values of type Value using Key type to index it.

It stores shared_ptr to values, so each value will be live when it's only is included in cache. Cache entries are removed on key changes (see `deleteStrategy`).

Template Parameters

  Key | type using as index in cache (pointer to this type will be used), must be able to emit events;
  Value | type for cache values, will be stored in shared_ptr;
  deleteStrategy | when cache entries should be deleted: CacheRemoveOnlyWhenDeleted - when key is deleted (default), CacheRemoveOnEachChange - when key is changed, other class template which derives from plask::CacheRemoveStrategyBase and have void onEvent(typename Key::Event& evt) method - custom.

Definition at line 296 of file cache.hpp.

## Member Function Documentation

## ◆ get() [1/2]

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

plask::shared_ptr< Value > plask::StrongCache< Key, Value, DeleteStrategy >::get | ( | Key * | index | ) | const
| inline

Try get object from cache.

Parameters

  index | key of object

Returns
  non-null value from cache stored for key or nullptr if there is no value for given index

Definition at line 303 of file cache.hpp.

## ◆ get() [2/2]

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

plask::shared_ptr< Value > plask::StrongCache< Key, Value, DeleteStrategy >::get | ( | plask::shared_ptr< Key > | index | ) | const
| inline

Try get object from cache.

Parameters

  index | key of object

Returns
  non-null value from cache stored for key or nullptr if there is no value for given index

Definition at line 313 of file cache.hpp.

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

- plask/utils/cache.hpp