Classes | Public Types | Public Member Functions
clipper::ObjectCache< T > Class Template Reference

Object Cache manager. More...

#include <clipper_memory.h>

List of all members.


class  Reference
 ObjectCache reference class. More...

Public Types


Public Member Functions

 ObjectCache ()
 ~ObjectCache ()
 destructor, can message on contents
void set_mode (const MODE &mode)
 set garbage collection mode
void purge ()
 purge unreferenced objects from cache
void destroy ()
void debug () const
Reference cache (const typename T::Key &key)
 cache or return data by key

Detailed Description

template<class T>
class clipper::ObjectCache< T >

Object Cache manager.

The object cache is a tool for storing information which may appear several times. Examples include tables of information for spacegroups or crystallographic maps. When a new object is created, a check is first done to see if such an object already exists in the cache, in which case that copy is used. Otherwise a new copy is added to the cache.

A cached object must implement:

Referring to the cache returns an ObjectCache<T>::Reference to a cache object. This object performs reference counting, which is used for garbage collection.

To retrieve the actual cached data, use the ObjectCache<T>::Reference::data() method. The data is held at a fixed memory location, therefore pointers to the data may be safely kept, as long as they are discarded as soon as the reference is discarded (at which point garbage collection may occur).

Ideally this would be a class with static members only, but some compilers have trouble with static members of template classes.

Garbage collection modes include:

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