diff options
author | lordjaxom <lordjaxom> | 2004-12-14 20:05:40 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-12-14 20:05:40 +0000 |
commit | b8f29c674cc0ccca207123342c1344bbd0f13796 (patch) | |
tree | 2af468bf7acc6df510241c1090d7e6538b6b3cf1 /cache.h | |
parent | 3b0999969632e2820b846ca8adcef6b346ff7441 (diff) | |
download | vdr-plugin-text2skin-b8f29c674cc0ccca207123342c1344bbd0f13796.tar.gz vdr-plugin-text2skin-b8f29c674cc0ccca207123342c1344bbd0f13796.tar.bz2 |
1.0-pre4v1.0-pre4
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 61 |
1 files changed, 56 insertions, 5 deletions
@@ -1,11 +1,12 @@ /* - * $Id: cache.h,v 1.5 2004/06/18 16:08:11 lordjaxom Exp $ + * $Id: cache.h,v 1.3 2004/12/14 20:02:31 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_CACHE_HPP #define VDR_TEXT2SKIN_CACHE_HPP #include "common.h" +#include "xml/object.h" #include <vdr/tools.h> #include <map> #include <vector> @@ -13,17 +14,59 @@ class cText2SkinBitmap; +struct tBitmapSpec { + std::string Filename; + int Alpha; + int Width; + int Height; + int Colors; + + tBitmapSpec(const std::string &filename, int alpha, int width, int height, int colors): + Filename(filename), Alpha(alpha), Width(width), Height(height), Colors(colors) {} + + bool operator<(const tBitmapSpec &Src) const; + bool operator==(const tBitmapSpec &Src) const; +}; + +inline bool tBitmapSpec::operator<(const tBitmapSpec &Src) const +{ + if (Filename == Src.Filename) { + if (Alpha == Src.Alpha) { + if (Width == Src.Width) { + if (Height == Src.Height) + return Colors < Src.Colors; + return Height < Src.Height; + } + return Width < Src.Width; + } + return Alpha < Src.Alpha; + } + return Filename < Src.Filename; +} + +inline bool tBitmapSpec::operator==(const tBitmapSpec &Src) const +{ + return Filename == Src.Filename + && Alpha == Src.Alpha + && Width == Src.Width + && Height == Src.Height + && Colors == Src.Colors; +} + class cText2SkinCache { private: - typedef std::string key_type; + typedef std::string name_type; + typedef tBitmapSpec key_type; typedef cText2SkinBitmap* data_type; typedef std::map<key_type,data_type> item_map; typedef item_map::iterator item_iterator; + typedef std::map<name_type,item_map> name_map; + typedef name_map::iterator name_iterator; typedef std::vector<key_type> usage_list; typedef usage_list::iterator usage_iterator; - item_map mItems; + name_map mNames; usage_list mUsage; int mMaxItems; @@ -37,12 +80,20 @@ public: void Reset(void); void Flush(void); bool Contains(const key_type &Key); + bool Contains(const name_type &Name); data_type &operator[](const key_type &Key); - uint Count(void) { return mItems.size(); } + uint Count(void) { return mUsage.size(); } }; inline bool cText2SkinCache::Contains(const key_type &Key) { - return mItems.find(Key) != mItems.end(); + name_iterator it = mNames.find(Key.Filename); + if (it != mNames.end()) + return (*it).second.find(Key) != (*it).second.end(); + return false; +} + +inline bool cText2SkinCache::Contains(const name_type &Key) { + return mNames.find(Key) != mNames.end(); } #endif // VDR_TEXT2SKIN_CACHE_HPP |