OTB  9.0.0
Orfeo Toolbox
otbStreamingManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbStreamingManager_h
22 #define otbStreamingManager_h
23 
24 #include "otbMacro.h"
25 
26 #include "itkDataObject.h"
27 #include "itkImageRegionSplitterBase.h"
29 
30 namespace otb
31 {
32 
52 template <class TImage>
53 class ITK_EXPORT StreamingManager : public itk::Object
54 {
55 public:
58  typedef itk::LightObject Superclass;
59  typedef itk::SmartPointer<Self> Pointer;
60  typedef itk::SmartPointer<const Self> ConstPointer;
61 
62  typedef TImage ImageType;
63  typedef typename ImageType::Pointer ImagePointerType;
64  typedef typename ImageType::RegionType RegionType;
65  typedef typename RegionType::IndexType IndexType;
66  typedef typename RegionType::SizeType SizeType;
67  typedef typename ImageType::InternalPixelType PixelType;
68 
70  typedef itk::ImageRegionSplitterBase AbstractSplitterType;
71 
73  itkTypeMacro(StreamingManager, itk::LightObject);
74 
76  itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
77 
78  const AbstractSplitterType* GetSplitter() const;
79 
82  virtual void PrepareStreaming(itk::DataObject* input, const RegionType& region) = 0;
83 
87  virtual unsigned int GetNumberOfSplits();
88 
92  virtual RegionType GetSplit(unsigned int i);
93 
94  itkSetMacro(DefaultRAM, MemoryPrintType);
95  itkGetMacro(DefaultRAM, MemoryPrintType);
96 
97 protected:
99  ~StreamingManager() override;
100 
101  virtual unsigned int EstimateOptimalNumberOfDivisions(itk::DataObject* input, const RegionType& region, MemoryPrintType availableRAMInMB, double bias = 1.0);
102 
105 
108 
110  typedef typename AbstractSplitterType::Pointer AbstractSplitterPointerType;
112 
113 private:
114  StreamingManager(const StreamingManager&) = delete;
115  void operator=(const StreamingManager&) = delete;
116 
120  MemoryPrintType GetActualAvailableRAMInBytes(MemoryPrintType availableRAMInMB);
121 
124 };
125 
126 } // End namespace otb
127 
128 #ifndef OTB_MANUAL_INSTANTIATION
129 #include "otbStreamingManager.hxx"
130 #endif
131 
132 #endif
otb::PipelineMemoryPrintCalculator::MemoryPrintType
::itksysFundamentalType_UInt64 MemoryPrintType
Definition: otbPipelineMemoryPrintCalculator.h:88
otb::StreamingManager::ImageType
TImage ImageType
Definition: otbStreamingManager.h:62
otb::StreamingManager::AbstractSplitterPointerType
AbstractSplitterType::Pointer AbstractSplitterPointerType
Definition: otbStreamingManager.h:110
otb::StreamingManager
This class handles the streaming process used in the writers implementation.
Definition: otbStreamingManager.h:53
otbStreamingManager.hxx
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbMacro.h
otbPipelineMemoryPrintCalculator.h
otb::StreamingManager::IndexType
RegionType::IndexType IndexType
Definition: otbStreamingManager.h:65
otb::StreamingManager::SizeType
RegionType::SizeType SizeType
Definition: otbStreamingManager.h:66
otb::StreamingManager::Superclass
itk::LightObject Superclass
Definition: otbStreamingManager.h:58
otb::StreamingManager::m_Region
RegionType m_Region
Definition: otbStreamingManager.h:107
otb::StreamingManager::PixelType
ImageType::InternalPixelType PixelType
Definition: otbStreamingManager.h:67
otb::StreamingManager::ImagePointerType
ImageType::Pointer ImagePointerType
Definition: otbStreamingManager.h:63
otb::StreamingManager::m_DefaultRAM
MemoryPrintType m_DefaultRAM
Definition: otbStreamingManager.h:123
otb::StreamingManager::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingManager.h:59
otb::StreamingManager::Self
StreamingManager Self
Definition: otbStreamingManager.h:57
otb::StreamingManager::MemoryPrintType
otb::PipelineMemoryPrintCalculator::MemoryPrintType MemoryPrintType
Definition: otbStreamingManager.h:69
otb::StreamingManager::m_ComputedNumberOfSplits
unsigned int m_ComputedNumberOfSplits
Definition: otbStreamingManager.h:104
otb::StreamingManager::AbstractSplitterType
itk::ImageRegionSplitterBase AbstractSplitterType
Definition: otbStreamingManager.h:70
otb::StreamingManager::m_Splitter
AbstractSplitterPointerType m_Splitter
Definition: otbStreamingManager.h:111
otb::StreamingManager::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingManager.h:60
otb::StreamingManager::RegionType
ImageType::RegionType RegionType
Definition: otbStreamingManager.h:64