LCOV - code coverage report
Current view: directory - gcore - gdal_proxy.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 2 2 100.0 %
Date: 2010-01-09 Functions: 6 4 66.7 %

       1                 : /******************************************************************************
       2                 :  * $Id: gdal_proxy.h 18063 2009-11-21 21:11:49Z warmerdam $
       3                 :  *
       4                 :  * Project:  GDAL Core
       5                 :  * Purpose:  GDAL Core C++/Private declarations
       6                 :  * Author:   Even Rouault <even dot rouault at mines dash paris dot org>
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2008, Even Rouault
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #ifndef GDAL_PROXY_H_INCLUDED
      31                 : #define GDAL_PROXY_H_INCLUDED
      32                 : 
      33                 : #include "gdal.h"
      34                 : 
      35                 : #ifdef __cplusplus
      36                 : 
      37                 : #include "gdal_priv.h"
      38                 : #include "cpl_hash_set.h"
      39                 : 
      40                 : /* ******************************************************************** */
      41                 : /*                        GDALProxyDataset                              */
      42                 : /* ******************************************************************** */
      43                 : 
      44                 : class CPL_DLL GDALProxyDataset : public GDALDataset
      45             260 : {
      46                 :     protected:
      47                 :         virtual GDALDataset *RefUnderlyingDataset() = 0;
      48                 :         virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
      49                 : 
      50                 :         virtual CPLErr IBuildOverviews( const char *, int, int *,
      51                 :                                     int, int *, GDALProgressFunc, void * );
      52                 :         virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
      53                 :                                 void *, int, int, GDALDataType,
      54                 :                                 int, int *, int, int, int );
      55                 :     public:
      56                 : 
      57                 :         virtual char      **GetMetadata( const char * pszDomain  );
      58                 :         virtual CPLErr      SetMetadata( char ** papszMetadata,
      59                 :                                         const char * pszDomain  );
      60                 :         virtual const char *GetMetadataItem( const char * pszName,
      61                 :                                             const char * pszDomain  );
      62                 :         virtual CPLErr      SetMetadataItem( const char * pszName,
      63                 :                                             const char * pszValue,
      64                 :                                             const char * pszDomain );
      65                 : 
      66                 :         virtual void FlushCache(void);
      67                 : 
      68                 :         virtual const char *GetProjectionRef(void);
      69                 :         virtual CPLErr SetProjection( const char * );
      70                 : 
      71                 :         virtual CPLErr GetGeoTransform( double * );
      72                 :         virtual CPLErr SetGeoTransform( double * );
      73                 : 
      74                 :         virtual void *GetInternalHandle( const char * );
      75                 :         virtual GDALDriver *GetDriver(void);
      76                 :         virtual char      **GetFileList(void);
      77                 : 
      78                 :         virtual int    GetGCPCount();
      79                 :         virtual const char *GetGCPProjection();
      80                 :         virtual const GDAL_GCP *GetGCPs();
      81                 :         virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
      82                 :                                 const char *pszGCPProjection );
      83                 : 
      84                 :         virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
      85                 :                                 int nBufXSize, int nBufYSize, 
      86                 :                                 GDALDataType eDT, 
      87                 :                                 int nBandCount, int *panBandList,
      88                 :                                 char **papszOptions );
      89                 : 
      90                 :         virtual CPLErr          CreateMaskBand( int nFlags );
      91                 : 
      92                 : };
      93                 : 
      94                 : /* ******************************************************************** */
      95                 : /*                         GDALProxyRasterBand                          */
      96                 : /* ******************************************************************** */
      97                 : 
      98                 : class CPL_DLL GDALProxyRasterBand : public GDALRasterBand
      99             376 : {
     100                 :     protected:
     101                 :         virtual GDALRasterBand* RefUnderlyingRasterBand() = 0;
     102                 :         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
     103                 : 
     104                 :         virtual CPLErr IReadBlock( int, int, void * );
     105                 :         virtual CPLErr IWriteBlock( int, int, void * );
     106                 :         virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     107                 :                                 void *, int, int, GDALDataType,
     108                 :                                 int, int );
     109                 : 
     110                 :     public:
     111                 : 
     112                 :         virtual char      **GetMetadata( const char * pszDomain  );
     113                 :         virtual CPLErr      SetMetadata( char ** papszMetadata,
     114                 :                                         const char * pszDomain  );
     115                 :         virtual const char *GetMetadataItem( const char * pszName,
     116                 :                                             const char * pszDomain  );
     117                 :         virtual CPLErr      SetMetadataItem( const char * pszName,
     118                 :                                             const char * pszValue,
     119                 :                                             const char * pszDomain );
     120                 :         virtual CPLErr FlushCache();
     121                 :         virtual char **GetCategoryNames();
     122                 :         virtual double GetNoDataValue( int *pbSuccess = NULL );
     123                 :         virtual double GetMinimum( int *pbSuccess = NULL );
     124                 :         virtual double GetMaximum(int *pbSuccess = NULL );
     125                 :         virtual double GetOffset( int *pbSuccess = NULL );
     126                 :         virtual double GetScale( int *pbSuccess = NULL );
     127                 :         virtual const char *GetUnitType();
     128                 :         virtual GDALColorInterp GetColorInterpretation();
     129                 :         virtual GDALColorTable *GetColorTable();
     130                 :         virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
     131                 : 
     132                 :         virtual CPLErr SetCategoryNames( char ** );
     133                 :         virtual CPLErr SetNoDataValue( double );
     134                 :         virtual CPLErr SetColorTable( GDALColorTable * ); 
     135                 :         virtual CPLErr SetColorInterpretation( GDALColorInterp );
     136                 :         virtual CPLErr SetOffset( double );
     137                 :         virtual CPLErr SetScale( double );
     138                 :         virtual CPLErr SetUnitType( const char * );
     139                 : 
     140                 :         virtual CPLErr GetStatistics( int bApproxOK, int bForce,
     141                 :                                     double *pdfMin, double *pdfMax, 
     142                 :                                     double *pdfMean, double *padfStdDev );
     143                 :         virtual CPLErr ComputeStatistics( int bApproxOK, 
     144                 :                                         double *pdfMin, double *pdfMax, 
     145                 :                                         double *pdfMean, double *pdfStdDev,
     146                 :                                         GDALProgressFunc, void *pProgressData );
     147                 :         virtual CPLErr SetStatistics( double dfMin, double dfMax, 
     148                 :                                     double dfMean, double dfStdDev );
     149                 :         virtual CPLErr ComputeRasterMinMax( int, double* );
     150                 : 
     151                 :         virtual int HasArbitraryOverviews();
     152                 :         virtual int GetOverviewCount();
     153                 :         virtual GDALRasterBand *GetOverview(int);
     154                 :         virtual GDALRasterBand *GetRasterSampleOverview( int );
     155                 :         virtual CPLErr BuildOverviews( const char *, int, int *,
     156                 :                                     GDALProgressFunc, void * );
     157                 : 
     158                 :         virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
     159                 :                                 int nBufXSize, int nBufYSize, 
     160                 :                                 GDALDataType eDT, char **papszOptions );
     161                 : 
     162                 :         virtual CPLErr  GetHistogram( double dfMin, double dfMax,
     163                 :                             int nBuckets, int * panHistogram,
     164                 :                             int bIncludeOutOfRange, int bApproxOK,
     165                 :                             GDALProgressFunc, void *pProgressData );
     166                 : 
     167                 :         virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
     168                 :                                             int *pnBuckets, int ** ppanHistogram,
     169                 :                                             int bForce,
     170                 :                                             GDALProgressFunc, void *pProgressData);
     171                 :         virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
     172                 :                                             int nBuckets, int *panHistogram );
     173                 : 
     174                 :         virtual const GDALRasterAttributeTable *GetDefaultRAT();
     175                 :         virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
     176                 : 
     177                 :         virtual GDALRasterBand *GetMaskBand();
     178                 :         virtual int             GetMaskFlags();
     179                 :         virtual CPLErr          CreateMaskBand( int nFlags );
     180                 : 
     181                 : };
     182                 : 
     183                 : 
     184                 : /* ******************************************************************** */
     185                 : /*                     GDALProxyPoolDataset                             */
     186                 : /* ******************************************************************** */
     187                 : 
     188                 : typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry;
     189                 : class     GDALProxyPoolRasterBand;
     190                 : 
     191                 : class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset
     192                 : {
     193                 :     private:
     194                 :         GIntBig          responsiblePID;
     195                 : 
     196                 :         char            *pszProjectionRef;
     197                 :         double           adfGeoTransform[6];
     198                 :         int              bHasSrcProjection;
     199                 :         int              bHasSrcGeoTransform;
     200                 :         char            *pszGCPProjection;
     201                 :         int              nGCPCount;
     202                 :         GDAL_GCP        *pasGCPList;
     203                 :         CPLHashSet      *metadataSet;
     204                 :         CPLHashSet      *metadataItemSet;
     205                 : 
     206                 :         GDALProxyPoolCacheEntry* cacheEntry;
     207                 : 
     208                 :     protected:
     209                 :         virtual GDALDataset *RefUnderlyingDataset();
     210                 :         virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
     211                 : 
     212                 :         friend class     GDALProxyPoolRasterBand;
     213                 : 
     214                 :     public:
     215                 :         GDALProxyPoolDataset(const char* pszSourceDatasetDescription,
     216                 :                             int nRasterXSize, int nRasterYSize,
     217                 :                             GDALAccess eAccess = GA_ReadOnly,
     218                 :                             int bShared = FALSE,
     219                 :                             const char * pszProjectionRef = NULL,
     220                 :                             double * padfGeoTransform = NULL);
     221                 :         ~GDALProxyPoolDataset();
     222                 : 
     223                 :         void         AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
     224                 : 
     225                 :         virtual const char *GetProjectionRef(void);
     226                 :         virtual CPLErr SetProjection( const char * );
     227                 : 
     228                 :         virtual CPLErr GetGeoTransform( double * );
     229                 :         virtual CPLErr SetGeoTransform( double * );
     230                 : 
     231                 :         /* Special behaviour for the following methods : they return a pointer */
     232                 :         /* data type, that must be cached by the proxy, so it doesn't become invalid */
     233                 :         /* when the underlying object get closed */
     234                 :         virtual char      **GetMetadata( const char * pszDomain  );
     235                 :         virtual const char *GetMetadataItem( const char * pszName,
     236                 :                                             const char * pszDomain  );
     237                 : 
     238                 :         virtual void *GetInternalHandle( const char * pszRequest );
     239                 : 
     240                 :         virtual const char *GetGCPProjection();
     241                 :         virtual const GDAL_GCP *GetGCPs();
     242                 : };
     243                 : 
     244                 : /* ******************************************************************** */
     245                 : /*                  GDALProxyPoolRasterBand                             */
     246                 : /* ******************************************************************** */
     247                 : 
     248                 : class GDALProxyPoolOverviewRasterBand;
     249                 : class GDALProxyPoolMaskBand;
     250                 : 
     251                 : class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand
     252                 : {
     253                 :     private:
     254                 :         CPLHashSet      *metadataSet;
     255                 :         CPLHashSet      *metadataItemSet;
     256                 :         char            *pszUnitType;
     257                 :         char           **papszCategoryNames;
     258                 :         GDALColorTable  *poColorTable;
     259                 : 
     260                 :         int                               nSizeProxyOverviewRasterBand;
     261                 :         GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand;
     262                 :         GDALProxyPoolMaskBand            *poProxyMaskBand;
     263                 : 
     264                 :         void Init();
     265                 : 
     266                 :     protected:
     267                 :         virtual GDALRasterBand* RefUnderlyingRasterBand();
     268                 :         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
     269                 : 
     270                 :         friend class GDALProxyPoolOverviewRasterBand;
     271                 :         friend class GDALProxyPoolMaskBand;
     272                 : 
     273                 :     public:
     274                 :         GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, int nBand,
     275                 :                                 GDALDataType eDataType,
     276                 :                                 int nBlockXSize, int nBlockYSize);
     277                 :         GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS,
     278                 :                                 GDALRasterBand* poUnderlyingRasterBand);
     279                 :         ~GDALProxyPoolRasterBand();
     280                 : 
     281                 :         /* Special behaviour for the following methods : they return a pointer */
     282                 :         /* data type, that must be cached by the proxy, so it doesn't become invalid */
     283                 :         /* when the underlying object get closed */
     284                 :         virtual char      **GetMetadata( const char * pszDomain  );
     285                 :         virtual const char *GetMetadataItem( const char * pszName,
     286                 :                                             const char * pszDomain  );
     287                 :         virtual char **GetCategoryNames();
     288                 :         virtual const char *GetUnitType();
     289                 :         virtual GDALColorTable *GetColorTable();
     290                 :         virtual GDALRasterBand *GetOverview(int);
     291                 :         virtual GDALRasterBand *GetRasterSampleOverview( int nDesiredSamples); // TODO
     292                 :         virtual GDALRasterBand *GetMaskBand();
     293                 : 
     294                 : };
     295                 : 
     296                 : /* ******************************************************************** */
     297                 : /*                  GDALProxyPoolOverviewRasterBand                     */
     298                 : /* ******************************************************************** */
     299                 : 
     300                 : class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand
     301                 : {
     302                 :     private:
     303                 :         GDALProxyPoolRasterBand *poMainBand;
     304                 :         int                      nOverviewBand;
     305                 : 
     306                 :         GDALRasterBand          *poUnderlyingMainRasterBand;
     307                 :         int                      nRefCountUnderlyingMainRasterBand;
     308                 : 
     309                 :     protected:
     310                 :         virtual GDALRasterBand* RefUnderlyingRasterBand();
     311                 :         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
     312                 : 
     313                 :     public:
     314                 :         GDALProxyPoolOverviewRasterBand(GDALProxyPoolDataset* poDS,
     315                 :                                         GDALRasterBand* poUnderlyingOverviewBand,
     316                 :                                         GDALProxyPoolRasterBand* poMainBand,
     317                 :                                         int nOverviewBand);
     318                 :         ~GDALProxyPoolOverviewRasterBand();
     319                 : };
     320                 : 
     321                 : /* ******************************************************************** */
     322                 : /*                      GDALProxyPoolMaskBand                           */
     323                 : /* ******************************************************************** */
     324                 : 
     325                 : class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand
     326                 : {
     327                 :     private:
     328                 :         GDALProxyPoolRasterBand *poMainBand;
     329                 : 
     330                 :         GDALRasterBand          *poUnderlyingMainRasterBand;
     331                 :         int                      nRefCountUnderlyingMainRasterBand;
     332                 : 
     333                 :     protected:
     334                 :         virtual GDALRasterBand* RefUnderlyingRasterBand();
     335                 :         virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
     336                 : 
     337                 :     public:
     338                 :         GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
     339                 :                               GDALRasterBand* poUnderlyingMaskBand,
     340                 :                               GDALProxyPoolRasterBand* poMainBand);
     341                 :         ~GDALProxyPoolMaskBand();
     342                 : };
     343                 : 
     344                 : #endif
     345                 : 
     346                 : 
     347                 : /* ******************************************************************** */
     348                 : /*            C types and methods declarations                          */
     349                 : /* ******************************************************************** */
     350                 : 
     351                 : 
     352                 : CPL_C_START
     353                 : 
     354                 : typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH;
     355                 : 
     356                 : GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription,
     357                 :                                                          int nRasterXSize, int nRasterYSize,
     358                 :                                                          GDALAccess eAccess, int bShared,
     359                 :                                                          const char * pszProjectionRef,
     360                 :                                                          double * padfGeoTransform);
     361                 : 
     362                 : void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset);
     363                 : 
     364                 : void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset,
     365                 :                                                         GDALDataType eDataType,
     366                 :                                                         int nBlockXSize, int nBlockYSize);
     367                 : 
     368                 : CPL_C_END
     369                 : 
     370                 : #endif /* GDAL_PROXY_H_INCLUDED */

Generated by: LCOV version 1.7