Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Name: gdalplugindriverproxy.h 4 : * Project: GDAL Core 5 : * Purpose: GDAL Core C++/Private declarations. 6 : * Author: Even Rouault <even dot rouault at spatialys.com> 7 : * 8 : ****************************************************************************** 9 : * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com> 10 : * 11 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : 14 : #ifndef GDALPLUGINDRIVERPROXY_H_INCLUDED 15 : #define GDALPLUGINDRIVERPROXY_H_INCLUDED 16 : 17 : #include "cpl_port.h" 18 : #include "gdal_driver.h" 19 : 20 : #include <set> 21 : 22 : /************************************************************************/ 23 : /* GDALPluginDriverProxy */ 24 : /************************************************************************/ 25 : 26 : // clang-format off 27 : /** Proxy for a plugin driver. 28 : * 29 : * Such proxy must be registered with 30 : * GDALDriverManager::DeclareDeferredPluginDriver(). 31 : * 32 : * If the real driver defines any of the following metadata items, the 33 : * proxy driver should also define them with the same value: 34 : * <ul> 35 : * <li>GDAL_DMD_LONGNAME</li> 36 : * <li>GDAL_DMD_EXTENSIONS</li> 37 : * <li>GDAL_DMD_EXTENSION</li> 38 : * <li>GDAL_DMD_OPENOPTIONLIST</li> 39 : * <li>GDAL_DMD_SUBDATASETS</li> 40 : * <li>GDAL_DMD_CONNECTION_PREFIX</li> 41 : * <li>GDAL_DCAP_RASTER</li> 42 : * <li>GDAL_DCAP_MULTIDIM_RASTER</li> 43 : * <li>GDAL_DCAP_VECTOR</li> 44 : * <li>GDAL_DCAP_GNM</li> 45 : * <li>GDAL_DCAP_MULTIPLE_VECTOR_LAYERS</li> 46 : * <li>GDAL_DCAP_NONSPATIAL</li> 47 : * <li>GDAL_DCAP_VECTOR_TRANSLATE_FROM</li> 48 : * </ul> 49 : * 50 : * The pfnIdentify and pfnGetSubdatasetInfoFunc callbacks, if they are 51 : * defined in the real driver, should also be set on the proxy driver. 52 : * 53 : * Furthermore, the following metadata items must be defined if the real 54 : * driver sets the corresponding callback: 55 : * <ul> 56 : * <li>GDAL_DCAP_OPEN: must be set to YES if the real driver defines pfnOpen</li> 57 : * <li>GDAL_DCAP_CREATE: must be set to YES if the real driver defines pfnCreate</li> 58 : * <li>GDAL_DCAP_CREATE_MULTIDIMENSIONAL: must be set to YES if the real driver defines pfnCreateMultiDimensional</li> 59 : * <li>GDAL_DCAP_CREATECOPY: must be set to YES if the real driver defines pfnCreateCopy</li> 60 : * </ul> 61 : * 62 : * @since 3.9 63 : */ 64 : // clang-format on 65 : 66 : class GDALPluginDriverProxy final : public GDALDriver 67 : { 68 : const std::string m_osPluginFileName; 69 : std::string m_osPluginFullPath{}; 70 : std::unique_ptr<GDALDriver> m_poRealDriver{}; 71 : std::set<std::string> m_oSetMetadataItems{}; 72 : 73 : GDALDriver *GetRealDriver(); 74 : 75 : CPL_DISALLOW_COPY_ASSIGN(GDALPluginDriverProxy) 76 : 77 : protected: 78 : friend class GDALDriverManager; 79 : 80 : //! @cond Doxygen_Suppress 81 77000 : void SetPluginFullPath(const std::string &osFullPath) 82 : { 83 77000 : m_osPluginFullPath = osFullPath; 84 77000 : } 85 : 86 : //! @endcond 87 : 88 : public: 89 : explicit GDALPluginDriverProxy(const std::string &osPluginFileName); 90 : 91 : /** Return the plugin file name (not a full path) */ 92 77000 : const std::string &GetPluginFileName() const 93 : { 94 77000 : return m_osPluginFileName; 95 : } 96 : 97 : //! @cond Doxygen_Suppress 98 : OpenCallback GetOpenCallback() override; 99 : 100 : CreateCallback GetCreateCallback() override; 101 : 102 : CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback() override; 103 : 104 : CreateCopyCallback GetCreateCopyCallback() override; 105 : 106 : DeleteCallback GetDeleteCallback() override; 107 : 108 : RenameCallback GetRenameCallback() override; 109 : 110 : CopyFilesCallback GetCopyFilesCallback() override; 111 : 112 : InstantiateAlgorithmCallback GetInstantiateAlgorithmCallback() override; 113 : //! @endcond 114 : 115 : CPLErr SetMetadataItem(const char *pszName, const char *pszValue, 116 : const char *pszDomain = "") override; 117 : 118 : char **GetMetadata(const char *pszDomain) override; 119 : 120 : const char *GetMetadataItem(const char *pszName, 121 : const char *pszDomain = "") override; 122 : }; 123 : 124 : #endif