Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkCacheManager.h
Go to the documentation of this file.
1#ifndef __vtkCacheManager_h
2#define __vtkCacheManager_h
3
4// MRML includes
5#include "vtkMRML.h"
6class vtkCallbackCommand;
7class vtkMRMLScene;
8
9// VTK includes
10#include <vtkObject.h>
11
12// STD includes
13#include <string>
14#include <vector>
15#include <map>
16
17#ifndef vtkObjectPointer
18# define vtkObjectPointer(xx) (reinterpret_cast<vtkObject**>((xx)))
19#endif
20
21class VTK_MRML_EXPORT vtkCacheManager : public vtkObject
22{
23public:
26 vtkTypeMacro(vtkCacheManager, vtkObject);
27 void PrintSelf(ostream& os, vtkIndent indent) override;
28
29 vtkGetMacro(InsufficientFreeBufferNotificationFlag, int);
30 vtkSetMacro(InsufficientFreeBufferNotificationFlag, int);
31
37 virtual void SetRemoteCacheDirectory(const char* dir);
38
42
48 void DeleteFromCachedFileList(const char* target);
49
50 // Description:
52 void DeleteFromCache(const char* target);
53
62
68
74 virtual int IsRemoteReference(const char* uri);
77 virtual int IsLocalReference(const char* uri);
78
83 virtual int LocalFileExists(const char* uri);
84
89 const char* FindCachedFile(const char* target, const char* dirname);
90
96 virtual int CachedFileExists(const char* filename);
97
106 const char* GetFilenameFromURI(const char* uri);
107 const char* AddCachePathToFilename(const char* filename);
108 const char* EncodeURI(const char* uri);
109
112 float ComputeCacheSize(const char* dirname, unsigned long size);
115
116 std::vector<std::string> GetCachedFiles() const;
117
119 vtkGetMacro(RemoteCacheLimit, int);
120 vtkSetMacro(RemoteCacheLimit, int);
121 vtkSetMacro(CurrentCacheSize, float);
122 vtkGetMacro(RemoteCacheFreeBufferSize, int);
123 vtkSetMacro(RemoteCacheFreeBufferSize, int);
124 vtkGetMacro(EnableForceRedownload, int);
125 vtkSetMacro(EnableForceRedownload, int);
126 // vtkGetMacro ( EnableRemoteCacheOverwriting, int );
127 // vtkSetMacro ( EnableRemoteCacheOverwriting, int );
128 void SetMRMLScene(vtkMRMLScene* scene) { this->MRMLScene = scene; }
129 void MapFileToURI(const char* uri, const char* fname);
130
131 void MarkNode(std::string);
133 enum
134 {
138 };
139
141 enum
142 {
148 };
149
150 std::map<std::string, std::string> uriMap;
151 const char* GetFileFromURIMap(const char* uri);
152
153private:
154 int InsufficientFreeBufferNotificationFlag;
155 int RemoteCacheLimit;
156 float CurrentCacheSize;
157 int RemoteCacheFreeBufferSize;
158 int EnableForceRedownload;
159 // int EnableRemoteCacheOverwriting;
160 vtkMRMLScene* MRMLScene;
161
162 std::string RemoteCacheDirectory;
163 int GetCachedFileList(const char* dirname);
164 std::vector<std::string> GetAllCachedFiles();
169 std::vector<std::string> CachedFileList;
170
171protected:
176
179 vtkCallbackCommand* CallbackCommand;
180};
181
182#endif
void DeleteFromCachedFileList(const char *target)
Removes a target from the list of locally cached files and directories.
void UpdateCacheInformation()
Called when a file is loaded or removed from the cache.
virtual int IsLocalReference(const char *uri)
Looks for a 'file://' in the URI and if present, returns true.
~vtkCacheManager() override
vtkCallbackCommand * CallbackCommand
Holder for callback.
const char * GetFilenameFromURI(const char *uri)
virtual int CachedFileExists(const char *filename)
const char * EncodeURI(const char *uri)
void CacheSizeCheck()
float GetFreeCacheSpaceRemaining()
void FreeCacheBufferCheck()
void DeleteFromCache(const char *target)
Remove a target directory or file from the cache.
void operator=(const vtkCacheManager &)
void MarkNodesBeforeDeletingDataFromCache(const char *)
const char * GetFileFromURIMap(const char *uri)
float ComputeCacheSize(const char *dirname, unsigned long size)
void MapFileToURI(const char *uri, const char *fname)
const char * GetRemoteCacheDirectory()
Returns the name of the directory to use for local file caching.
virtual void SetRemoteCacheDirectory(const char *dir)
std::vector< std::string > GetCachedFiles() const
static vtkCacheManager * New()
The Usual vtk class functions.
const char * AddCachePathToFilename(const char *filename)
virtual int LocalFileExists(const char *uri)
std::map< std::string, std::string > uriMap
vtkCacheManager(const vtkCacheManager &)
void PrintSelf(ostream &os, vtkIndent indent) override
float GetCurrentCacheSize()
void SetMRMLScene(vtkMRMLScene *scene)
const char * FindCachedFile(const char *target, const char *dirname)
void MarkNode(std::string)
virtual int IsRemoteReference(const char *uri)
A set of MRML Nodes that supports serialization and undo/redo.