vtkMRMLStorageNode.h

Go to the documentation of this file.
00001 /*=auto=========================================================================
00002 
00003   Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
00004 
00005   See Doc/copyright/copyright.txt
00006   or http://www.slicer.org/copyright/copyright.txt for details.
00007 
00008   Program:   3D Slicer
00009   Module:    $RCSfile: vtkMRMLStorageNode.h,v $
00010   Date:      $Date: 2006/03/19 17:12:29 $
00011   Version:   $Revision: 1.3 $
00012 
00013 =========================================================================auto=*/
00017 
00018 #ifndef __vtkMRMLStorageNode_h
00019 #define __vtkMRMLStorageNode_h
00020 
00021 #include "vtkMRML.h"
00022 #include "vtkMRMLNode.h"
00023 #include "vtkMRMLScene.h"
00024 #include "vtkURIHandler.h"
00025 
00026 class vtkStringArray;
00027 class vtkURIHandler;
00028 
00029 class VTK_MRML_EXPORT vtkMRMLStorageNode : public vtkMRMLNode
00030 {
00031   public:
00032   static vtkMRMLStorageNode *New(){return NULL;};
00033   vtkTypeMacro(vtkMRMLStorageNode,vtkMRMLNode);
00034   void PrintSelf(ostream& os, vtkIndent indent);
00035 
00036   virtual vtkMRMLNode* CreateNodeInstance() = 0;
00037 
00040   virtual void ReadXMLAttributes( const char** atts);
00041   
00046   virtual int ReadData(vtkMRMLNode *refNode) = 0;
00047 
00052   virtual int WriteData(vtkMRMLNode *refNode) = 0;
00053 
00056   virtual void WriteXML(ostream& of, int indent);
00057 
00060   virtual void Copy(vtkMRMLNode *node);
00061 
00064   virtual const char* GetNodeTagName() = 0;
00065 
00068   vtkSetStringMacro(FileName);
00069   vtkGetStringMacro(FileName);
00072   const char *GetNthFileName(int n) const;
00073 
00076   vtkGetMacro(UseCompression, int);
00077   vtkSetMacro(UseCompression, int);
00078   vtkBooleanMacro(UseCompression, int);
00079   
00082   vtkSetStringMacro(URI);
00083   vtkGetStringMacro(URI);
00084   
00085   vtkGetObjectMacro (URIHandler, vtkURIHandler);
00086   vtkSetObjectMacro (URIHandler, vtkURIHandler);
00087   
00090   virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData );
00091 
00095   void StageReadData ( vtkMRMLNode *refNode );
00099   void StageWriteData ( vtkMRMLNode *refNode );
00100 
00109   //BTX
00110   enum
00111   {
00112     Idle,
00113     Pending,
00114     Scheduled,
00115     Transferring,
00116     TransferDone,
00117     Cancelled
00118   };
00119   //ETX
00122   vtkGetMacro(ReadState,int);
00123   vtkSetMacro(ReadState,int);
00124   void SetReadStatePending() { this->SetReadState(this->Pending); };
00125   void SetReadStateIdle() { this->SetReadState(this->Idle); }; 
00126   void SetReadStateScheduled() { this->SetReadState(this->Scheduled); };
00127   void SetReadStateTransferring() { this->SetReadState(this->Transferring); }; 
00128   void SetReadStateTransferDone() { this->SetReadState(this->TransferDone); }; 
00129   void SetReadStateCancelled() { this->SetReadState(this->Cancelled); }; 
00130   const char *GetStateAsString(int state);
00131   const char *GetReadStateAsString() { return this->GetStateAsString(this->ReadState); };
00132   
00135   vtkGetMacro(WriteState,int);
00136   vtkSetMacro(WriteState,int);
00137   void SetWriteStatePending() { this->SetWriteState(this->Pending); };
00138   void SetWriteStateIdle() { this->SetWriteState(this->Idle); };
00139   void SetWriteStateScheduled() { this->SetWriteState(this->Scheduled); };
00140   void SetWriteStateTransferring() { this->SetWriteState(this->Transferring); };
00141   void SetWriteStateTransferDone() { this->SetWriteState(this->TransferDone); };
00142   void SetWriteStateCancelled() { this->SetWriteState(this->Cancelled); }; 
00143   const char *GetWriteStateAsString() { return this->GetStateAsString(this->WriteState); };
00144 
00148   //BTX
00149   std::string GetFullNameFromFileName();
00150   std::string GetFullNameFromNthFileName(int n);
00151   //ETX
00152 
00158   virtual int SupportedFileType(const char *fileName);
00159 
00163   virtual vtkStringArray* GetSupportedWriteFileTypes();
00164 
00167   vtkSetStringMacro(WriteFileFormat);
00168   vtkGetStringMacro(WriteFileFormat);
00169 
00172   unsigned int AddFileName (const char *fileName);
00175   void ResetFileNameList();
00176   
00179   int GetNumberOfFileNames() const
00180   {
00181     return (int)this->FileNameList.size();
00182   };
00183 
00187   int FileNameIsInList(const char *fileName);
00188   
00191   unsigned int AddURI(const char *uri);
00192 
00195   const char *GetNthURI(int n);
00196   
00199   void ResetURIList();
00200   
00203   int GetNumberOfURIs()
00204   {
00205     return (int)this->URIList.size();
00206   }
00207 
00210   void SetDataDirectory(const char* dataDirName);
00213   void SetURIPrefix(const char *uriPrefix);
00214   
00217   virtual const char* GetDefaultWriteFileExtension()
00218     {
00219     return NULL;
00220     };
00221 
00224   void ResetNthFileName(int n, const char *fileName);
00227   void ResetNthURI(int n, const char *uri);
00228 
00232   int IsFilePathRelative(const char * filepath);
00233 
00239   const char *GetAbsoluteFilePath(const char *inputPath);
00240   
00243   vtkSetStringMacro(TempFileName);
00244   vtkGetStringMacro(TempFileName);
00245   
00246 protected:
00247   vtkMRMLStorageNode();
00248   ~vtkMRMLStorageNode();
00249   vtkMRMLStorageNode(const vtkMRMLStorageNode&);
00250   void operator=(const vtkMRMLStorageNode&);
00251   
00252   char *FileName;
00253   char *TempFileName;
00254   char *URI;
00255   vtkURIHandler *URIHandler;
00256   int UseCompression;
00257   int ReadState;
00258   int WriteState;
00259 
00260   //BTX
00263   std::vector<std::string> FileNameList;
00266   std::vector<std::string> URIList;
00267   //ETX
00268   vtkStringArray* SupportedWriteFileTypes;
00269   char* WriteFileFormat;
00270 
00274   virtual void InitializeSupportedWriteFileTypes();
00275 
00276 };
00277 
00278 #endif
00279 
00280 
00281 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1