File indexing completed on 2024-04-28 16:08:40
0001 /*************************************************************************** 0002 * Copyright (C) 2013 by Linuxstopmotion contributors; * 0003 * see the AUTHORS file for details. * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef TCACHE_H_ 0022 #define TCACHE_H_ 0023 0024 #include <QObject> 0025 0026 struct TestLoader { 0027 typedef const char value_t; 0028 static value_t* lastFreed; 0029 static value_t* lastLoaded; 0030 static int freeCount; 0031 static value_t* load(const char* p) { 0032 lastLoaded = p; 0033 return p; 0034 } 0035 static void free(value_t* p) { 0036 lastFreed = p; 0037 ++freeCount; 0038 } 0039 }; 0040 0041 template<typename T> class LoadCache; 0042 0043 class TestCache : public QObject { 0044 Q_OBJECT 0045 LoadCache<TestLoader>* cache; 0046 public: 0047 TestCache(); 0048 ~TestCache(); 0049 private slots: 0050 void gettingTwiceReturnsSameInstance(); 0051 void leastRecentlyUsedIsFreed(); 0052 void clearFrees(); 0053 void dropFrees(); 0054 void droppedItemMustBeReloaded(); 0055 }; 0056 0057 0058 #endif