ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkStreamingImageIOBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkStreamingImageIOBase_h
19 #define __itkStreamingImageIOBase_h
20 
21 #include "itkImageIOBase.h"
22 
23 #include <fstream>
24 
25 namespace itk
26 {
51 class ITK_EXPORT StreamingImageIOBase:public ImageIOBase
52 {
53 public:
58 
60  itkTypeMacro(StreamingImageIOBase, ImageIOBase);
61 
62  // see super class for documentation
63  //
64  // overidden to return true
65  virtual bool CanStreamWrite(void);
66 
67  // see super class for documentation
68  //
69  // overidden to return true
70  virtual bool CanStreamRead(void);
71 
72  // see super class for documentation
73  //
74  // If UseStreamedReading is true, then returned region is the
75  // requested region parameter.
76  virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const;
77 
78  // see super class for documentation
79  //
80  // Verifies the set file name meets the pasting requirements, then calls
81  // GetActualNumberOfSplitsForWritingCanStreamWrite
82  virtual unsigned int GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
83  const ImageIORegion & pasteRegion,
84  const ImageIORegion & largestPossibleRegion);
85 
86 protected:
88  // virtual ~StreamingImageIOBase(); not needed
89  virtual void PrintSelf(std::ostream & os, Indent indent) const;
90 
98  virtual bool RequestedToStream(void) const;
99 
105  virtual bool ReadBufferAsBinary(std::istream & is, void *buffer, SizeType num);
106 
112  virtual bool WriteBufferAsBinary(std::ostream & is, const void *buffer, SizeType num);
113 
130  virtual bool StreamReadBufferAsBinary(std::istream & os, void *buffer);
131 
143  virtual bool StreamWriteBufferAsBinary(std::ostream & os, const void *buffer);
144 
146  virtual SizeType GetHeaderSize(void) const = 0;
147 
152  virtual SizeType GetDataPosition(void) const { return this->GetHeaderSize(); }
153 
159  virtual void OpenFileForReading(std::ifstream & os, const char *filename);
160 
170  virtual void OpenFileForWriting(std::ofstream & os, const char *filename, bool truncate);
171 
172 private:
173  StreamingImageIOBase(const Self &); //purposely not implemented
174  void operator=(const Self &); //purposely not implemented
175 };
176 } // namespace itk
177 
178 #endif
179