OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
Misc::WeakCache< Key, T > Class Template Reference

#include <weakcache.hpp>

Collaboration diagram for Misc::WeakCache< Key, T >:

Classes

class  iterator
 

Public Types

using WeakPtr = std::weak_ptr< T >
 
using StrongPtr = std::shared_ptr< T >
 
using Map = std::unordered_map< Key, WeakPtr >
 

Public Member Functions

void insert (Key key, StrongPtr value, bool prune=true)
 Stores a weak pointer to the item. More...
 
StrongPtr get (Key key)
 
iterator begin ()
 
iterator end ()
 
void prune ()
 Removes known invalid entries. More...
 

Private Attributes

Map mData
 
std::vector< Key > mDirty
 

Detailed Description

template<typename Key, typename T>
class Misc::WeakCache< Key, T >

Provides a container to weakly store pointers to shared data.

Member Typedef Documentation

template<typename Key, typename T>
using Misc::WeakCache< Key, T >::Map = std::unordered_map<Key, WeakPtr>
template<typename Key, typename T>
using Misc::WeakCache< Key, T >::StrongPtr = std::shared_ptr<T>
template<typename Key, typename T>
using Misc::WeakCache< Key, T >::WeakPtr = std::weak_ptr<T>

Member Function Documentation

template<typename Key , typename T >
WeakCache< Key, T >::iterator Misc::WeakCache< Key, T >::begin ( )
template<typename Key , typename T >
WeakCache< Key, T >::iterator Misc::WeakCache< Key, T >::end ( )
template<typename Key, typename T >
WeakCache< Key, T >::StrongPtr Misc::WeakCache< Key, T >::get ( Key  key)

Retrieves the item associated with the key.

Returns
An item or null.
template<typename Key, typename T >
void Misc::WeakCache< Key, T >::insert ( Key  key,
StrongPtr  value,
bool  prune = true 
)

Stores a weak pointer to the item.

Here is the call graph for this function:

template<typename Key , typename T >
void Misc::WeakCache< Key, T >::prune ( )

Removes known invalid entries.

Here is the caller graph for this function:

Member Data Documentation

template<typename Key, typename T>
Map Misc::WeakCache< Key, T >::mData
private
template<typename Key, typename T>
std::vector<Key> Misc::WeakCache< Key, T >::mDirty
private

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