GDAL
gdal_proxy.h
00001 /******************************************************************************
00002  * $Id: gdal_proxy.h 36501 2016-11-25 14:09:24Z rouault $
00003  *
00004  * Project:  GDAL Core
00005  * Purpose:  GDAL Core C++/Private declarations
00006  * Author:   Even Rouault <even dot rouault at mines dash paris dot org>
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ****************************************************************************/
00029 
00030 #ifndef GDAL_PROXY_H_INCLUDED
00031 #define GDAL_PROXY_H_INCLUDED
00032 
00033 #ifndef DOXYGEN_SKIP
00034 
00035 #include "gdal.h"
00036 
00037 #ifdef __cplusplus
00038 
00039 #include "gdal_priv.h"
00040 #include "cpl_hash_set.h"
00041 
00042 /* ******************************************************************** */
00043 /*                        GDALProxyDataset                              */
00044 /* ******************************************************************** */
00045 
00046 class CPL_DLL GDALProxyDataset : public GDALDataset
00047 {
00048     protected:
00049         GDALProxyDataset() {};
00050 
00051         virtual GDALDataset *RefUnderlyingDataset() = 0;
00052         virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
00053 
00054         virtual CPLErr IBuildOverviews( const char *, int, int *,
00055                                     int, int *, GDALProgressFunc, void * ) CPL_OVERRIDE;
00056         virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00057                                 void *, int, int, GDALDataType,
00058                                 int, int *, GSpacing, GSpacing, GSpacing,
00059                                 GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
00060     public:
00061 
00062         virtual char      **GetMetadataDomainList() CPL_OVERRIDE;
00063         virtual char      **GetMetadata( const char * pszDomain  ) CPL_OVERRIDE;
00064         virtual CPLErr      SetMetadata( char ** papszMetadata,
00065                                         const char * pszDomain  ) CPL_OVERRIDE;
00066         virtual const char *GetMetadataItem( const char * pszName,
00067                                             const char * pszDomain  ) CPL_OVERRIDE;
00068         virtual CPLErr      SetMetadataItem( const char * pszName,
00069                                             const char * pszValue,
00070                                             const char * pszDomain ) CPL_OVERRIDE;
00071 
00072         virtual void FlushCache(void) CPL_OVERRIDE;
00073 
00074         virtual const char *GetProjectionRef(void) CPL_OVERRIDE;
00075         virtual CPLErr SetProjection( const char * ) CPL_OVERRIDE;
00076 
00077         virtual CPLErr GetGeoTransform( double * ) CPL_OVERRIDE;
00078         virtual CPLErr SetGeoTransform( double * ) CPL_OVERRIDE;
00079 
00080         virtual void *GetInternalHandle( const char * ) CPL_OVERRIDE;
00081         virtual GDALDriver *GetDriver(void) CPL_OVERRIDE;
00082         virtual char      **GetFileList(void) CPL_OVERRIDE;
00083 
00084         virtual int    GetGCPCount() CPL_OVERRIDE;
00085         virtual const char *GetGCPProjection() CPL_OVERRIDE;
00086         virtual const GDAL_GCP *GetGCPs() CPL_OVERRIDE;
00087         virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00088                                 const char *pszGCPProjection ) CPL_OVERRIDE;
00089 
00090         virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00091                                 int nBufXSize, int nBufYSize,
00092                                 GDALDataType eDT,
00093                                 int nBandCount, int *panBandList,
00094                                 char **papszOptions ) CPL_OVERRIDE;
00095 
00096         virtual CPLErr          CreateMaskBand( int nFlags ) CPL_OVERRIDE;
00097 
00098   private:
00099     CPL_DISALLOW_COPY_ASSIGN(GDALProxyDataset)
00100 };
00101 
00102 /* ******************************************************************** */
00103 /*                         GDALProxyRasterBand                          */
00104 /* ******************************************************************** */
00105 
00106 class CPL_DLL GDALProxyRasterBand : public GDALRasterBand
00107 {
00108     protected:
00109         GDALProxyRasterBand() {};
00110 
00111         virtual GDALRasterBand* RefUnderlyingRasterBand() = 0;
00112         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
00113 
00114         virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
00115         virtual CPLErr IWriteBlock( int, int, void * ) CPL_OVERRIDE;
00116         virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00117                                 void *, int, int, GDALDataType,
00118                                 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
00119 
00120     public:
00121 
00122         virtual char      **GetMetadataDomainList() CPL_OVERRIDE;
00123         virtual char      **GetMetadata( const char * pszDomain  ) CPL_OVERRIDE;
00124         virtual CPLErr      SetMetadata( char ** papszMetadata,
00125                                         const char * pszDomain  ) CPL_OVERRIDE;
00126         virtual const char *GetMetadataItem( const char * pszName,
00127                                             const char * pszDomain  ) CPL_OVERRIDE;
00128         virtual CPLErr      SetMetadataItem( const char * pszName,
00129                                             const char * pszValue,
00130                                             const char * pszDomain ) CPL_OVERRIDE;
00131         virtual CPLErr FlushCache() CPL_OVERRIDE;
00132         virtual char **GetCategoryNames() CPL_OVERRIDE;
00133         virtual double GetNoDataValue( int *pbSuccess = NULL ) CPL_OVERRIDE;
00134         virtual double GetMinimum( int *pbSuccess = NULL ) CPL_OVERRIDE;
00135         virtual double GetMaximum(int *pbSuccess = NULL ) CPL_OVERRIDE;
00136         virtual double GetOffset( int *pbSuccess = NULL ) CPL_OVERRIDE;
00137         virtual double GetScale( int *pbSuccess = NULL ) CPL_OVERRIDE;
00138         virtual const char *GetUnitType() CPL_OVERRIDE;
00139         virtual GDALColorInterp GetColorInterpretation() CPL_OVERRIDE;
00140         virtual GDALColorTable *GetColorTable() CPL_OVERRIDE;
00141         virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0) CPL_OVERRIDE;
00142 
00143         virtual CPLErr SetCategoryNames( char ** ) CPL_OVERRIDE;
00144         virtual CPLErr SetNoDataValue( double ) CPL_OVERRIDE;
00145         virtual CPLErr DeleteNoDataValue() CPL_OVERRIDE;
00146         virtual CPLErr SetColorTable( GDALColorTable * ) CPL_OVERRIDE;
00147         virtual CPLErr SetColorInterpretation( GDALColorInterp ) CPL_OVERRIDE;
00148         virtual CPLErr SetOffset( double ) CPL_OVERRIDE;
00149         virtual CPLErr SetScale( double ) CPL_OVERRIDE;
00150         virtual CPLErr SetUnitType( const char * ) CPL_OVERRIDE;
00151 
00152         virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00153                                     double *pdfMin, double *pdfMax,
00154                                     double *pdfMean, double *padfStdDev ) CPL_OVERRIDE;
00155         virtual CPLErr ComputeStatistics( int bApproxOK,
00156                                         double *pdfMin, double *pdfMax,
00157                                         double *pdfMean, double *pdfStdDev,
00158                                         GDALProgressFunc, void *pProgressData ) CPL_OVERRIDE;
00159         virtual CPLErr SetStatistics( double dfMin, double dfMax,
00160                                     double dfMean, double dfStdDev ) CPL_OVERRIDE;
00161         virtual CPLErr ComputeRasterMinMax( int, double* ) CPL_OVERRIDE;
00162 
00163         virtual int HasArbitraryOverviews() CPL_OVERRIDE;
00164         virtual int GetOverviewCount() CPL_OVERRIDE;
00165         virtual GDALRasterBand *GetOverview(int) CPL_OVERRIDE;
00166         virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig ) CPL_OVERRIDE;
00167         virtual CPLErr BuildOverviews( const char *, int, int *,
00168                                     GDALProgressFunc, void * ) CPL_OVERRIDE;
00169 
00170         virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00171                                 int nBufXSize, int nBufYSize,
00172                                 GDALDataType eDT, char **papszOptions ) CPL_OVERRIDE;
00173 
00174         virtual CPLErr  GetHistogram( double dfMin, double dfMax,
00175                             int nBuckets, GUIntBig * panHistogram,
00176                             int bIncludeOutOfRange, int bApproxOK,
00177                             GDALProgressFunc, void *pProgressData ) CPL_OVERRIDE;
00178 
00179         virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00180                                             int *pnBuckets, GUIntBig ** ppanHistogram,
00181                                             int bForce,
00182                                             GDALProgressFunc, void *pProgressData) CPL_OVERRIDE;
00183         virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00184                                             int nBuckets, GUIntBig *panHistogram ) CPL_OVERRIDE;
00185 
00186         virtual GDALRasterAttributeTable *GetDefaultRAT() CPL_OVERRIDE;
00187         virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ) CPL_OVERRIDE;
00188 
00189         virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE;
00190         virtual int             GetMaskFlags() CPL_OVERRIDE;
00191         virtual CPLErr          CreateMaskBand( int nFlags ) CPL_OVERRIDE;
00192 
00193         virtual CPLVirtualMem  *GetVirtualMemAuto( GDALRWFlag eRWFlag,
00194                                                 int *pnPixelSpace,
00195                                                 GIntBig *pnLineSpace,
00196                                                 char **papszOptions ) CPL_OVERRIDE;
00197   private:
00198     CPL_DISALLOW_COPY_ASSIGN(GDALProxyRasterBand)
00199 };
00200 
00201 /* ******************************************************************** */
00202 /*                     GDALProxyPoolDataset                             */
00203 /* ******************************************************************** */
00204 
00205 typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry;
00206 class     GDALProxyPoolRasterBand;
00207 
00208 class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset
00209 {
00210     private:
00211         GIntBig          responsiblePID;
00212 
00213         char            *pszProjectionRef;
00214         double           adfGeoTransform[6];
00215         int              bHasSrcProjection;
00216         int              bHasSrcGeoTransform;
00217         char            *pszGCPProjection;
00218         int              nGCPCount;
00219         GDAL_GCP        *pasGCPList;
00220         CPLHashSet      *metadataSet;
00221         CPLHashSet      *metadataItemSet;
00222 
00223         GDALProxyPoolCacheEntry* cacheEntry;
00224 
00225     protected:
00226         virtual GDALDataset *RefUnderlyingDataset() CPL_OVERRIDE;
00227         virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset) CPL_OVERRIDE;
00228 
00229         friend class     GDALProxyPoolRasterBand;
00230 
00231     public:
00232         GDALProxyPoolDataset(const char* pszSourceDatasetDescription,
00233                             int nRasterXSize, int nRasterYSize,
00234                             GDALAccess eAccess = GA_ReadOnly,
00235                             int bShared = FALSE,
00236                             const char * pszProjectionRef = NULL,
00237                             double * padfGeoTransform = NULL);
00238         virtual ~GDALProxyPoolDataset();
00239 
00240         void         SetOpenOptions(char** papszOpenOptions);
00241         void         AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
00242 
00243         virtual const char *GetProjectionRef(void) CPL_OVERRIDE;
00244         virtual CPLErr SetProjection( const char * ) CPL_OVERRIDE;
00245 
00246         virtual CPLErr GetGeoTransform( double * ) CPL_OVERRIDE;
00247         virtual CPLErr SetGeoTransform( double * ) CPL_OVERRIDE;
00248 
00249         /* Special behaviour for the following methods : they return a pointer */
00250         /* data type, that must be cached by the proxy, so it doesn't become invalid */
00251         /* when the underlying object get closed */
00252         virtual char      **GetMetadata( const char * pszDomain  ) CPL_OVERRIDE;
00253         virtual const char *GetMetadataItem( const char * pszName,
00254                                             const char * pszDomain  ) CPL_OVERRIDE;
00255 
00256         virtual void *GetInternalHandle( const char * pszRequest ) CPL_OVERRIDE;
00257 
00258         virtual const char *GetGCPProjection() CPL_OVERRIDE;
00259         virtual const GDAL_GCP *GetGCPs() CPL_OVERRIDE;
00260   private:
00261     CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolDataset)
00262 };
00263 
00264 /* ******************************************************************** */
00265 /*                  GDALProxyPoolRasterBand                             */
00266 /* ******************************************************************** */
00267 
00268 class GDALProxyPoolOverviewRasterBand;
00269 class GDALProxyPoolMaskBand;
00270 
00271 class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand
00272 {
00273     private:
00274         CPLHashSet      *metadataSet;
00275         CPLHashSet      *metadataItemSet;
00276         char            *pszUnitType;
00277         char           **papszCategoryNames;
00278         GDALColorTable  *poColorTable;
00279 
00280         int                               nSizeProxyOverviewRasterBand;
00281         GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand;
00282         GDALProxyPoolMaskBand            *poProxyMaskBand;
00283 
00284         void Init();
00285 
00286     protected:
00287         virtual GDALRasterBand* RefUnderlyingRasterBand() CPL_OVERRIDE;
00288         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand) CPL_OVERRIDE;
00289 
00290         friend class GDALProxyPoolOverviewRasterBand;
00291         friend class GDALProxyPoolMaskBand;
00292 
00293     public:
00294         GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, int nBand,
00295                                 GDALDataType eDataType,
00296                                 int nBlockXSize, int nBlockYSize);
00297         GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS,
00298                                 GDALRasterBand* poUnderlyingRasterBand);
00299         virtual ~GDALProxyPoolRasterBand();
00300 
00301         void AddSrcMaskBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
00302 
00303         /* Special behaviour for the following methods : they return a pointer */
00304         /* data type, that must be cached by the proxy, so it doesn't become invalid */
00305         /* when the underlying object get closed */
00306         virtual char      **GetMetadata( const char * pszDomain  ) CPL_OVERRIDE;
00307         virtual const char *GetMetadataItem( const char * pszName,
00308                                             const char * pszDomain  ) CPL_OVERRIDE;
00309         virtual char **GetCategoryNames() CPL_OVERRIDE;
00310         virtual const char *GetUnitType() CPL_OVERRIDE;
00311         virtual GDALColorTable *GetColorTable() CPL_OVERRIDE;
00312         virtual GDALRasterBand *GetOverview(int) CPL_OVERRIDE;
00313         virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig nDesiredSamples) CPL_OVERRIDE; // TODO
00314         virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE;
00315   private:
00316     CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolRasterBand)
00317 };
00318 
00319 /* ******************************************************************** */
00320 /*                  GDALProxyPoolOverviewRasterBand                     */
00321 /* ******************************************************************** */
00322 
00323 class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand
00324 {
00325     private:
00326         GDALProxyPoolRasterBand *poMainBand;
00327         int                      nOverviewBand;
00328 
00329         GDALRasterBand          *poUnderlyingMainRasterBand;
00330         int                      nRefCountUnderlyingMainRasterBand;
00331 
00332     protected:
00333         virtual GDALRasterBand* RefUnderlyingRasterBand() CPL_OVERRIDE;
00334         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand) CPL_OVERRIDE;
00335 
00336     public:
00337         GDALProxyPoolOverviewRasterBand(GDALProxyPoolDataset* poDS,
00338                                         GDALRasterBand* poUnderlyingOverviewBand,
00339                                         GDALProxyPoolRasterBand* poMainBand,
00340                                         int nOverviewBand);
00341         virtual ~GDALProxyPoolOverviewRasterBand();
00342 };
00343 
00344 /* ******************************************************************** */
00345 /*                      GDALProxyPoolMaskBand                           */
00346 /* ******************************************************************** */
00347 
00348 class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand
00349 {
00350     private:
00351         GDALProxyPoolRasterBand *poMainBand;
00352 
00353         GDALRasterBand          *poUnderlyingMainRasterBand;
00354         int                      nRefCountUnderlyingMainRasterBand;
00355 
00356     protected:
00357         virtual GDALRasterBand* RefUnderlyingRasterBand() CPL_OVERRIDE;
00358         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand) CPL_OVERRIDE;
00359 
00360     public:
00361         GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
00362                               GDALRasterBand* poUnderlyingMaskBand,
00363                               GDALProxyPoolRasterBand* poMainBand);
00364         GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
00365                               GDALProxyPoolRasterBand* poMainBand,
00366                               GDALDataType eDataType,
00367                               int nBlockXSize, int nBlockYSize);
00368         virtual ~GDALProxyPoolMaskBand();
00369 };
00370 
00371 #endif
00372 
00373 /* ******************************************************************** */
00374 /*            C types and methods declarations                          */
00375 /* ******************************************************************** */
00376 
00377 CPL_C_START
00378 
00379 typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH;
00380 
00381 GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription,
00382                                                          int nRasterXSize, int nRasterYSize,
00383                                                          GDALAccess eAccess, int bShared,
00384                                                          const char * pszProjectionRef,
00385                                                          double * padfGeoTransform);
00386 
00387 void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset);
00388 
00389 void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset,
00390                                                         GDALDataType eDataType,
00391                                                         int nBlockXSize, int nBlockYSize);
00392 
00393 CPL_C_END
00394 
00395 #endif /* #ifndef DOXYGEN_SKIP */
00396 
00397 #endif /* GDAL_PROXY_H_INCLUDED */

Generated for GDAL by doxygen 1.7.6.1.