|
Slicer 5.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
Manages the on-disk remote cache used by MRML storage. More...
#include <Libs/MRML/Core/vtkCacheManager.h>


Classes | |
| struct | CacheEntry |
| Describes a top-level item (file or folder) in the cache directory. More... | |
Public Types | |
| enum | { NoCachedFile = 0 , OldCachedFile , CachedFile } |
| Currently these are not used. More... | |
| enum | { InsufficientFreeBufferEvent = 21000 , CacheLimitExceededEvent , CacheDeleteEvent , CacheDirtyEvent , CacheClearEvent } |
| typedef vtkObject | Superclass |
Public Member Functions | |
| virtual bool | CachedFileExists (const char *filename) |
| virtual bool | CachedFileExists (const std::string &filename) |
| bool | ClearCache () |
| Removes all files from the cachedir. | |
| bool | CreateSentinelFile () const |
| Creates the sentinel file in the current cache directory. | |
| bool | CreateSentinelFileInDirectory (const std::string &directoryPath) const |
| Creates the sentinel file in the specified directory. | |
| void | DeleteFromCache (const char *target) |
| void | DeleteFromCache (const std::string &filename) |
| std::string | EncodeURI (const char *uri) |
| std::string | FindCachedFile (const char *target, const char *dirname) |
| std::vector< std::string > | GetCachedFiles () const |
| std::vector< std::string > | GetCachedFilesInDirectory (const std::string &directoryPath) |
| std::vector< CacheEntry > | GetCacheEntries () const |
| virtual const char * | GetClassName () |
| float | GetCurrentCacheSize () |
| Current cache size in MB. Updated by UpdateCacheInformation(). | |
| virtual int | GetEnableForceRedownload () |
| const char * | GetFileFromURIMap (const char *uri) |
| std::string | GetFilenameFromURI (const char *uri) |
| std::string | GetFilenameFromURI (const std::string &uri) |
| float | GetFreeCacheSpaceRemaining () |
| Returns the amount of free space remaining in the cache directory, in MB. Updated by UpdateCacheInformation(). | |
| virtual int | GetInsufficientFreeBufferNotificationFlag () |
| const char * | GetRemoteCacheDirectory () |
| Returns the name of the directory to use for local file caching. | |
| virtual int | GetRemoteCacheLimit () |
| Cache size limit in MB. | |
| std::string | GetSentinelFileName () const |
| Sentinel file name used to identify cache directories where file deletion is allowed. | |
| bool | HasSentinelFile () const |
| True if the sentinel file exists in the current cache directory. | |
| bool | HasSentinelFileInDirectory (const std::string &directoryPath) const |
| True if the sentinel file exists in the specified directory. | |
| virtual int | IsA (const char *type) |
| bool | IsDirectoryEmpty (const std::string &directoryPath) const |
| Returns true if the specified directory is empty. | |
| virtual bool | IsLocalReference (const char *uri) |
| Looks for a 'file://' in the URI and if present, returns true. | |
| virtual bool | IsRemoteReference (const char *uri) |
| virtual bool | LocalFileExists (const char *uri) |
| void | MapFileToURI (const char *uri, const char *fname) |
| void | PrintSelf (ostream &os, vtkIndent indent) override |
| bool | PruneCache () |
| virtual void | SetEnableForceRedownload (int) |
| virtual void | SetInsufficientFreeBufferNotificationFlag (int) |
| void | SetMRMLScene (vtkMRMLScene *scene) |
| virtual void | SetRemoteCacheDirectory (const char *dir) |
| virtual void | SetRemoteCacheDirectory (const std::string &dir) |
| virtual void | SetRemoteCacheLimit (int) |
| void | UpdateCacheInformation () |
| Called when a file is loaded or removed from the cache. | |
Static Public Member Functions | |
| static int | IsTypeOf (const char *type) |
| static vtkCacheManager * | New () |
| The Usual vtk class functions. | |
| static vtkCacheManager * | SafeDownCast (vtkObject *o) |
Protected Member Functions | |
| void | operator= (const vtkCacheManager &) |
| vtkCacheManager () | |
| vtkCacheManager (const vtkCacheManager &) | |
| ~vtkCacheManager () override | |
Protected Attributes | |
| vtkCallbackCommand * | CallbackCommand |
| Holder for callback. | |
Manages the on-disk remote cache used by MRML storage.
The class manages a folder that stores temporary files, mostly used for local caching of remote data.
The cache folder needs to be cleaned when the maximum size is reached. To prevent accidental deletion of non-cache user data, the class uses a "sentinel file" mechanism. Presence of a sentinel file (.slicer-cache) in the folder marks it as owned by the cache manager, allowing the cache manager to delete files in it. Deletion is strictly limited to files within the cache directory (symlinks are resolved and file is only deleted if the canonicalized path is inside the cache root folder).
Definition at line 32 of file vtkCacheManager.h.
| typedef vtkObject vtkCacheManager::Superclass |
Definition at line 37 of file vtkCacheManager.h.
| anonymous enum |
Currently these are not used.
| Enumerator | |
|---|---|
| NoCachedFile | |
| OldCachedFile | |
| CachedFile | |
Definition at line 172 of file vtkCacheManager.h.
| anonymous enum |
| Enumerator | |
|---|---|
| InsufficientFreeBufferEvent | |
| CacheLimitExceededEvent | |
| CacheDeleteEvent | |
| CacheDirtyEvent | |
| CacheClearEvent | |
Definition at line 179 of file vtkCacheManager.h.
|
protected |
|
overrideprotected |
|
protected |
|
virtual |
Checks to see if the The URI provided exists on disk. If not, it appends the Remote Cache Directory path and checks again, in case no path was provided. If neither exists, returns false. If one exists, returns true.
|
virtual |
| bool vtkCacheManager::ClearCache | ( | ) |
Removes all files from the cachedir.
| bool vtkCacheManager::CreateSentinelFile | ( | ) | const |
Creates the sentinel file in the current cache directory.
| bool vtkCacheManager::CreateSentinelFileInDirectory | ( | const std::string & | directoryPath | ) | const |
Creates the sentinel file in the specified directory.
| void vtkCacheManager::DeleteFromCache | ( | const char * | target | ) |
Remove a target directory or file from the cache folder. If the target is a directory, it will be removed recursively. Before deletion, any MRML nodes that hold the URI as a reference will be marked as "modified since read".
| void vtkCacheManager::DeleteFromCache | ( | const std::string & | filename | ) |
| std::string vtkCacheManager::EncodeURI | ( | const char * | uri | ) |
| std::string vtkCacheManager::FindCachedFile | ( | const char * | target, |
| const char * | dirname ) |
Takes a filename and a dirname (usually called with the RemoteCachedDirectory) and returns the full path of the filename if it exists under the dirname.
| std::vector< std::string > vtkCacheManager::GetCachedFiles | ( | ) | const |
Get list of cached files. Updated by UpdateCacheInformation(). Get files in the folder, ordered by modification time from newest to oldest. Does not include the sentinel file.
| std::vector< std::string > vtkCacheManager::GetCachedFilesInDirectory | ( | const std::string & | directoryPath | ) |
Get files in the folder, ordered by modification time from newest to oldest. Does not include the sentinel file.
| std::vector< CacheEntry > vtkCacheManager::GetCacheEntries | ( | ) | const |
Returns one CacheEntry per top-level item in the cache directory. Updated by UpdateCacheInformation() Entries are sorted newest-first (descending ModifiedTime). Does not include the sentinel file. CacheEntry::ExceedsCacheSize is set for entries that PruneCache() would evict.
|
virtual |
| float vtkCacheManager::GetCurrentCacheSize | ( | ) |
Current cache size in MB. Updated by UpdateCacheInformation().
|
virtual |
| const char * vtkCacheManager::GetFileFromURIMap | ( | const char * | uri | ) |
| std::string vtkCacheManager::GetFilenameFromURI | ( | const char * | uri | ) |
Extracts the filename from the URI and prepends the Remote Cache Directory path to it. Returns the full path. NOTE: this method looks at a filename's extension and if appended version numbers have been added, it attempts to strip them out of the extension and add them to the filenamebase. So filename.nrrd_010 would become filename.nrrd. This will cause problems for any file type with an '_' in its extension.
| std::string vtkCacheManager::GetFilenameFromURI | ( | const std::string & | uri | ) |
| float vtkCacheManager::GetFreeCacheSpaceRemaining | ( | ) |
Returns the amount of free space remaining in the cache directory, in MB. Updated by UpdateCacheInformation().
|
virtual |
| const char * vtkCacheManager::GetRemoteCacheDirectory | ( | ) |
Returns the name of the directory to use for local file caching.
|
virtual |
Cache size limit in MB.
| std::string vtkCacheManager::GetSentinelFileName | ( | ) | const |
Sentinel file name used to identify cache directories where file deletion is allowed.
| bool vtkCacheManager::HasSentinelFile | ( | ) | const |
True if the sentinel file exists in the current cache directory.
| bool vtkCacheManager::HasSentinelFileInDirectory | ( | const std::string & | directoryPath | ) | const |
True if the sentinel file exists in the specified directory.
|
virtual |
| bool vtkCacheManager::IsDirectoryEmpty | ( | const std::string & | directoryPath | ) | const |
Returns true if the specified directory is empty.
|
virtual |
Looks for a 'file://' in the URI and if present, returns true.
|
virtual |
Checks to see if a URI appears to point to remote location and returns true if so. Looks for a '://' and if present, checks to see if the prefix is 'file'. If not 'file' but the thing:/// pattern exists, then returns true.
|
static |
|
virtual |
Checks to see if a URI is a file on disk and returns true if so. Strips off a file:/// prefix if present, and expects an absolute path.
| void vtkCacheManager::MapFileToURI | ( | const char * | uri, |
| const char * | fname ) |
|
static |
The Usual vtk class functions.
|
protected |
|
override |
| bool vtkCacheManager::PruneCache | ( | ) |
Delete oldest files until on-disk cache usage fits within RemoteCacheLimit. Returns true on success and false on failure.
|
static |
|
virtual |
|
virtual |
|
inline |
Definition at line 40 of file vtkCacheManager.h.
|
virtual |
Sets the name of the directory to use for local file caching Does some checking to make sure this is a valid directory on the local system. Makes sure there's NO "/" at the end of the string, or kwsys/SystemTools will not see as a valid dir.
|
inlinevirtual |
Definition at line 48 of file vtkCacheManager.h.
|
virtual |
| void vtkCacheManager::UpdateCacheInformation | ( | ) |
Called when a file is loaded or removed from the cache.
|
protected |
Holder for callback.
Definition at line 234 of file vtkCacheManager.h.