![]() | InDesign SDK 20.5 |
#include <mresourcefilecachex.h>
Public Types | |
| enum | { kDefaultRFCacheLength = 8, kDefaultMaxBundleCount = 50, kDefaultMaxResourceCount = 50 } |
Public Member Functions | |
| void | CacheBundle (NSString *identifier, NSBundle *bundle) |
| NSBundle * | GetCachedBundle (NSString *identifier) |
| void | RemoveBundle (NSString *identifier) |
| NSData * | GetCachedResourceData (const IDFile &resourceFile) |
| void | RemoveResourceData (const IDFile &resourceFile) |
| void | SetMaxBundleCount (uint32 count) |
| void | SetMaxResourceCount (uint32 count) |
| void | ClearCache () |
| bool16 | DisableUnloading (bool16 disable=kTrue) |
| void | CacheResourceData (const IDFile &resourceFile, NSData *data) |
| void | CloseResourceFile (const IDFile &resourceFile) |
| void | CloseUnusedFiles () |
Static Public Member Functions | |
| static MResourceFileCacheX & | GetSharedCache () |
Static Public Attributes | |
| static MResourceFileCacheX | fResourceFileCache |
Implementation of a cache for resource bundles and files This provides efficient caching of NSBundle resources and maintains compatibility with legacy resource handling. The cache is thread-safe and handles automatic cleanup of unused resources.
For modern resource handling, use the bundle-based methods:
The cache implements an eviction policy based on:
Caching happens behind the scenes and is transparent to almost all clients. The one exception is that a bug in the Mac OS X Nav services dialogs can clobber one of our resource files if we have any unused but cached resource files. To avoid this call MResourceFileCacheX::fResourceFileCache.CloseUnusedFiles() to empty the cache of unused files just prior to using a Nav Services dialog, and at the end of any callbacks that might cause a resource file to be opened or closed
| void MResourceFileCacheX::CacheBundle | ( | NSString * | identifier, |
| NSBundle * | bundle | ||
| ) |
Cache a bundle with its identifier
| void MResourceFileCacheX::CacheResourceData | ( | const IDFile & | resourceFile, |
| NSData * | data | ||
| ) |
Legacy support for resource file handling
| void MResourceFileCacheX::ClearCache | ( | ) |
Clear all cached bundles and resource data
| bool16 MResourceFileCacheX::DisableUnloading | ( | bool16 | disable = kTrue | ) |
Flag to disable unloading of cached but unused resources
| NSBundle* MResourceFileCacheX::GetCachedBundle | ( | NSString * | identifier | ) |
Get a cached bundle by identifier
| NSData* MResourceFileCacheX::GetCachedResourceData | ( | const IDFile & | resourceFile | ) |
Get cached resource data for a file
| static |
Get the shared cache instance
| void MResourceFileCacheX::RemoveBundle | ( | NSString * | identifier | ) |
Remove a bundle from the cache
| void MResourceFileCacheX::RemoveResourceData | ( | const IDFile & | resourceFile | ) |
Remove resource data from cache
| void MResourceFileCacheX::SetMaxBundleCount | ( | uint32 | count | ) |
Set maximum number of bundles to cache
| void MResourceFileCacheX::SetMaxResourceCount | ( | uint32 | count | ) |
Set maximum number of resource data entries to cache
| static |
Provides access to the resource cache