ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkStreamingImageIOBase_h 00019 #define __itkStreamingImageIOBase_h 00020 00021 #include "itkImageIOBase.h" 00022 00023 #include <fstream> 00024 00025 namespace itk 00026 { 00051 class ITK_EXPORT StreamingImageIOBase:public ImageIOBase 00052 { 00053 public: 00055 typedef StreamingImageIOBase Self; 00056 typedef ImageIOBase Superclass; 00057 typedef SmartPointer< Self > Pointer; 00058 00060 itkTypeMacro(StreamingImageIOBase, ImageIOBase); 00061 00062 // see super class for documentation 00063 // 00064 // overidden to return true 00065 virtual bool CanStreamWrite(void); 00066 00067 // see super class for documentation 00068 // 00069 // overidden to return true 00070 virtual bool CanStreamRead(void); 00071 00072 // see super class for documentation 00073 // 00074 // If UseStreamedReading is true, then returned region is the 00075 // requested region parameter. 00076 virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const; 00077 00078 // see super class for documentation 00079 // 00080 // Verifies the set file name meets the pasting requirements, then calls 00081 // GetActualNumberOfSplitsForWritingCanStreamWrite 00082 virtual unsigned int GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits, 00083 const ImageIORegion & pasteRegion, 00084 const ImageIORegion & largestPossibleRegion); 00085 00086 protected: 00087 StreamingImageIOBase(); 00088 // virtual ~StreamingImageIOBase(); not needed 00089 virtual void PrintSelf(std::ostream & os, Indent indent) const; 00090 00098 virtual bool RequestedToStream(void) const; 00099 00105 virtual bool ReadBufferAsBinary(std::istream & is, void *buffer, SizeType num); 00106 00112 virtual bool WriteBufferAsBinary(std::ostream & is, const void *buffer, SizeType num); 00113 00130 virtual bool StreamReadBufferAsBinary(std::istream & os, void *buffer); 00131 00143 virtual bool StreamWriteBufferAsBinary(std::ostream & os, const void *buffer); 00144 00146 virtual SizeType GetHeaderSize(void) const = 0; 00147 00152 virtual SizeType GetDataPosition(void) const { return this->GetHeaderSize(); } 00153 00159 virtual void OpenFileForReading(std::ifstream & os, const char *filename); 00160 00170 virtual void OpenFileForWriting(std::ofstream & os, const char *filename, bool truncate); 00171 00172 private: 00173 StreamingImageIOBase(const Self &); //purposely not implemented 00174 void operator=(const Self &); //purposely not implemented 00175 }; 00176 } // namespace itk 00177 00178 #endif 00179