Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLStorageNode.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkMRMLStorageNode.h,v $
10  Date: $Date: 2006/03/19 17:12:29 $
11  Version: $Revision: 1.3 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkMRMLStorageNode_h
16 #define __vtkMRMLStorageNode_h
17 
18 // MRML includes
19 #include "vtkMRMLNode.h"
21 
22 class vtkURIHandler;
23 
24 // VTK includes
25 class vtkStringArray;
26 
27 // STD includes
28 #include <vector>
29 
33 class VTK_MRML_EXPORT vtkMRMLStorageNode : public vtkMRMLNode
34 {
35 public:
37  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
38 
39  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE = 0;
40 
43  virtual vtkMRMLStorableNode* GetStorableNode();
44 
47  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
48 
58  virtual int ReadData(vtkMRMLNode *refNode, bool temporaryFile = false);
59 
64  virtual int WriteData(vtkMRMLNode *refNode);
65 
68  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
69 
72  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
73 
76  virtual const char* GetNodeTagName() VTK_OVERRIDE = 0;
77 
80  vtkSetStringMacro(FileName);
81  vtkGetStringMacro(FileName);
82 
88  virtual std::string GetSupportedFileExtension(const char* fileName = NULL, bool includeReadable = true, bool includeWriteable = true);
89 
92  const char *GetNthFileName(int n) const;
93 
96  vtkBooleanMacro(UseCompression, int);
97  vtkGetMacro(UseCompression, int);
98  vtkSetMacro(UseCompression, int);
99 
102  vtkSetStringMacro(URI);
103  vtkGetStringMacro(URI);
104 
105  vtkGetObjectMacro (URIHandler, vtkURIHandler);
106  virtual void SetURIHandler(vtkURIHandler* uriHandler);
107 
110  virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData ) VTK_OVERRIDE;
111 
120  enum
121  {
127  Cancelled
128  };
129 
131  vtkGetMacro(ReadState,int);
132  vtkSetMacro(ReadState,int);
133  void SetReadStatePending() { this->SetReadState(this->Pending); };
134  void SetReadStateIdle() { this->SetReadState(this->Idle); };
135  void SetReadStateScheduled() { this->SetReadState(this->Scheduled); };
136  void SetReadStateTransferring() { this->SetReadState(this->Transferring); };
137  void SetReadStateTransferDone() { this->SetReadState(this->TransferDone); };
138  void SetReadStateCancelled() { this->SetReadState(this->Cancelled); };
139  const char *GetStateAsString(int state);
140  const char *GetReadStateAsString() { return this->GetStateAsString(this->ReadState); };
141 
144  vtkGetMacro(WriteState,int);
145  vtkSetMacro(WriteState,int);
146  void SetWriteStatePending() { this->SetWriteState(this->Pending); };
147  void SetWriteStateIdle() { this->SetWriteState(this->Idle); };
148  void SetWriteStateScheduled() { this->SetWriteState(this->Scheduled); };
149  void SetWriteStateTransferring() { this->SetWriteState(this->Transferring); };
150  void SetWriteStateTransferDone() { this->SetWriteState(this->TransferDone); };
151  void SetWriteStateCancelled() { this->SetWriteState(this->Cancelled); };
152  const char *GetWriteStateAsString() { return this->GetStateAsString(this->WriteState); };
153 
157  std::string GetFullNameFromFileName();
158  std::string GetFullNameFromNthFileName(int n);
159 
171  virtual int SupportedFileType(const char *fileName);
172 
176  virtual vtkStringArray* GetSupportedReadFileTypes();
177 
181  virtual vtkStringArray* GetSupportedWriteFileTypes();
182 
188  virtual void GetFileExtensionsFromFileTypes(vtkStringArray* inputFileTypes, vtkStringArray* outputFileExtensions);
189 
192  vtkSetStringMacro(WriteFileFormat);
193  vtkGetStringMacro(WriteFileFormat);
194 
197  unsigned int AddFileName (const char *fileName);
200  void ResetFileNameList();
201 
205  {
206  return (int)this->FileNameList.size();
207  };
208 
212  int FileNameIsInList(const char *fileName);
213 
216  unsigned int AddURI(const char *uri);
217 
220  const char *GetNthURI(int n);
221 
224  void ResetURIList();
225 
229  {
230  return (int)this->URIList.size();
231  }
232 
235  void SetDataDirectory(const char* dataDirName);
238  void SetURIPrefix(const char *uriPrefix);
239 
242  virtual const char* GetDefaultWriteFileExtension();
243 
248  virtual void SetDefaultWriteFileExtension(const char* ext);
249 
252  void ResetNthFileName(int n, const char *fileName);
255  void ResetNthURI(int n, const char *uri);
256 
261  int IsFilePathRelative(const char * filepath);
262 
267  const char *GetAbsoluteFilePath(const char *inputPath);
268 
271  vtkSetStringMacro(TempFileName);
272  vtkGetStringMacro(TempFileName);
273 
277  void InvalidateFile();
278 
281  vtkTimeStamp GetStoredTime();
282 
289  virtual bool CanReadInReferenceNode(vtkMRMLNode* refNode) = 0;
295  virtual bool CanWriteFromReferenceNode(vtkMRMLNode* refNode);
296 
301  virtual void ConfigureForDataExchange() {};
302 
305  static std::string GetLowercaseExtensionFromFileName(const std::string& filename);
306 
309  std::string GetFileNameWithoutExtension(const char* fileName = NULL);
310 
312  vtkSetMacro(CompressionParameter, std::string);
313  vtkGetMacro(CompressionParameter, std::string);
314 
316  virtual std::vector<std::string> GetCompressionPresetDisplayNames();
317 
319  virtual std::string GetCompressionParameterFromDisplayName(const std::string& name);
320 
322  virtual std::string GetDisplayNameFromCompressionParameter(const std::string& preset);
323 
325  virtual int GetNumberOfCompressionPresets();
326 
330  {
332  {
333  }
334 
335  CompressionPreset(const std::string &parameter, const std::string &name)
336  : CompressionParameter(parameter)
337  , DisplayName(name)
338  {
339  }
340 
341  std::string CompressionParameter;
342  std::string DisplayName;
343  };
344 
346  virtual const std::vector<CompressionPreset> GetCompressionPresets();
347 
348 protected:
352  void operator=(const vtkMRMLStorageNode&);
353 
357  virtual int ReadDataInternal(vtkMRMLNode* refNode);
358 
362  virtual int WriteDataInternal(vtkMRMLNode* refNode);
363 
367  void StageReadData ( vtkMRMLNode *refNode );
368 
372  void StageWriteData ( vtkMRMLNode *refNode );
373 
374  char *FileName;
376  char *URI;
381  std::string CompressionParameter;
382  std::vector<CompressionPreset> CompressionPresets;
383 
386  std::vector<std::string> FileNameList;
389  std::vector<std::string> URIList;
391  vtkStringArray* SupportedReadFileTypes;
392 
395  vtkStringArray* SupportedWriteFileTypes;
397 
400  virtual void InitializeSupportedReadFileTypes();
404  virtual void InitializeSupportedWriteFileTypes();
409  virtual void UpdateCompressionPresets();
410 
415  vtkTimeStamp* StoredTime;
416 
417  vtkWeakPointer<vtkMRMLStorableNode> LastFoundStorableNode;
418 };
419 
420 #endif
vtkWeakPointer< vtkMRMLStorableNode > LastFoundStorableNode
std::vector< std::string > FileNameList
An array of file names, should contain the FileName but may not
virtual void ConfigureForDataExchange()
std::string CompressionParameter
int GetNumberOfFileNames() const
See how many file names were generated during ExecuteInformation
LRU Cache.
void operator=(const vtkMRMLNode &)
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
vtkStringArray * SupportedReadFileTypes
List of supported extensions to read in.
MRML node to represent a 3D surface model.
vtkStringArray * SupportedWriteFileTypes
A superclass for other storage nodes.
vtkURIHandler * URIHandler
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
std::string DefaultWriteFileExtension
List of supported extensions to write in.
const char * GetWriteStateAsString()
vtkTimeStamp * StoredTime
std::vector< std::string > URIList
An array of URI&#39;s, should contain the URI but may not
CompressionPreset(const std::string &parameter, const std::string &name)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
std::vector< CompressionPreset > CompressionPresets
const char * GetReadStateAsString()
int GetNumberOfURIs()
Return how many uri names this storage node holds in it&#39;s list