GDAL

gdal_drivermanager.h
1/******************************************************************************
2 *
3 * Name: gdal_drivermanager.h
4 * Project: GDAL Core
5 * Purpose: Declaration of GDALDriverManager class
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1998, Frank Warmerdam
10 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef GDALDRIVERMANAGER_H_INCLUDED
16#define GDALDRIVERMANAGER_H_INCLUDED
17
18#include "cpl_port.h"
19#include "cpl_string.h"
20#include "gdal.h"
21#include "gdal_majorobject.h"
22
23#include <memory>
24#include <set>
25#include <vector>
26
27 class GDALDriver;
28 class GDALPluginDriverProxy;
29
30/* ******************************************************************** */
31/* GDALDriverManager */
32/* ******************************************************************** */
33
41 class CPL_DLL GDALDriverManager final : public GDALMajorObject
42{
43 int nDrivers = 0;
44 GDALDriver **papoDrivers = nullptr;
45 std::map<CPLString, GDALDriver *> oMapNameToDrivers{};
46 std::string m_osPluginPath{};
47 std::string m_osDriversIniPath{};
48 mutable std::string m_osLastTriedDirectory{};
49 std::set<std::string> m_oSetPluginFileNames{};
50 bool m_bInDeferredDriverLoading = false;
51 std::map<std::string, std::unique_ptr<GDALDriver>> m_oMapRealDrivers{};
52 std::vector<std::unique_ptr<GDALDriver>> m_aoHiddenDrivers{};
53
54 GDALDriver *GetDriver_unlocked(int iDriver)
55 {
56 return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver]
57 : nullptr;
58 }
59
60 GDALDriver *GetDriverByName_unlocked(const char *pszName) const;
61
62 static void CleanupPythonDrivers();
63
64 std::string GetPluginFullPath(const char *pszFilename) const;
65
66 int RegisterDriver(GDALDriver *, bool bHidden);
67
68 CPL_DISALLOW_COPY_ASSIGN(GDALDriverManager)
69
70 protected:
71 friend class GDALPluginDriverProxy;
72 friend GDALDatasetH CPL_STDCALL
73 GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
74 const char *const *papszAllowedDrivers,
75 const char *const *papszOpenOptions,
76 const char *const *papszSiblingFiles);
77
79 static char **GetSearchPaths(const char *pszGDAL_DRIVER_PATH);
81
82 public:
83 GDALDriverManager();
84 ~GDALDriverManager() override;
85
86 int GetDriverCount(void) const;
87 GDALDriver *GetDriver(int);
88 GDALDriver *GetDriverByName(const char *);
89
90 int RegisterDriver(GDALDriver *);
91 void DeregisterDriver(GDALDriver *);
92
93 // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
94 void AutoLoadDrivers();
95 void AutoSkipDrivers();
96 void ReorderDrivers();
97 static CPLErr LoadPlugin(const char *name);
98
99 static void AutoLoadPythonDrivers();
100
101 void DeclareDeferredPluginDriver(GDALPluginDriverProxy *poProxyDriver);
102
104 int GetDriverCount(bool bIncludeHidden) const;
105 GDALDriver *GetDriver(int iDriver, bool bIncludeHidden);
106 bool IsKnownDriver(const char *pszDriverName) const;
107 GDALDriver *GetHiddenDriverByName(const char *pszName);
109};
110
111 CPL_C_START
112 GDALDriverManager CPL_DLL *GetGDALDriverManager(void);
113 CPL_C_END
114
115#endif
GDALDriverManager
Class for managing the registration of file format drivers.
Definition gdal_drivermanager.h:42
GDALDriver
Format specific driver.
Definition gdal_driver.h:63
GDALMajorObject
Object with metadata.
Definition gdal_majorobject.h:43
GDALPluginDriverProxy
Proxy for a plugin driver.
Definition gdalplugindriverproxy.h:67
CPLErr
CPLErr
Error category.
Definition cpl_error.h:37
cpl_port.h
Core portability definitions for CPL.
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:936
cpl_string.h
Various convenience functions for working with strings and string lists.
gdal.h
Public (C callable) GDAL entry points.
GDALOpenEx
GDALDatasetH GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags, const char *const *papszAllowedDrivers, const char *const *papszOpenOptions, const char *const *papszSiblingFiles)
Open a raster or vector file as a GDALDataset.
Definition gdaldataset.cpp:3914
GDALDatasetH
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition gdal_fwd.h:42