ARB
Public Member Functions | List of all members
cache::CacheHandle< SMARTPTR > Class Template Reference

Handle for Cache entries. More...

#include <cache.h>

Inheritance diagram for cache::CacheHandle< SMARTPTR >:
Inheritance graph
[legend]
Collaboration diagram for cache::CacheHandle< SMARTPTR >:
Collaboration graph
[legend]

Public Member Functions

 CacheHandle ()
 
 ~CacheHandle ()
 
void assign (SMARTPTR data, Cache< SMARTPTR > &cache)
 
SMARTPTR access (Cache< SMARTPTR > &cache)
 
void release (Cache< SMARTPTR > &cache)
 
bool is_cached () const
 

Detailed Description

template<typename SMARTPTR>
class cache::CacheHandle< SMARTPTR >

Handle for Cache entries.

Definition at line 33 of file cache.h.

Constructor & Destructor Documentation

template<typename SMARTPTR>
cache::CacheHandle< SMARTPTR >::CacheHandle ( )
inline

create a new, unbound CacheHandle

Each (potential) cache entry needs a CacheHandle on client side.

Definition at line 233 of file cache.h.

template<typename SMARTPTR>
cache::CacheHandle< SMARTPTR >::~CacheHandle ( )
inline

destroys a CacheHandle

Before destrying it, you need to either call release() or Cache::flush().

Definition at line 239 of file cache.h.

Member Function Documentation

template<typename SMARTPTR>
void cache::CacheHandle< SMARTPTR >::assign ( SMARTPTR  data,
Cache< SMARTPTR > &  cache 
)
inline

assign data to a CacheHandle

Parameters
dataSmartPtr containing client data (may not be NULp)
cacheCache in which data shall be stored

The assigned data is stored in the Cache.

When the cache is filled, calls to assign() will invalidate other cache entries and their CacheHandles.

Definition at line 251 of file cache.h.

Referenced by probe_input_data::get_dataPtr(), and probe_input_data::preload_rel2abs().

template<typename SMARTPTR>
SMARTPTR cache::CacheHandle< SMARTPTR >::access ( Cache< SMARTPTR > &  cache)
inline

read data from cache

Parameters
cacheCache to which data has been assigned earlier
Returns
SmartPtr containing data (as used in assign())

You need to check whether the assigned data still is cached by calling is_cached() before you can use this function. e.g. like follows

if (!handle.is_cached()) handle.assign(generateYourData(), cache);
smartptr = handle.access(cache);

The data behind the returned smartptr will stay valid until its destruction, even if the handle is invalidated by other code.

Calling access() will also make this CacheHandle the "newest" handle in cache, i.e. the one with the longest lifetime.

Definition at line 275 of file cache.h.

Referenced by probe_input_data::calc_relpos(), probe_input_data::get_abspos(), and probe_input_data::get_dataPtr().

template<typename SMARTPTR>
void cache::CacheHandle< SMARTPTR >::release ( Cache< SMARTPTR > &  cache)
inline

actively release data from cache

Parameters
cacheCache to which data has been assigned earlier

Call this either

  • before destroying the CacheHandle or
  • when you know the data will no longer be needed, to safe cache-space for other entries.

Definition at line 288 of file cache.h.

Referenced by probe_input_data::~probe_input_data().

template<typename SMARTPTR>
bool cache::CacheHandle< SMARTPTR >::is_cached ( ) const
inline

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