/src/gdal/gcore/gdal_drivermanager.h
Line | Count | Source |
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 | | |
34 | | /** |
35 | | * Class for managing the registration of file format drivers. |
36 | | * |
37 | | * Use GetGDALDriverManager() to fetch the global singleton instance of |
38 | | * this class. |
39 | | */ |
40 | | |
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 | 0 | { |
56 | 0 | return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver] |
57 | 0 | : nullptr; |
58 | 0 | } |
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 | | |
78 | | //! @cond Doxygen_Suppress |
79 | | static char **GetSearchPaths(const char *pszGDAL_DRIVER_PATH); |
80 | | //! @endcond |
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 | | |
103 | | //! @cond Doxygen_Suppress |
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); |
108 | | //! @endcond |
109 | | }; |
110 | | |
111 | | CPL_C_START |
112 | | GDALDriverManager CPL_DLL *GetGDALDriverManager(void); |
113 | | CPL_C_END |
114 | | |
115 | | #endif |