00001 /* $Id:cache.h jjs $ */ 00002 /* 00003 Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl> 00004 Part of the Moros Project http://moros.sourceforge.net/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License. 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY. 00010 00011 See the COPYING file for more details. 00012 */ 00013 00014 #ifndef __CACHE_H 00015 #define __CACHE_H 00016 00017 #include <string> 00018 #include <glibmm.h> 00019 #include <gdkmm.h> 00020 #include "../general/hashtable.h" 00021 00022 class picture { 00023 public: 00024 picture(std::string k); 00025 std::string key; 00026 Glib::RefPtr<Gdk::Pixbuf> image; 00027 picture *higher; 00028 picture *lower; 00029 }; 00030 00036 class cache { 00037 private: 00038 picture *lowest; 00039 picture *highest; 00040 int elements; 00041 hashtable<const char,picture> data; 00042 public: 00043 cache(); 00044 picture &operator[](std::string key); 00045 bool exists(std::string key); 00046 void clean(int max); 00047 void dump(); 00048 }; 00049 00050 #endif // __CACHE_H