OTB  10.0.0
Orfeo Toolbox
otbGDALDriverManagerWrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbGDALDriverManagerWrapper_h
22 #define otbGDALDriverManagerWrapper_h
23 
24 
25 #include "itkLightObject.h"
26 #include "itkProcessObject.h"
27 #include "otbConfigure.h"
28 
29 class GDALDataset;
30 class GDALDriver;
31 
32 /* GDAL Libraries */
33 #include "gdal.h"
34 #include "gdaljp2metadata.h"
35 #include "gdal_priv.h"
36 #include "gdal_alg.h"
37 
38 #include "otbGDALDatasetWrapper.h"
39 // otb::GDALOverviewsBuilder moved to self header & body files.
40 // Including its header file here for compile time compatibility.
42 
43 namespace otb
44 {
45 
59 // Wraps the GdalDriverManager so that GDALAllRegister is called automatically
61 {
62 public:
63  // GetInstance returns a reference to a GDALDriverManagerWrapper
64  // This is the only entry point to interact with this class
66  {
67 
68  // Declare a static method variable of type GDALDriverManagerWrapper
69  // so that it is constructed and initialized only on the first call
70  // to GetInstance(), and so try to avoid static initialization order problems
71 
72  static GDALDriverManagerWrapper theUniqueInstance;
73  return theUniqueInstance;
74  }
75 
76  // Open the file for reading and returns a smart dataset pointer
77  GDALDatasetWrapper::Pointer Open(std::string filename) const;
78 
79  // Open the new file for writing and returns a smart dataset pointer
80  GDALDatasetWrapper::Pointer Create(std::string& driverShortName, std::string filename, int nXSize, int nYSize, int nBands, GDALDataType eType,
81  char** papszOptions) const;
82 
84  void* mem_ptr,
85  const uint64_t& width,
86  const uint64_t& height,
87  const GDALDataType pix_type,
88  const uint32_t byte_per_pixel,
89  const uint16_t nb_bands = 1,
90  const uint64_t& band_offset = 1) const;
91 
92  GDALDriver* GetDriverByName(std::string driverShortName) const;
93 
94 private:
95  // private constructor so that this class is allocated only inside GetInstance
97 
99 }; // end of GDALDriverManagerWrapper
100 
101 
102 } // end namespace otb
103 
104 
105 #endif // otbGDALDriverManagerWrapper_h
itk::SmartPointer< Self > Pointer
Provide an unique instance of a GDALDataSet.
GDALDriver * GetDriverByName(std::string driverShortName) const
GDALDatasetWrapper::Pointer Create(std::string &driverShortName, std::string filename, int nXSize, int nYSize, int nBands, GDALDataType eType, char **papszOptions) const
static GDALDriverManagerWrapper & GetInstance()
GDALDatasetWrapper::Pointer OpenFromMemory(void *mem_ptr, const uint64_t &width, const uint64_t &height, const GDALDataType pix_type, const uint32_t byte_per_pixel, const uint16_t nb_bands=1, const uint64_t &band_offset=1) const
GDALDatasetWrapper::Pointer Open(std::string filename) const
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.