ITK  4.6.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 #include "ITKIOImageBaseExport.h"
21 
22 #include "itkImageIOBase.h"
23 
24 #include <fstream>
25 
26 namespace itk
27 {
52 class ITKIOImageBase_EXPORT StreamingImageIOBase:public ImageIOBase
53 {
54 public:
59 
61  itkTypeMacro(StreamingImageIOBase, ImageIOBase);
62 
63  // see super class for documentation
64  //
65  // overidden to return true
66  virtual bool CanStreamWrite(void) ITK_OVERRIDE;
67 
68  // see super class for documentation
69  //
70  // overidden to return true
71  virtual bool CanStreamRead(void) ITK_OVERRIDE;
72 
73  // see super class for documentation
74  //
75  // If UseStreamedReading is true, then returned region is the
76  // requested region parameter.
77  virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const ITK_OVERRIDE;
78 
79  // see super class for documentation
80  //
81  // Verifies the set file name meets the pasting requirements, then calls
82  // GetActualNumberOfSplitsForWritingCanStreamWrite
83  virtual unsigned int GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
84  const ImageIORegion & pasteRegion,
85  const ImageIORegion & largestPossibleRegion) ITK_OVERRIDE;
86 
87 protected:
89  // virtual ~StreamingImageIOBase(); not needed
90  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
91 
99  virtual bool RequestedToStream(void) const;
100 
106  virtual bool ReadBufferAsBinary(std::istream & is, void *buffer, SizeType num);
107 
113  virtual bool WriteBufferAsBinary(std::ostream & is, const void *buffer, SizeType num);
114 
131  virtual bool StreamReadBufferAsBinary(std::istream & os, void *buffer);
132 
144  virtual bool StreamWriteBufferAsBinary(std::ostream & os, const void *buffer);
145 
147  virtual SizeType GetHeaderSize(void) const = 0;
148 
153  virtual SizeType GetDataPosition(void) const { return this->GetHeaderSize(); }
154 
155 private:
156  StreamingImageIOBase(const Self &); //purposely not implemented
157  void operator=(const Self &); //purposely not implemented
158 };
159 } // namespace itk
160 
161 #endif
An ImageIORegion represents a structured region of data.
Abstract superclass defines image IO interface.
A base class for specific ImageIO file formats which support streaming.
::itk::intmax_t SizeType
Control indentation during Print() invocation.
Definition: itkIndent.h:49