- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# gdal_proxy.h

    00001 /******************************************************************************
    00002  * $Id: gdal_proxy.h 20962 2010-10-25 23:00:16Z 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, Even Rouault
    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 #include "gdal.h"
    00034
    00035 #ifdef __cplusplus
    00036
    00037 #include "gdal_priv.h"
    00038 #include "cpl_hash_set.h"
    00039
    00040 /* ******************************************************************** */
    00041 /*                        GDALProxyDataset                              */
    00042 /* ******************************************************************** */
    00043
    00044 class CPL_DLL GDALProxyDataset : public GDALDataset
    00045 {
    00046     protected:
    00047         virtual GDALDataset *RefUnderlyingDataset() = 0;
    00048         virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
    00049
    00050         virtual CPLErr IBuildOverviews( const char *, int, int *,
    00051                                     int, int *, GDALProgressFunc, void * );
    00052         virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
    00053                                 void *, int, int, GDALDataType,
    00054                                 int, int *, int, int, int );
    00055     public:
    00056
    00057         virtual char      **GetMetadata( const char * pszDomain  );
    00058         virtual CPLErr      SetMetadata( char ** papszMetadata,
    00059                                         const char * pszDomain  );
    00060         virtual const char *GetMetadataItem( const char * pszName,
    00061                                             const char * pszDomain  );
    00062         virtual CPLErr      SetMetadataItem( const char * pszName,
    00063                                             const char * pszValue,
    00064                                             const char * pszDomain );
    00065
    00066         virtual void FlushCache(void);
    00067
    00068         virtual const char *GetProjectionRef(void);
    00069         virtual CPLErr SetProjection( const char * );
    00070
    00071         virtual CPLErr GetGeoTransform( double * );
    00072         virtual CPLErr SetGeoTransform( double * );
    00073
    00074         virtual void *GetInternalHandle( const char * );
    00075         virtual GDALDriver *GetDriver(void);
    00076         virtual char      **GetFileList(void);
    00077
    00078         virtual int    GetGCPCount();
    00079         virtual const char *GetGCPProjection();
    00080         virtual const GDAL_GCP *GetGCPs();
    00081         virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
    00082                                 const char *pszGCPProjection );
    00083
    00084         virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
    00085                                 int nBufXSize, int nBufYSize,
    00086                                 GDALDataType eDT,
    00087                                 int nBandCount, int *panBandList,
    00088                                 char **papszOptions );
    00089
    00090         virtual CPLErr          CreateMaskBand( int nFlags );
    00091
    00092 };
    00093
    00094 /* ******************************************************************** */
    00095 /*                         GDALProxyRasterBand                          */
    00096 /* ******************************************************************** */
    00097
    00098 class CPL_DLL GDALProxyRasterBand : public GDALRasterBand
    00099 {
    00100     protected:
    00101         virtual GDALRasterBand* RefUnderlyingRasterBand() = 0;
    00102         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
    00103
    00104         virtual CPLErr IReadBlock( int, int, void * );
    00105         virtual CPLErr IWriteBlock( int, int, void * );
    00106         virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
    00107                                 void *, int, int, GDALDataType,
    00108                                 int, int );
    00109
    00110     public:
    00111
    00112         virtual char      **GetMetadata( const char * pszDomain  );
    00113         virtual CPLErr      SetMetadata( char ** papszMetadata,
    00114                                         const char * pszDomain  );
    00115         virtual const char *GetMetadataItem( const char * pszName,
    00116                                             const char * pszDomain  );
    00117         virtual CPLErr      SetMetadataItem( const char * pszName,
    00118                                             const char * pszValue,
    00119                                             const char * pszDomain );
    00120         virtual CPLErr FlushCache();
    00121         virtual char **GetCategoryNames();
    00122         virtual double GetNoDataValue( int *pbSuccess = NULL );
    00123         virtual double GetMinimum( int *pbSuccess = NULL );
    00124         virtual double GetMaximum(int *pbSuccess = NULL );
    00125         virtual double GetOffset( int *pbSuccess = NULL );
    00126         virtual double GetScale( int *pbSuccess = NULL );
    00127         virtual const char *GetUnitType();
    00128         virtual GDALColorInterp GetColorInterpretation();
    00129         virtual GDALColorTable *GetColorTable();
    00130         virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
    00131
    00132         virtual CPLErr SetCategoryNames( char ** );
    00133         virtual CPLErr SetNoDataValue( double );
    00134         virtual CPLErr SetColorTable( GDALColorTable * );
    00135         virtual CPLErr SetColorInterpretation( GDALColorInterp );
    00136         virtual CPLErr SetOffset( double );
    00137         virtual CPLErr SetScale( double );
    00138         virtual CPLErr SetUnitType( const char * );
    00139
    00140         virtual CPLErr GetStatistics( int bApproxOK, int bForce,
    00141                                     double *pdfMin, double *pdfMax,
    00142                                     double *pdfMean, double *padfStdDev );
    00143         virtual CPLErr ComputeStatistics( int bApproxOK,
    00144                                         double *pdfMin, double *pdfMax,
    00145                                         double *pdfMean, double *pdfStdDev,
    00146                                         GDALProgressFunc, void *pProgressData );
    00147         virtual CPLErr SetStatistics( double dfMin, double dfMax,
    00148                                     double dfMean, double dfStdDev );
    00149         virtual CPLErr ComputeRasterMinMax( int, double* );
    00150
    00151         virtual int HasArbitraryOverviews();
    00152         virtual int GetOverviewCount();
    00153         virtual GDALRasterBand *GetOverview(int);
    00154         virtual GDALRasterBand *GetRasterSampleOverview( int );
    00155         virtual CPLErr BuildOverviews( const char *, int, int *,
    00156                                     GDALProgressFunc, void * );
    00157
    00158         virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
    00159                                 int nBufXSize, int nBufYSize,
    00160                                 GDALDataType eDT, char **papszOptions );
    00161
    00162         virtual CPLErr  GetHistogram( double dfMin, double dfMax,
    00163                             int nBuckets, int * panHistogram,
    00164                             int bIncludeOutOfRange, int bApproxOK,
    00165                             GDALProgressFunc, void *pProgressData );
    00166
    00167         virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
    00168                                             int *pnBuckets, int ** ppanHistogram,
    00169                                             int bForce,
    00170                                             GDALProgressFunc, void *pProgressData);
    00171         virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
    00172                                             int nBuckets, int *panHistogram );
    00173
    00174         virtual const GDALRasterAttributeTable *GetDefaultRAT();
    00175         virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
    00176
    00177         virtual GDALRasterBand *GetMaskBand();
    00178         virtual int             GetMaskFlags();
    00179         virtual CPLErr          CreateMaskBand( int nFlags );
    00180
    00181 };
    00182
    00183
    00184 /* ******************************************************************** */
    00185 /*                     GDALProxyPoolDataset                             */
    00186 /* ******************************************************************** */
    00187
    00188 typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry;
    00189 class     GDALProxyPoolRasterBand;
    00190
    00191 class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset
    00192 {
    00193     private:
    00194         GIntBig          responsiblePID;
    00195
    00196         char            *pszProjectionRef;
    00197         double           adfGeoTransform[6];
    00198         int              bHasSrcProjection;
    00199         int              bHasSrcGeoTransform;
    00200         char            *pszGCPProjection;
    00201         int              nGCPCount;
    00202         GDAL_GCP        *pasGCPList;
    00203         CPLHashSet      *metadataSet;
    00204         CPLHashSet      *metadataItemSet;
    00205
    00206         GDALProxyPoolCacheEntry* cacheEntry;
    00207
    00208     protected:
    00209         virtual GDALDataset *RefUnderlyingDataset();
    00210         virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
    00211
    00212         friend class     GDALProxyPoolRasterBand;
    00213
    00214     public:
    00215         GDALProxyPoolDataset(const char* pszSourceDatasetDescription,
    00216                             int nRasterXSize, int nRasterYSize,
    00217                             GDALAccess eAccess = GA_ReadOnly,
    00218                             int bShared = FALSE,
    00219                             const char * pszProjectionRef = NULL,
    00220                             double * padfGeoTransform = NULL);
    00221         ~GDALProxyPoolDataset();
    00222
    00223         void         AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
    00224
    00225         virtual const char *GetProjectionRef(void);
    00226         virtual CPLErr SetProjection( const char * );
    00227
    00228         virtual CPLErr GetGeoTransform( double * );
    00229         virtual CPLErr SetGeoTransform( double * );
    00230
    00231         /* Special behaviour for the following methods : they return a pointer */
    00232         /* data type, that must be cached by the proxy, so it doesn't become invalid */
    00233         /* when the underlying object get closed */
    00234         virtual char      **GetMetadata( const char * pszDomain  );
    00235         virtual const char *GetMetadataItem( const char * pszName,
    00236                                             const char * pszDomain  );
    00237
    00238         virtual void *GetInternalHandle( const char * pszRequest );
    00239
    00240         virtual const char *GetGCPProjection();
    00241         virtual const GDAL_GCP *GetGCPs();
    00242 };
    00243
    00244 /* ******************************************************************** */
    00245 /*                  GDALProxyPoolRasterBand                             */
    00246 /* ******************************************************************** */
    00247
    00248 class GDALProxyPoolOverviewRasterBand;
    00249 class GDALProxyPoolMaskBand;
    00250
    00251 class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand
    00252 {
    00253     private:
    00254         CPLHashSet      *metadataSet;
    00255         CPLHashSet      *metadataItemSet;
    00256         char            *pszUnitType;
    00257         char           **papszCategoryNames;
    00258         GDALColorTable  *poColorTable;
    00259
    00260         int                               nSizeProxyOverviewRasterBand;
    00261         GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand;
    00262         GDALProxyPoolMaskBand            *poProxyMaskBand;
    00263
    00264         void Init();
    00265
    00266     protected:
    00267         virtual GDALRasterBand* RefUnderlyingRasterBand();
    00268         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
    00269
    00270         friend class GDALProxyPoolOverviewRasterBand;
    00271         friend class GDALProxyPoolMaskBand;
    00272
    00273     public:
    00274         GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, int nBand,
    00275                                 GDALDataType eDataType,
    00276                                 int nBlockXSize, int nBlockYSize);
    00277         GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS,
    00278                                 GDALRasterBand* poUnderlyingRasterBand);
    00279         ~GDALProxyPoolRasterBand();
    00280
    00281         void AddSrcMaskBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
    00282
    00283         /* Special behaviour for the following methods : they return a pointer */
    00284         /* data type, that must be cached by the proxy, so it doesn't become invalid */
    00285         /* when the underlying object get closed */
    00286         virtual char      **GetMetadata( const char * pszDomain  );
    00287         virtual const char *GetMetadataItem( const char * pszName,
    00288                                             const char * pszDomain  );
    00289         virtual char **GetCategoryNames();
    00290         virtual const char *GetUnitType();
    00291         virtual GDALColorTable *GetColorTable();
    00292         virtual GDALRasterBand *GetOverview(int);
    00293         virtual GDALRasterBand *GetRasterSampleOverview( int nDesiredSamples); // TODO
    00294         virtual GDALRasterBand *GetMaskBand();
    00295
    00296 };
    00297
    00298 /* ******************************************************************** */
    00299 /*                  GDALProxyPoolOverviewRasterBand                     */
    00300 /* ******************************************************************** */
    00301
    00302 class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand
    00303 {
    00304     private:
    00305         GDALProxyPoolRasterBand *poMainBand;
    00306         int                      nOverviewBand;
    00307
    00308         GDALRasterBand          *poUnderlyingMainRasterBand;
    00309         int                      nRefCountUnderlyingMainRasterBand;
    00310
    00311     protected:
    00312         virtual GDALRasterBand* RefUnderlyingRasterBand();
    00313         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
    00314
    00315     public:
    00316         GDALProxyPoolOverviewRasterBand(GDALProxyPoolDataset* poDS,
    00317                                         GDALRasterBand* poUnderlyingOverviewBand,
    00318                                         GDALProxyPoolRasterBand* poMainBand,
    00319                                         int nOverviewBand);
    00320         ~GDALProxyPoolOverviewRasterBand();
    00321 };
    00322
    00323 /* ******************************************************************** */
    00324 /*                      GDALProxyPoolMaskBand                           */
    00325 /* ******************************************************************** */
    00326
    00327 class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand
    00328 {
    00329     private:
    00330         GDALProxyPoolRasterBand *poMainBand;
    00331
    00332         GDALRasterBand          *poUnderlyingMainRasterBand;
    00333         int                      nRefCountUnderlyingMainRasterBand;
    00334
    00335     protected:
    00336         virtual GDALRasterBand* RefUnderlyingRasterBand();
    00337         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
    00338
    00339     public:
    00340         GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
    00341                               GDALRasterBand* poUnderlyingMaskBand,
    00342                               GDALProxyPoolRasterBand* poMainBand);
    00343         GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
    00344                               GDALProxyPoolRasterBand* poMainBand,
    00345                               GDALDataType eDataType,
    00346                               int nBlockXSize, int nBlockYSize);
    00347         ~GDALProxyPoolMaskBand();
    00348 };
    00349
    00350 #endif
    00351
    00352
    00353 /* ******************************************************************** */
    00354 /*            C types and methods declarations                          */
    00355 /* ******************************************************************** */
    00356
    00357
    00358 CPL_C_START
    00359
    00360 typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH;
    00361
    00362 GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription,
    00363                                                          int nRasterXSize, int nRasterYSize,
    00364                                                          GDALAccess eAccess, int bShared,
    00365                                                          const char * pszProjectionRef,
    00366                                                          double * padfGeoTransform);
    00367
    00368 void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset);
    00369
    00370 void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset,
    00371                                                         GDALDataType eDataType,
    00372                                                         int nBlockXSize, int nBlockYSize);
    00373
    00374 CPL_C_END
    00375
    00376 #endif /* GDAL_PROXY_H_INCLUDED */

Generated for GDAL by 1.7.1.