Slicer  4.8
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"
20 class vtkURIHandler;
21 
22 // VTK includes
23 class vtkStringArray;
24 
25 // STD includes
26 #include <vector>
27 
31 class VTK_MRML_EXPORT vtkMRMLStorageNode : public vtkMRMLNode
32 {
33 public:
35  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
36 
37  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE = 0;
38 
41  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
42 
52  virtual int ReadData(vtkMRMLNode *refNode, bool temporaryFile = false);
53 
58  virtual int WriteData(vtkMRMLNode *refNode);
59 
62  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
63 
66  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
67 
70  virtual const char* GetNodeTagName() VTK_OVERRIDE = 0;
71 
74  vtkSetStringMacro(FileName);
75  vtkGetStringMacro(FileName);
76 
82  virtual std::string GetSupportedFileExtension(const char* fileName = NULL, bool includeReadable = true, bool includeWriteable = true);
83 
86  const char *GetNthFileName(int n) const;
87 
90  vtkBooleanMacro(UseCompression, int);
91  vtkGetMacro(UseCompression, int);
92  vtkSetMacro(UseCompression, int);
93 
96  vtkSetStringMacro(URI);
97  vtkGetStringMacro(URI);
98 
99  vtkGetObjectMacro (URIHandler, vtkURIHandler);
100  virtual void SetURIHandler(vtkURIHandler* uriHandler);
101 
104  virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData ) VTK_OVERRIDE;
105 
114  enum
115  {
121  Cancelled
122  };
123 
125  vtkGetMacro(ReadState,int);
126  vtkSetMacro(ReadState,int);
127  void SetReadStatePending() { this->SetReadState(this->Pending); };
128  void SetReadStateIdle() { this->SetReadState(this->Idle); };
129  void SetReadStateScheduled() { this->SetReadState(this->Scheduled); };
130  void SetReadStateTransferring() { this->SetReadState(this->Transferring); };
131  void SetReadStateTransferDone() { this->SetReadState(this->TransferDone); };
132  void SetReadStateCancelled() { this->SetReadState(this->Cancelled); };
133  const char *GetStateAsString(int state);
134  const char *GetReadStateAsString() { return this->GetStateAsString(this->ReadState); };
135 
138  vtkGetMacro(WriteState,int);
139  vtkSetMacro(WriteState,int);
140  void SetWriteStatePending() { this->SetWriteState(this->Pending); };
141  void SetWriteStateIdle() { this->SetWriteState(this->Idle); };
142  void SetWriteStateScheduled() { this->SetWriteState(this->Scheduled); };
143  void SetWriteStateTransferring() { this->SetWriteState(this->Transferring); };
144  void SetWriteStateTransferDone() { this->SetWriteState(this->TransferDone); };
145  void SetWriteStateCancelled() { this->SetWriteState(this->Cancelled); };
146  const char *GetWriteStateAsString() { return this->GetStateAsString(this->WriteState); };
147 
151  std::string GetFullNameFromFileName();
152  std::string GetFullNameFromNthFileName(int n);
153 
165  virtual int SupportedFileType(const char *fileName);
166 
170  virtual vtkStringArray* GetSupportedReadFileTypes();
171 
175  virtual vtkStringArray* GetSupportedWriteFileTypes();
176 
182  virtual void GetFileExtensionsFromFileTypes(vtkStringArray* inputFileTypes, vtkStringArray* outputFileExtensions);
183 
186  vtkSetStringMacro(WriteFileFormat);
187  vtkGetStringMacro(WriteFileFormat);
188 
191  unsigned int AddFileName (const char *fileName);
194  void ResetFileNameList();
195 
199  {
200  return (int)this->FileNameList.size();
201  };
202 
206  int FileNameIsInList(const char *fileName);
207 
210  unsigned int AddURI(const char *uri);
211 
214  const char *GetNthURI(int n);
215 
218  void ResetURIList();
219 
223  {
224  return (int)this->URIList.size();
225  }
226 
229  void SetDataDirectory(const char* dataDirName);
232  void SetURIPrefix(const char *uriPrefix);
233 
236  virtual const char* GetDefaultWriteFileExtension();
237 
242  virtual void SetDefaultWriteFileExtension(const char* ext);
243 
246  void ResetNthFileName(int n, const char *fileName);
249  void ResetNthURI(int n, const char *uri);
250 
255  int IsFilePathRelative(const char * filepath);
256 
261  const char *GetAbsoluteFilePath(const char *inputPath);
262 
265  vtkSetStringMacro(TempFileName);
266  vtkGetStringMacro(TempFileName);
267 
271  void InvalidateFile();
272 
275  vtkTimeStamp GetStoredTime();
276 
283  virtual bool CanReadInReferenceNode(vtkMRMLNode* refNode) = 0;
289  virtual bool CanWriteFromReferenceNode(vtkMRMLNode* refNode);
290 
295  virtual void ConfigureForDataExchange() {};
296 
299  static std::string GetLowercaseExtensionFromFileName(const std::string& filename);
300 
303  std::string GetFileNameWithoutExtension(const char* fileName = NULL);
304 
305 protected:
309  void operator=(const vtkMRMLStorageNode&);
310 
314  virtual int ReadDataInternal(vtkMRMLNode* refNode);
315 
319  virtual int WriteDataInternal(vtkMRMLNode* refNode);
320 
324  void StageReadData ( vtkMRMLNode *refNode );
325 
329  void StageWriteData ( vtkMRMLNode *refNode );
330 
331  char *FileName;
333  char *URI;
338 
341  std::vector<std::string> FileNameList;
344  std::vector<std::string> URIList;
346  vtkStringArray* SupportedReadFileTypes;
347 
350  vtkStringArray* SupportedWriteFileTypes;
352 
355  virtual void InitializeSupportedReadFileTypes();
359  virtual void InitializeSupportedWriteFileTypes();
360 
365  vtkTimeStamp* StoredTime;
366 };
367 
368 #endif
std::vector< std::string > FileNameList
An array of file names, should contain the FileName but may not.
virtual void ConfigureForDataExchange()
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.
vtkStringArray * SupportedWriteFileTypes
A supercalss 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.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
const char * GetReadStateAsString()
int GetNumberOfURIs()
Return how many uri names this storage node holds in it&#39;s list.