ITK  5.4.0
Insight Toolkit
itkStreamingImageIOBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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_MOVE(StreamingImageIOBase);
56 
61 
63  itkOverrideGetNameOfClassMacro(StreamingImageIOBase);
64 
65  // see super class for documentation
66  //
67  // overridden to return true
68  bool
69  CanStreamWrite() override;
70 
71  // see super class for documentation
72  //
73  // overridden to return true
74  bool
75  CanStreamRead() override;
76 
77  // see super class for documentation
78  //
79  // If UseStreamedReading is true, then returned region is the
80  // requested region parameter.
82  GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requestedRegion) const override;
83 
84  // see super class for documentation
85  //
86  // Verifies the set file name meets the pasting requirements, then calls
87  // GetActualNumberOfSplitsForWritingCanStreamWrite
88  unsigned int
89  GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
90  const ImageIORegion & pasteRegion,
91  const ImageIORegion & largestPossibleRegion) override;
92 
93 protected:
95  // virtual ~StreamingImageIOBase(); not needed
96  void
97  PrintSelf(std::ostream & os, Indent indent) const override;
98 
106  virtual bool
107  RequestedToStream() const;
108 
114  virtual bool
115  ReadBufferAsBinary(std::istream & is, void * buffer, SizeType num);
116 
122  virtual bool
123  WriteBufferAsBinary(std::ostream & os, const void * buffer, SizeType num);
124 
141  virtual bool
142  StreamReadBufferAsBinary(std::istream & file, void * _buffer);
143 
155  virtual bool
156  StreamWriteBufferAsBinary(std::ostream & file, const void * _buffer);
157 
159  virtual SizeType
160  GetHeaderSize() const = 0;
161 
166  virtual SizeType
168  {
169  return this->GetHeaderSize();
170  }
171 };
172 } // namespace itk
173 
174 #endif
itk::ImageIOBase
Abstract superclass defines image IO interface.
Definition: itkImageIOBase.h:77
itk::StreamingImageIOBase
A base class for specific ImageIO file formats which support streaming.
Definition: itkStreamingImageIOBase.h:52
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageIORegion
An ImageIORegion represents a structured region of data.
Definition: itkImageIORegion.h:52
itk::StreamingImageIOBase::GetDataPosition
virtual SizeType GetDataPosition() const
Returns the byte offset into the file where the data is located.
Definition: itkStreamingImageIOBase.h:167
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkImageIOBase.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ImageIOBase::SizeType
itk::intmax_t SizeType
Definition: itkImageIOBase.h:395
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61