ITK  6.0.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
26namespace itk
27{
52class ITKIOImageBase_EXPORT StreamingImageIOBase : public ImageIOBase
53{
54public:
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
93protected:
95 // virtual ~StreamingImageIOBase(); not needed
96 void
97 PrintSelf(std::ostream & os, Indent indent) const override;
98
106 virtual bool
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
Abstract superclass defines image IO interface.
itk::intmax_t SizeType
An ImageIORegion represents a structured region of data.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Base class for most ITK classes.
Definition: itkObject.h:62
A base class for specific ImageIO file formats which support streaming.
virtual bool StreamReadBufferAsBinary(std::istream &file, void *_buffer)
Reads the set IORegion from os into buffer.
void PrintSelf(std::ostream &os, Indent indent) const override
virtual bool WriteBufferAsBinary(std::ostream &os, const void *buffer, SizeType num)
Reimplemented from super class to get around 2GB read/write limitation.
virtual bool StreamWriteBufferAsBinary(std::ostream &file, const void *_buffer)
Writes the set IORegion from buffer into os.
unsigned int GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion) override
bool CanStreamRead() override
virtual bool ReadBufferAsBinary(std::istream &is, void *buffer, SizeType num)
Reimplemented from superclass to get around 2GB read/write limitation.
ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion &requestedRegion) const override
virtual bool RequestedToStream() const
Returns true if GetIORegion() is not the same size as the largest region give by GetNumberOfDimension...
virtual SizeType GetDataPosition() const
Returns the byte offset into the file where the data is located.
virtual SizeType GetHeaderSize() const =0
Returns the size of the header in the file.
bool CanStreamWrite() override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....