summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bitmap.c15
-rw-r--r--bitmap.h29
-rw-r--r--cache.h22
3 files changed, 30 insertions, 36 deletions
diff --git a/bitmap.c b/bitmap.c
index 71bfe1d..a6a5fc7 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -1,5 +1,5 @@
/*
- * $Id: bitmap.c,v 1.9 2005/01/27 17:31:35 lordjaxom Exp $
+ * $Id: bitmap.c,v 1.10 2005/01/28 21:26:34 lordjaxom Exp $
*/
#include "bitmap.h"
@@ -16,7 +16,18 @@ using namespace Magick;
#endif
#include <glob.h>
-cxCache<tBitmapSpec,cText2SkinBitmap*> cText2SkinBitmap::mCache(Text2SkinSetup.MaxCacheFill);
+cBitmapCache cText2SkinBitmap::mCache(Text2SkinSetup.MaxCacheFill);
+
+void cBitmapCache::DeleteObject(const tBitmapSpec &Key, cText2SkinBitmap *&Data)
+{
+ delete Data;
+}
+
+void cBitmapCache::ResetObject(cText2SkinBitmap *&Data)
+{
+ Data->Reset();
+}
+
cText2SkinBitmap *cText2SkinBitmap::Load(const std::string &Filename, int Alpha, int height,
int width, int colors, bool Quiet) {
diff --git a/bitmap.h b/bitmap.h
index 446a94a..be29363 100644
--- a/bitmap.h
+++ b/bitmap.h
@@ -1,5 +1,5 @@
/*
- * $Id: bitmap.h,v 1.6 2005/01/27 17:31:35 lordjaxom Exp $
+ * $Id: bitmap.h,v 1.7 2005/01/28 21:26:34 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_BITMAP_H
@@ -50,15 +50,18 @@ inline bool tBitmapSpec::operator==(const tBitmapSpec &Src) const
class cText2SkinBitmap;
-template<>
-void cxCache<tBitmapSpec,cText2SkinBitmap*>::Delete(const tBitmapSpec &Key,
- cText2SkinBitmap *&Data);
-template<>
-void cxCache<tBitmapSpec,cText2SkinBitmap*>::Reset(cText2SkinBitmap *&Data);
+class cBitmapCache: public cxCache<tBitmapSpec,cText2SkinBitmap*> {
+protected:
+ virtual void DeleteObject(const tBitmapSpec &Key, cText2SkinBitmap *&Data);
+ virtual void ResetObject(cText2SkinBitmap *&Data);
+
+public:
+ cBitmapCache(uint MaxItems): cxCache<tBitmapSpec,cText2SkinBitmap*>(MaxItems) {}
+};
class cText2SkinBitmap {
private:
- static cxCache<tBitmapSpec,cText2SkinBitmap*> mCache;
+ static cBitmapCache mCache;
std::vector<cBitmap*> mBitmaps;
int mCurrent;
@@ -96,16 +99,4 @@ inline void cText2SkinBitmap::SetColor(int Index, tColor Color) {
mBitmaps[mCurrent]->SetColor(Index, Color);
}
-template<>
-void cxCache<tBitmapSpec,cText2SkinBitmap*>::Delete(const tBitmapSpec &Key, cText2SkinBitmap *&Data)
-{
- delete Data;
-}
-
-template<>
-void cxCache<tBitmapSpec,cText2SkinBitmap*>::Reset(cText2SkinBitmap *&Data)
-{
- Data->Reset();
-}
-
#endif // VDR_TEXT2SKIN_BITMAP_H
diff --git a/cache.h b/cache.h
index 9d4696f..9582c75 100644
--- a/cache.h
+++ b/cache.h
@@ -1,5 +1,5 @@
/*
- * $Id: cache.h,v 1.4 2005/01/27 10:53:07 lordjaxom Exp $
+ * $Id: cache.h,v 1.5 2005/01/28 21:26:34 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_CACHE_HPP
@@ -22,12 +22,12 @@ private:
uint mMaxItems;
protected:
- void Delete(const key_type &Key, data_type &Data) {}
- void Reset(data_type &Data) {}
+ virtual void DeleteObject(const key_type &Key, data_type &Data) = 0;
+ virtual void ResetObject(data_type &Data) = 0;
public:
cxCache(uint MaxItems);
- ~cxCache();
+ virtual ~cxCache();
void Reset(void);
void Flush(void);
@@ -54,20 +54,12 @@ cxCache<key_type, data_type>::~cxCache()
Flush();
}
-/*XXX move
-template<class key_type, class data_type>
-void cxCache<key_type, data_type>::Delete(const key_type &Key, data_type &Data)
-{
- delete Data;
-}
-*/
-
template<class key_type, class data_type>
void cxCache<key_type, data_type>::Flush(void)
{
item_iterator it = mItems.begin();
for (; it != mItems.end(); ++it)
- Delete(it->first, it->second);
+ DeleteObject(it->first, it->second);
mUsage.clear();
mItems.clear();
@@ -78,7 +70,7 @@ void cxCache<key_type, data_type>::Reset(void)
{
item_iterator it = mItems.begin();
for (; it != mItems.end(); ++it)
- Reset(it->second);
+ ResetObject(it->second);
}
template<class key_type, class data_type>
@@ -99,7 +91,7 @@ data_type &cxCache<key_type, data_type>::operator[](const key_type &Key)
if (mUsage.size() == mMaxItems) {
item_iterator it = mItems.find(*mUsage.begin());
- Delete(it->first, it->second);
+ DeleteObject(it->first, it->second);
mUsage.erase(mUsage.begin());
mItems.erase(it);
}