OTB  6.7.0
Orfeo Toolbox
otbGDALDriverManagerWrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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,
81  int nXSize, int nYSize, int nBands,
82  GDALDataType eType, char ** papszOptions ) const;
83 
84 
85  GDALDriver* GetDriverByName( std::string driverShortName ) const;
86 
87 private :
88 // private constructor so that this class is allocated only inside GetInstance
90 
92 }; // end of GDALDriverManagerWrapper
93 
94 
95 } // end namespace otb
96 
97 
98 #endif // otbGDALDriverManagerWrapper_h
GDALDatasetWrapper::Pointer Open(std::string filename) const
GDALDatasetWrapper::Pointer Create(std::string driverShortName, std::string filename, int nXSize, int nYSize, int nBands, GDALDataType eType, char **papszOptions) const
GDALDriver * GetDriverByName(std::string driverShortName) const
static GDALDriverManagerWrapper & GetInstance()
Provide an unique instance of a GDALDataSet.