OW_NAMESPACE::Cache< T > Class Template Reference

This class encapsulates the functionality of a cache. More...

#include <OW_Cache.hpp>

Collaboration diagram for OW_NAMESPACE::Cache< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Cache ()
void addToCache (const T &cc, const String &key)
 Add an item to the cache.
getFromCache (const String &key)
 Get an item from the cache.
void removeFromCache (const String &key)
 Remove an item from the cache.
void clearCache ()
 Remove all items from the cache.
void setMaxCacheSize (UInt32)
 Set the maximum number of items the cache will hold.

Private Types

typedef std::list< std::pair<
T, String > > 
class_cache_t
typedef __gnu_cxx::hash_map<
String, typename class_cache_t::iterator > 
cache_index_t

Private Attributes

class_cache_t theCache
cache_index_t theCacheIndex
Mutex cacheGuard
UInt32 maxCacheSize

Detailed Description

template<typename T>
class OW_NAMESPACE::Cache< T >

This class encapsulates the functionality of a cache.

Definition at line 53 of file OW_Cache.hpp.


Member Typedef Documentation

template<typename T>
typedef __gnu_cxx::hash_map<String, typename class_cache_t::iterator> OW_NAMESPACE::Cache< T >::cache_index_t [private]
 

Definition at line 100 of file OW_Cache.hpp.

template<typename T>
typedef std::list<std::pair<T, String> > OW_NAMESPACE::Cache< T >::class_cache_t [private]
 

Definition at line 97 of file OW_Cache.hpp.


Constructor & Destructor Documentation

template<typename T>
OW_NAMESPACE::Cache< T >::Cache  ) 
 

Definition at line 108 of file OW_Cache.hpp.


Member Function Documentation

template<typename T>
void OW_NAMESPACE::Cache< T >::addToCache const T &  cc,
const String key
 

Add an item to the cache.

Parameters:
cc The item to add
key The key for the item cc is not already in the cache. Adding duplicate items into the cache will waste space. getFromCache(key) returns cc.

Definition at line 115 of file OW_Cache.hpp.

References OW_NAMESPACE::Cache< T >::cacheGuard, OW_NAMESPACE::Cache< T >::maxCacheSize, OW_NAMESPACE::Cache< T >::theCache, and OW_NAMESPACE::Cache< T >::theCacheIndex.

Referenced by OW_NAMESPACE::MOF::CIMOMVisitor::CIMOMprocessQualifierType(), OW_NAMESPACE::MetaRepository::getCIMClass(), OW_NAMESPACE::MOF::CIMOMVisitor::getClass(), OW_NAMESPACE::MOF::CIMOMVisitor::getQualifierType(), OW_NAMESPACE::MetaRepository::getQualifierType(), OW_NAMESPACE::ProviderAgentCIMOMHandle::helperGetClass(), OW_NAMESPACE::ProviderAgentEnvironment::ProviderAgentEnvironment(), and OW_NAMESPACE::MetaRepository::setQualifierType().

template<typename T>
void OW_NAMESPACE::Cache< T >::clearCache  ) 
 

Remove all items from the cache.

Definition at line 170 of file OW_Cache.hpp.

References OW_NAMESPACE::Cache< T >::cacheGuard, OW_NAMESPACE::Cache< T >::theCache, and OW_NAMESPACE::Cache< T >::theCacheIndex.

Referenced by OW_NAMESPACE::MetaRepository::deleteNameSpace().

template<typename T>
T OW_NAMESPACE::Cache< T >::getFromCache const String key  ) 
 

Get an item from the cache.

Average complexity is constant time. Worst case is linear in the size of the cache.

Parameters:
key The key for the item to retrieve.
Returns:
The item if found, else the item constructed with CIMNULL parameter.

Definition at line 134 of file OW_Cache.hpp.

References OW_NAMESPACE::Cache< T >::cacheGuard, OW_NAMESPACE::CIMNULL, i, OW_NAMESPACE::Cache< T >::theCache, and OW_NAMESPACE::Cache< T >::theCacheIndex.

Referenced by OW_NAMESPACE::MetaRepository::getCIMClass(), OW_NAMESPACE::MOF::CIMOMVisitor::getClass(), OW_NAMESPACE::MOF::CIMOMVisitor::getQualifierType(), OW_NAMESPACE::MetaRepository::getQualifierType(), and OW_NAMESPACE::ProviderAgentCIMOMHandle::helperGetClass().

template<typename T>
void OW_NAMESPACE::Cache< T >::removeFromCache const String key  ) 
 

Remove an item from the cache.

Average complexity is constant time. Worst case is linear in the size of the cache. It does not matter if the item is not in the cache. getFromCache(key) will return T(CIMNULL)

Parameters:
key The key for the item to remove.

Definition at line 156 of file OW_Cache.hpp.

References OW_NAMESPACE::Cache< T >::cacheGuard, i, OW_NAMESPACE::Cache< T >::theCache, and OW_NAMESPACE::Cache< T >::theCacheIndex.

Referenced by OW_NAMESPACE::MetaRepository::deleteClass(), OW_NAMESPACE::MetaRepository::deleteQualifierType(), OW_NAMESPACE::MetaRepository::modifyClass(), and OW_NAMESPACE::MetaRepository::setQualifierType().

template<typename T>
void OW_NAMESPACE::Cache< T >::setMaxCacheSize UInt32   ) 
 

Set the maximum number of items the cache will hold.

This will shrink the cache if necessary.

Definition at line 179 of file OW_Cache.hpp.

References OW_NAMESPACE::Cache< T >::cacheGuard, OW_NAMESPACE::Cache< T >::maxCacheSize, OW_NAMESPACE::Cache< T >::theCache, and OW_NAMESPACE::Cache< T >::theCacheIndex.

Referenced by OW_NAMESPACE::MetaRepository::init(), OW_NAMESPACE::MetaRepository2::MetaRepository2(), and OW_NAMESPACE::ProviderAgentEnvironment::ProviderAgentEnvironment().


Member Data Documentation

template<typename T>
Mutex OW_NAMESPACE::Cache< T >::cacheGuard [private]
 

Definition at line 103 of file OW_Cache.hpp.

Referenced by OW_NAMESPACE::Cache< T >::addToCache(), OW_NAMESPACE::Cache< T >::clearCache(), OW_NAMESPACE::Cache< T >::getFromCache(), OW_NAMESPACE::Cache< T >::removeFromCache(), and OW_NAMESPACE::Cache< T >::setMaxCacheSize().

template<typename T>
UInt32 OW_NAMESPACE::Cache< T >::maxCacheSize [private]
 

Definition at line 104 of file OW_Cache.hpp.

Referenced by OW_NAMESPACE::Cache< T >::addToCache(), and OW_NAMESPACE::Cache< T >::setMaxCacheSize().

template<typename T>
class_cache_t OW_NAMESPACE::Cache< T >::theCache [private]
 

Definition at line 101 of file OW_Cache.hpp.

Referenced by OW_NAMESPACE::Cache< T >::addToCache(), OW_NAMESPACE::Cache< T >::clearCache(), OW_NAMESPACE::Cache< T >::getFromCache(), OW_NAMESPACE::Cache< T >::removeFromCache(), and OW_NAMESPACE::Cache< T >::setMaxCacheSize().

template<typename T>
cache_index_t OW_NAMESPACE::Cache< T >::theCacheIndex [private]
 

Definition at line 102 of file OW_Cache.hpp.

Referenced by OW_NAMESPACE::Cache< T >::addToCache(), OW_NAMESPACE::Cache< T >::clearCache(), OW_NAMESPACE::Cache< T >::getFromCache(), OW_NAMESPACE::Cache< T >::removeFromCache(), and OW_NAMESPACE::Cache< T >::setMaxCacheSize().


The documentation for this class was generated from the following file:
Generated on Thu Feb 9 09:13:28 2006 for openwbem by  doxygen 1.4.6