|
flyweight.hpp
|
#include <flyweight.hpp>
Public Types | |
| using | autorelease_value = autorelease_value< T, flyweight_refcounted, std::tuple< Args... > > |
Public Member Functions | |
| flyweight_refcounted () | |
| template<typename Creator > | |
| flyweight_refcounted (Creator &&creator) | |
| template<typename Creator , typename Deleter > | |
| flyweight_refcounted (Creator &&creator, Deleter &&deleter) | |
| T & | get (const std::tuple< Args... > &arg_tuple) |
| template<bool uses_multiple_args = (sizeof...(Args) > 1)> | |
| auto | get (Args &&... args) -> typename std::enable_if< uses_multiple_args, T & >::type |
Alternative to flyweight_refcounted::get with the arguments unpacked. | |
| autorelease_value | get_autorelease (const std::tuple< Args... > &arg_tuple) |
| template<bool uses_multiple_args = (sizeof...(Args) > 1)> | |
| auto | get_autorelease (Args &&... args) -> typename std::enable_if< uses_multiple_args, autorelease_value >::type |
Alternative to flyweight_refcounted::get_autorelease with the arguments unpacked. | |
| size_t | reference_count (const std::tuple< Args... > &arg_tuple) const |
| template<bool uses_multiple_args = (sizeof...(Args) > 1)> | |
| auto | reference_count (Args &&... args) const -> typename std::enable_if< uses_multiple_args, size_t >::type |
Alternative to flyweight_refcounted::reference_count with the arguments unpacked. | |
| bool | release (const std::tuple< Args... > &arg_tuple) |
| template<bool uses_multiple_args = (sizeof...(Args) > 1)> | |
| auto | release (Args &&... args) -> typename std::enable_if< uses_multiple_args, bool >::type |
Alternative to flyweight_refcounted::release with the arguments unpacked. | |
flyweight subclass that employs reference counting.
The reference count increments for each call to flyweight_refcounted::get and decrements for each call to flyweight_refcounted::release using the same arguments. When calling flyweight_refcounted::release, the value is actually deleted from the cache only when the reference count reaches zero.
This is specially useful for implementing resource management of heavy objects, like images used as icons in an interactive app.
|
inline |
|
inline |
|
inline |
|
inline |
Override for flyweight::get with reference counting.
|
inline |
Alternative to flyweight_refcounted::get with the arguments unpacked.
|
inline |
Override for flyweight::get_autorelease with reference counting.
|
inline |
Alternative to flyweight_refcounted::get_autorelease with the arguments unpacked.
|
inline |
Checks the current reference count for the value mapped to the passed arguments.
|
inline |
Alternative to flyweight_refcounted::reference_count with the arguments unpacked.
|
inline |
Override for flyweight::release with reference counting. The value will actually be released only when the reference count reaches zero.
|
inline |
Alternative to flyweight_refcounted::release with the arguments unpacked.