Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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"
6 class vtkCallbackCommand;
7 class 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 
21 class VTK_MRML_EXPORT vtkCacheManager : public vtkObject
22 {
23  public:
24 
26  static vtkCacheManager *New();
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 
42  const char *GetRemoteCacheDirectory ();
43 
46  void UpdateCacheInformation ( );
49  void DeleteFromCachedFileList ( const char * target );
50 
51  //Description:
53  void DeleteFromCache( const char *target );
54 
58  int ClearCache ( );
62  int ClearCacheCheck ( );
63 
68  void MarkNodesBeforeDeletingDataFromCache (const char *);
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 
111  void CacheSizeCheck();
112  void FreeCacheBufferCheck();
113  float ComputeCacheSize( const char *dirname, unsigned long size );
114  float GetCurrentCacheSize();
115  float GetFreeCacheSpaceRemaining();
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 );
129  void SetMRMLScene ( vtkMRMLScene *scene )
130  {
131  this->MRMLScene = scene;
132  }
133  void MapFileToURI ( const char *uri, const char *fname );
134 
135  void MarkNode ( std::string );
137  enum
138  {
139  NoCachedFile=0,
141  CachedFile
142  };
143 
145  enum
146  {
147  InsufficientFreeBufferEvent = 21000,
151  CacheClearEvent
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:
176  vtkCacheManager();
177  ~vtkCacheManager() override;
179  void operator=(const vtkCacheManager&);
180 
183  vtkCallbackCommand *CallbackCommand;
184 
185 };
186 
187 #endif
188 
void SetMRMLScene(vtkMRMLScene *scene)
std::map< std::string, std::string > uriMap
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
vtkCallbackCommand * CallbackCommand
Holder for callback