InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mresourcefilecachex.h
1 /*************************************************************************
2  *
3  * ADOBE CONFIDENTIAL
4  * ___________________
5  *
6  * Copyright 2025 Adobe
7  * All Rights Reserved.
8  *
9  * NOTICE: All information contained herein is, and remains
10  * the property of Adobe and its suppliers, if any. The intellectual
11  * and technical concepts contained herein are proprietary to Adobe
12  * and its suppliers and are protected by all applicable intellectual
13  * property laws, including trade secret and copyright laws.
14  * Dissemination of this information or reproduction of this material
15  * is strictly forbidden unless prior written permission is obtained
16  * from Adobe.
17  **************************************************************************/
18 
19 #ifndef __MResourceFileCacheX_h__
20 #define __MResourceFileCacheX_h__
21 
22 #include "K2Vector.h"
23 #include "KeyValuePair.h"
24 
25 #ifdef __OBJC__
26 @class NSCache;
27 @class NSBundle;
28 @class NSString;
29 @class NSData;
30 #else
31 typedef struct objc_object NSCache;
32 typedef struct objc_object NSBundle;
33 typedef struct objc_object NSString;
34 typedef struct objc_object NSData;
35 #endif
36 
37 //========================================================================================
38 // Class MResourceFileCacheX
39 
63 {
64 public:
65  enum {
66  kDefaultRFCacheLength = 8,
67  kDefaultMaxBundleCount = 50, // Maximum number of bundles to cache
68  kDefaultMaxResourceCount = 50 // Maximum number of resource data entries to cache
69  };
70 
73 
76 
78  void CacheBundle(NSString* identifier, NSBundle* bundle);
79 
81  NSBundle* GetCachedBundle(NSString* identifier);
82 
84  void RemoveBundle(NSString* identifier);
85 
87  NSData* GetCachedResourceData(const IDFile& resourceFile);
88 
90  void RemoveResourceData(const IDFile& resourceFile);
91 
93  void SetMaxBundleCount(uint32 count);
94 
96  void SetMaxResourceCount(uint32 count);
97 
99  void ClearCache();
100 
102  bool16 DisableUnloading(bool16 disable = kTrue);
103 
105  void CacheResourceData(const IDFile& resourceFile, NSData* data);
106  void CloseResourceFile(const IDFile& resourceFile);
107  void CloseUnusedFiles();
108 
111 
112 private:
113  bool16 fUnloadingDisabled;
114  NSCache* fBundleCache; // Cache for bundles
115  NSCache* fResourceDataCache; // Cache for resource data
116 
117  // Helper method to convert IDFile to cache key
118  NSString* CreateCacheKey(const IDFile& resourceFile);
119 };
120 
121 #endif // __MResourceFileCacheX_h__