Line data Source code
1 0 : /* 2 : 3 : OOCacheManager.h 4 : By Jens Ayton 5 : 6 : Singleton class responsible for handling Oolite's data cache. 7 : The cache manager stores arbitrary property lists in separate namespaces 8 : (referred to simply as caches). The cache is emptied if it was created with a 9 : different verison of Oolite, or if it was created on a system with a different 10 : byte sex. 11 : 12 : Oolite 13 : Copyright (C) 2004-2013 Giles C Williams and contributors 14 : 15 : This program is free software; you can redistribute it and/or 16 : modify it under the terms of the GNU General Public License 17 : as published by the Free Software Foundation; either version 2 18 : of the License, or (at your option) any later version. 19 : 20 : This program is distributed in the hope that it will be useful, 21 : but WITHOUT ANY WARRANTY; without even the implied warranty of 22 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 : GNU General Public License for more details. 24 : 25 : You should have received a copy of the GNU General Public License 26 : along with this program; if not, write to the Free Software 27 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 28 : MA 02110-1301, USA. 29 : 30 : */ 31 : 32 : #import "OOCocoa.h" 33 : 34 : 35 0 : @interface OOCacheManager: NSObject 36 : { 37 : @private 38 0 : NSMutableDictionary *_caches; 39 0 : id _scheduledWrite; 40 0 : BOOL _permitWrites; 41 0 : BOOL _dirty; 42 : } 43 : 44 0 : + (OOCacheManager *)sharedCache; 45 : 46 0 : - (id)objectForKey:(NSString *)inKey inCache:(NSString *)inCacheKey; 47 0 : - (void)setObject:(id)inElement forKey:(NSString *)inKey inCache:(NSString *)inCacheKey; 48 0 : - (void)removeObjectForKey:(NSString *)inKey inCache:(NSString *)inCacheKey; 49 0 : - (void)clearCache:(NSString *)inCacheKey; 50 0 : - (void)clearAllCaches; 51 0 : - (void) reloadAllCaches; 52 : 53 0 : - (void)setAllowCacheWrites:(BOOL)flag; 54 : 55 0 : - (NSString *)cacheDirectoryPathCreatingIfNecessary:(BOOL)create; 56 : 57 0 : - (void)flush; 58 0 : - (void)finishOngoingFlush; // Wait for flush to complete. Does nothing if async flushing is disabled. 59 : 60 : @end