ITK  5.0.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:
55  ITK_DISALLOW_COPY_AND_ASSIGN(StreamingImageIOBase);
56 
61 
63  itkTypeMacro(StreamingImageIOBase, ImageIOBase);
64 
65  // see super class for documentation
66  //
67  // overidden to return true
68  bool CanStreamWrite() override;
69 
70  // see super class for documentation
71  //
72  // overidden to return true
73  bool CanStreamRead() override;
74 
75  // see super class for documentation
76  //
77  // If UseStreamedReading is true, then returned region is the
78  // requested region parameter.
79  ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const override;
80 
81  // see super class for documentation
82  //
83  // Verifies the set file name meets the pasting requirements, then calls
84  // GetActualNumberOfSplitsForWritingCanStreamWrite
85  unsigned int GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
86  const ImageIORegion & pasteRegion,
87  const ImageIORegion & largestPossibleRegion) override;
88 
89 protected:
91  // virtual ~StreamingImageIOBase(); not needed
92  void PrintSelf(std::ostream & os, Indent indent) const override;
93 
101  virtual bool RequestedToStream() const;
102 
108  virtual bool ReadBufferAsBinary(std::istream & is, void *buffer, SizeType num);
109 
115  virtual bool WriteBufferAsBinary(std::ostream & is, const void *buffer, SizeType num);
116 
133  virtual bool StreamReadBufferAsBinary(std::istream & os, void *buffer);
134 
146  virtual bool StreamWriteBufferAsBinary(std::ostream & os, const void *buffer);
147 
149  virtual SizeType GetHeaderSize() const = 0;
150 
155  virtual SizeType GetDataPosition() const { return this->GetHeaderSize(); }
156 };
157 } // namespace itk
158 
159 #endif
Light weight base class for most itk classes.
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.
virtual SizeType GetDataPosition() const
Returns the byte offset into the file where the data is located.
::itk::intmax_t SizeType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:60