Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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{
23 public:
24
27 vtkTypeMacro(vtkCacheManager, vtkObject);
28 void PrintSelf(ostream& os, vtkIndent indent) override;
29
30 vtkGetMacro (InsufficientFreeBufferNotificationFlag, int );
31 vtkSetMacro (InsufficientFreeBufferNotificationFlag, int );
32
38 virtual void SetRemoteCacheDirectory (const char *dir );
39
43
49 void DeleteFromCachedFileList ( const char * target );
50
51 //Description:
53 void DeleteFromCache( const char *target );
54
58 int ClearCache ( );
63
69
75 virtual int IsRemoteReference ( const char *uri );
78 virtual int IsLocalReference ( const char *uri );
79
84 virtual int LocalFileExists ( const char *uri );
85
90 const char* FindCachedFile ( const char * target, const char *dirname );
91
97 virtual int CachedFileExists ( const char *filename );
98
107 const char* GetFilenameFromURI ( const char *uri );
108 const char* AddCachePathToFilename ( const char *filename );
109 const char* EncodeURI ( const char *uri );
110
113 float ComputeCacheSize( const char *dirname, unsigned long size );
116
117 std::vector< std::string > GetCachedFiles()const;
118
120 vtkGetMacro ( RemoteCacheLimit, int );
121 vtkSetMacro ( RemoteCacheLimit, int );
122 vtkSetMacro ( CurrentCacheSize, float );
123 vtkGetMacro ( RemoteCacheFreeBufferSize, int );
124 vtkSetMacro ( RemoteCacheFreeBufferSize, int );
125 vtkGetMacro ( EnableForceRedownload, int );
126 vtkSetMacro ( EnableForceRedownload, int );
127 //vtkGetMacro ( EnableRemoteCacheOverwriting, int );
128 //vtkSetMacro ( EnableRemoteCacheOverwriting, int );
130 {
131 this->MRMLScene = scene;
132 }
133 void MapFileToURI ( const char *uri, const char *fname );
134
135 void MarkNode ( std::string );
137 enum
138 {
142 };
143
145 enum
146 {
152 };
153
154 std::map<std::string, std::string> uriMap;
155 const char *GetFileFromURIMap (const char *uri );
156
157 private:
158 int InsufficientFreeBufferNotificationFlag;
159 int RemoteCacheLimit;
160 float CurrentCacheSize;
161 int RemoteCacheFreeBufferSize;
162 int EnableForceRedownload;
163 //int EnableRemoteCacheOverwriting;
164 vtkMRMLScene *MRMLScene;
165
166 std::string RemoteCacheDirectory;
167 int GetCachedFileList(const char *dirname);
168 std::vector< std::string > GetAllCachedFiles();
173 std::vector< std::string > CachedFileList;
174
175 protected:
180
183 vtkCallbackCommand *CallbackCommand;
184
185};
186
187#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.