author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (side-by-side diff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/pim/opimcache.h | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
-rw-r--r-- | libopie/pim/opimcache.h | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/libopie/pim/opimcache.h b/libopie/pim/opimcache.h deleted file mode 100644 index 7f7cff5..0000000 --- a/libopie/pim/opimcache.h +++ b/dev/null @@ -1,131 +0,0 @@ -#ifndef OPIE_PIM_CACHE_H -#define OPIE_PIM_CACHE_H - -#include <qintcache.h> - -#include "opimrecord.h" - -class OPimCacheItemPrivate; - -template <class T = OPimRecord> -class OPimCacheItem { -public: - OPimCacheItem( const T& t = T() ); - OPimCacheItem( const OPimCacheItem& ); - ~OPimCacheItem(); - - OPimCacheItem &operator=( const OPimCacheItem& ); - - T record()const; - void setRecord( const T& ); -private: - T m_t; - OPimCacheItemPrivate *d; -}; - - -class OPimCachePrivate; -/** - * OPimCache for caching the items - * We support adding, removing - * and finding - */ -template <class T = OPimRecord> -class OPimCache { -public: - typedef OPimCacheItem<T> Item; - OPimCache(); - OPimCache( const OPimCache& ); - ~OPimCache(); - - OPimCache &operator=( const OPimCache& ); - - bool contains(int uid)const; - void invalidate(); - void setSize( int size ); - - T find(int uid )const; - void add( const T& ); - void remove( int uid ); - void replace( const T& ); - -private: - QIntCache<Item> m_cache; - OPimCachePrivate* d; -}; - -// Implementation -template <class T> -OPimCacheItem<T>::OPimCacheItem( const T& t ) - : m_t(t) { -} -template <class T> -OPimCacheItem<T>::~OPimCacheItem() { - -} -template <class T> -T OPimCacheItem<T>::record()const { - return m_t; -} -template <class T> -void OPimCacheItem<T>::setRecord( const T& t ) { - m_t = t; -} -// Cache -template <class T> -OPimCache<T>::OPimCache() - : m_cache(100, 53 ) -{ - m_cache.setAutoDelete( TRUE ); -} -template <class T> -OPimCache<T>::~OPimCache() { - -} -template <class T> -bool OPimCache<T>::contains(int uid )const { - Item* it = m_cache.find( uid, FALSE ); - if (!it) - return false; - return true; -} -template <class T> -void OPimCache<T>::invalidate() { - m_cache.clear(); -} -template <class T> -void OPimCache<T>::setSize( int size ) { - m_cache.setMaxCost( size ); -} -template <class T> -T OPimCache<T>::find(int uid )const { - Item *it = m_cache.find( uid ); - if (it) - return it->record(); - return T(); -} -template <class T> -void OPimCache<T>::add( const T& t ) { - Item* it = 0l; - it = m_cache.find(t.uid(), FALSE ); - - if (it ) - it->setRecord( t ); - - it = new Item( t ); - if (!m_cache.insert( t.uid(), it ) ) - delete it; -} -template <class T> -void OPimCache<T>::remove( int uid ) { - m_cache.remove( uid ); -} -template <class T> -void OPimCache<T>::replace( const T& t) { - Item *it = m_cache.find( t.uid() ); - if ( it ) { - it->setRecord( t ); - } -} - -#endif |