sbFixedInterfaceCache< KeyClass, Interface > Class Template Reference

#include <sbFixedInterfaceCache.h>

Public Types

typedef KeyClass::KeyType KeyType
 

Public Member Functions

 sbFixedInterfaceCache (PRUint32 aSize)
 
 ~sbFixedInterfaceCache ()
 
void Put (KeyType aKey, Interface *aValue)
 
Interface * Get (KeyType aKey) const
 

Detailed Description

template<class KeyClass, class Interface>
class sbFixedInterfaceCache< KeyClass, Interface >

This class provides a fixed size cache for interface pointers. It holds an owning reference to the pointer, but hands out raw pointers that much be AddRef'd by the caller if they wish to hold on to it. The cache is populated from the end to make it easy to search the most recently added entry. The class now sports a hash implementation so lookups are fast and this makes the cache much more scalable and negates the power of 2 requirement on the size.

Definition at line 46 of file sbFixedInterfaceCache.h.

Member Typedef Documentation

template<class KeyClass, class Interface>
typedef KeyClass::KeyType sbFixedInterfaceCache< KeyClass, Interface >::KeyType

Definition at line 49 of file sbFixedInterfaceCache.h.

Constructor & Destructor Documentation

template<class KeyClass, class Interface>
sbFixedInterfaceCache< KeyClass, Interface >::sbFixedInterfaceCache ( PRUint32  aSize)
inline

Initializes the key array and hash to the cache size. NOTE: The size must be a power of 2

Definition at line 55 of file sbFixedInterfaceCache.h.

template<class KeyClass, class Interface>
sbFixedInterfaceCache< KeyClass, Interface >::~sbFixedInterfaceCache ( )
inline

Releases references to the bags we're holding

Definition at line 67 of file sbFixedInterfaceCache.h.

Member Function Documentation

template<class KeyClass, class Interface>
Interface* sbFixedInterfaceCache< KeyClass, Interface >::Get ( KeyType  aKey) const
inline

Returns the interface pointer for aKey. If it's not found then nsnull is returned. The pointer returned is not addref'd so if you want to keep it around be sure to do it youself

Definition at line 104 of file sbFixedInterfaceCache.h.

template<class KeyClass, class Interface>
void sbFixedInterfaceCache< KeyClass, Interface >::Put ( KeyType  aKey,
Interface *  aValue 
)
inline

Replaces or adds the interface pointer for aKey. The previous interface pointer is released if there is one.

Definition at line 80 of file sbFixedInterfaceCache.h.


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