Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

gdal_priv.h

00001 /******************************************************************************
00002  * $Id: gdal_priv_h-source.html,v 1.14 2002/12/21 19:13:12 warmerda Exp $
00003  *
00004  * Name:     gdal_priv.h
00005  * Project:  GDAL Core
00006  * Purpose:  GDAL Core C++/Private declarations. 
00007  * Author:   Frank Warmerdam, warmerda@home.com
00008  *
00009  ******************************************************************************
00010  * Copyright (c) 1998, Frank Warmerdam
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028  * DEALINGS IN THE SOFTWARE.
00029  ******************************************************************************
00030  *
00031  * $Log: gdal_priv_h-source.html,v $
00031  * Revision 1.14  2002/12/21 19:13:12  warmerda
00031  * updated
00031  *
00032  * Revision 1.38  2002/10/21 18:05:42  warmerda
00033  * added AutoSkipDrivers() method on driver manager
00034  *
00035  * Revision 1.37  2002/09/11 14:17:52  warmerda
00036  * make SetDescription() and GetDescription() virtual
00037  *
00038  * Revision 1.36  2002/09/04 06:52:05  warmerda
00039  * added unload driver support to GDALDriver
00040  *
00041  * Revision 1.35  2002/07/09 20:33:12  warmerda
00042  * expand tabs
00043  *
00044  * Revision 1.34  2002/06/19 18:19:59  warmerda
00045  * GDALOpenInfo: added bIsDirecory flag, removed VSIStatBuf
00046  *
00047  * Revision 1.33  2002/06/12 21:13:27  warmerda
00048  * use metadata based driver info
00049  *
00050  * Revision 1.32  2002/05/29 15:58:26  warmerda
00051  * removed GetDescription(), added SetColorInterpretation()
00052  *
00053  * Revision 1.31  2002/05/28 18:56:22  warmerda
00054  * added shared dataset concept
00055  *
00056  * Revision 1.30  2002/03/01 14:29:09  warmerda
00057  * added GetBand() method on GDALRasterBand
00058  *
00059  * Revision 1.29  2001/12/15 15:42:27  warmerda
00060  * *** empty log message ***
00061  *
00062  * Revision 1.28  2001/11/18 00:52:15  warmerda
00063  * removed GDALProjDef
00064  *
00065  * Revision 1.27  2001/11/16 21:36:01  warmerda
00066  * added the AddBand() method on GDALDataset
00067  *
00068  * Revision 1.26  2001/10/17 21:47:02  warmerda
00069  * added SetGCPs() on GDALDataset
00070  *
00071  * Revision 1.25  2001/10/02 13:15:16  warmerda
00072  * added CPL_DLL for GDALDefaultOverviews
00073  *
00074  * Revision 1.24  2001/06/20 16:08:54  warmerda
00075  * GDALDefaultOverviews now remembers ovr filename, and allows explicit setting
00076  *
00077  * Revision 1.23  2001/02/06 16:30:21  warmerda
00078  * Added gdal_frmts.h
00079  *
00080  * Revision 1.22  2000/10/06 15:26:08  warmerda
00081  * added SetNoDataValue, SetCategoryNames
00082  *
00083  * Revision 1.21  2000/07/20 13:38:26  warmerda
00084  * make GetGDALDriverManager public with CPL_DLL
00085  *
00086  * Revision 1.20  2000/04/30 23:22:16  warmerda
00087  * added CreateCopy support
00088  *
00089  * Revision 1.19  2000/04/21 21:55:01  warmerda
00090  * majorobject updates, and overview building
00091  *
00092  * Revision 1.18  2000/04/04 23:44:29  warmerda
00093  * added AutoLoadDrivers() to GDALDriverManager
00094  *
00095  * Revision 1.17  2000/03/31 13:41:24  warmerda
00096  * added gcps
00097  *
00098  * Revision 1.16  2000/03/24 00:09:05  warmerda
00099  * rewrote cache management
00100  *
00101  * Revision 1.15  2000/03/09 23:22:03  warmerda
00102  * added GetHistogram
00103  *
00104  * Revision 1.14  2000/03/06 02:20:35  warmerda
00105  * added colortables, overviews, etc
00106  *
00107  * Revision 1.12  2000/01/31 15:00:25  warmerda
00108  * added some documentation
00109  *
00110  * Revision 1.11  2000/01/31 14:24:36  warmerda
00111  * implemented dataset delete
00112  *
00113  * Revision 1.10  1999/11/11 21:59:07  warmerda
00114  * added GetDriver() for datasets
00115  *
00116  * Revision 1.9  1999/10/21 13:23:45  warmerda
00117  * Added a bit of driver related documentation.
00118  *
00119  * Revision 1.8  1999/10/21 12:04:11  warmerda
00120  * Reorganized header.
00121  *
00122  * Revision 1.7  1999/10/01 14:44:02  warmerda
00123  * added documentation
00124  *
00125  * Revision 1.6  1999/04/21 04:16:25  warmerda
00126  * experimental docs
00127  *
00128  * Revision 1.5  1999/01/11 15:36:18  warmerda
00129  * Added projections support, and a few other things.
00130  *
00131  * Revision 1.4  1998/12/31 18:54:25  warmerda
00132  * Implement initial GDALRasterBlock support, and block cache
00133  *
00134  * Revision 1.3  1998/12/06 22:17:09  warmerda
00135  * Fill out rasterio support.
00136  *
00137  * Revision 1.2  1998/12/03 18:34:06  warmerda
00138  * Update to use CPL
00139  *
00140  * Revision 1.1  1998/10/18 06:15:11  warmerda
00141  * Initial implementation.
00142  *
00143  */
00144 
00145 #ifndef GDAL_PRIV_H_INCLUDED
00146 #define GDAL_PRIV_H_INCLUDED
00147 
00148 /* -------------------------------------------------------------------- */
00149 /*      Predeclare various classes before pulling in gdal.h, the        */
00150 /*      public declarations.                                            */
00151 /* -------------------------------------------------------------------- */
00152 class GDALMajorObject;
00153 class GDALDataset;
00154 class GDALRasterBand;
00155 class GDALDriver;
00156 
00157 /* -------------------------------------------------------------------- */
00158 /*      Pull in the public declarations.  This gets the C apis, and     */
00159 /*      also various constants.  However, we will still get to          */
00160 /*      provide the real class definitions for the GDAL classes.        */
00161 /* -------------------------------------------------------------------- */
00162 
00163 #include "gdal.h"
00164 #include "gdal_frmts.h"
00165 #include "cpl_vsi.h"
00166 #include "cpl_conv.h"
00167 
00168 /* ******************************************************************** */
00169 /*                           GDALMajorObject                            */
00170 /*                                                                      */
00171 /*      Base class providing metadata, description and other            */
00172 /*      services shared by major objects.                               */
00173 /* ******************************************************************** */
00174 
00175 class CPL_DLL GDALMajorObject
00176 {
00177   protected:
00178     char             *pszDescription;
00179     char            **papszMetadata;
00180     
00181   public:
00182                         GDALMajorObject();
00183     virtual            ~GDALMajorObject();
00184                         
00185     virtual const char *GetDescription() const;
00186     virtual void        SetDescription( const char * );
00187 
00188     virtual char      **GetMetadata( const char * pszDomain = "" );
00189     virtual CPLErr      SetMetadata( char ** papszMetadata,
00190                                      const char * pszDomain = "" );
00191     virtual const char *GetMetadataItem( const char * pszName,
00192                                          const char * pszDomain = "" );
00193     virtual CPLErr      SetMetadataItem( const char * pszName,
00194                                          const char * pszValue,
00195                                          const char * pszDomain = "" );
00196 };
00197 
00198 /* ******************************************************************** */
00199 /*                         GDALDefaultOverviews                         */
00200 /* ******************************************************************** */
00201 class CPL_DLL GDALDefaultOverviews
00202 {
00203     GDALDataset *poDS;
00204     GDALDataset *poODS;
00205     
00206     char        *pszOvrFilename;
00207     
00208   public:
00209                GDALDefaultOverviews();
00210                ~GDALDefaultOverviews();
00211 
00212     void       Initialize( GDALDataset *poDS, const char *pszName = NULL, 
00213                            int bNameIsOVR = FALSE );
00214     int        IsInitialized() { return poDS != NULL; }
00215 
00216     int        GetOverviewCount(int);
00217     GDALRasterBand *GetOverview(int,int);
00218 
00219     CPLErr     BuildOverviews( const char * pszBasename,
00220                                const char * pszResampling, 
00221                                int nOverviews, int * panOverviewList,
00222                                int nBands, int * panBandList,
00223                                GDALProgressFunc pfnProgress,
00224                                void *pProgressData );
00225 };
00226 
00227 /* ******************************************************************** */
00228 /*                             GDALDataset                              */
00229 /* ******************************************************************** */
00230 
00237 class CPL_DLL GDALDataset : public GDALMajorObject
00238 {
00239     friend GDALDatasetH GDALOpen( const char *, GDALAccess);
00240     friend GDALDatasetH GDALOpenShared( const char *, GDALAccess);
00241     friend class GDALDriver;
00242 
00243   protected:
00244     GDALDriver  *poDriver;
00245     GDALAccess  eAccess;
00246     
00247     // Stored raster information.
00248     int         nRasterXSize;
00249     int         nRasterYSize;
00250     int         nBands;
00251     GDALRasterBand **papoBands;
00252 
00253     int         nRefCount;
00254     int         bShared;
00255 
00256                 GDALDataset(void);
00257     void        RasterInitialize( int, int );
00258     void        SetBand( int, GDALRasterBand * );
00259 
00260     GDALDefaultOverviews oOvManager;
00261     
00262     virtual CPLErr IBuildOverviews( const char *, int, int *,
00263                                     int, int *, GDALProgressFunc, void * );
00264     
00265     friend class GDALRasterBand;
00266     
00267   public:
00268     virtual     ~GDALDataset();
00269 
00270     int         GetRasterXSize( void );
00271     int         GetRasterYSize( void );
00272     int         GetRasterCount( void );
00273     GDALRasterBand *GetRasterBand( int );
00274 
00275     virtual void FlushCache(void);
00276 
00277     virtual const char *GetProjectionRef(void);
00278     virtual CPLErr SetProjection( const char * );
00279 
00280     virtual CPLErr GetGeoTransform( double * );
00281     virtual CPLErr SetGeoTransform( double * );
00282 
00283     virtual CPLErr        AddBand( GDALDataType eType, 
00284                                    char **papszOptions=NULL );
00285 
00286     virtual void *GetInternalHandle( const char * );
00287     virtual GDALDriver *GetDriver(void);
00288 
00289     virtual int    GetGCPCount();
00290     virtual const char *GetGCPProjection();
00291     virtual const GDAL_GCP *GetGCPs();
00292     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00293                             const char *pszGCPProjection );
00294  
00295     int           Reference();
00296     int           Dereference();
00297     GDALAccess    GetAccess() { return eAccess; }
00298 
00299     int           GetShared();
00300     void          MarkAsShared();
00301 
00302     static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
00303 
00304     CPLErr BuildOverviews( const char *, int, int *,
00305                            int, int *, GDALProgressFunc, void * );
00306 };
00307 
00308 /* ******************************************************************** */
00309 /*                           GDALRasterBlock                            */
00310 /* ******************************************************************** */
00311 
00314 class CPL_DLL GDALRasterBlock
00315 {
00316     GDALDataType        eType;
00317     
00318     int                 nAge;
00319     int                 bDirty;
00320 
00321     int                 nXOff;
00322     int                 nYOff;
00323        
00324     int                 nXSize;
00325     int                 nYSize;
00326     
00327     void                *pData;
00328 
00329     GDALRasterBand      *poBand;
00330     
00331     GDALRasterBlock     *poNext;
00332     GDALRasterBlock     *poPrevious;
00333 
00334   public:
00335                 GDALRasterBlock( GDALRasterBand *, int, int );
00336     virtual     ~GDALRasterBlock();
00337 
00338     CPLErr      Internalize( void );    /* make copy of data */
00339     void        Touch( void );          /* update age */
00340     void        MarkDirty( void );      /* data has been modified since read */
00341     void        MarkClean( void );
00342 
00343     CPLErr      Write();
00344 
00345     GDALDataType GetDataType() { return eType; }
00346     int         GetXOff() { return nXOff; }
00347     int         GetYOff() { return nYOff; }
00348     int         GetXSize() { return nXSize; }
00349     int         GetYSize() { return nYSize; }
00350     int         GetAge() { return nAge; }
00351     int         GetDirty() { return bDirty; }
00352 
00353     void        *GetDataRef( void ) { return pData; }
00354 
00355     GDALRasterBand *GetBand() { return poBand; }
00356 
00357     static void FlushOldestBlock();
00358     static void Verify();
00359 
00360 };
00361 
00362 
00363 /* ******************************************************************** */
00364 /*                             GDALColorTable                           */
00365 /* ******************************************************************** */
00366 
00367 class CPL_DLL GDALColorTable
00368 {
00369     GDALPaletteInterp eInterp;
00370 
00371     int         nEntryCount;
00372     GDALColorEntry *paoEntries;
00373 
00374 public:
00375                 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00376                 ~GDALColorTable();
00377 
00378     GDALColorTable *Clone() const;
00379 
00380     GDALPaletteInterp GetPaletteInterpretation() const;
00381 
00382     int           GetColorEntryCount() const;
00383     const GDALColorEntry *GetColorEntry( int ) const;
00384     int           GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00385     void          SetColorEntry( int, const GDALColorEntry * );
00386 };
00387 
00388 /* ******************************************************************** */
00389 /*                            GDALRasterBand                            */
00390 /* ******************************************************************** */
00391 
00393 
00394 class CPL_DLL GDALRasterBand : public GDALMajorObject
00395 {
00396   protected:
00397     GDALDataset *poDS;
00398     int         nBand; /* 1 based */
00399 
00400     int         nRasterXSize;
00401     int         nRasterYSize;
00402     
00403     GDALDataType eDataType;
00404     GDALAccess  eAccess;
00405 
00406     /* stuff related to blocking, and raster cache */
00407     int         nBlockXSize;
00408     int         nBlockYSize;
00409     int         nBlocksPerRow;
00410     int         nBlocksPerColumn;
00411 
00412     GDALRasterBlock **papoBlocks;
00413 
00414     friend class GDALDataset;
00415     friend class GDALRasterBlock;
00416 
00417   protected:
00418     virtual CPLErr IReadBlock( int, int, void * ) = 0;
00419     virtual CPLErr IWriteBlock( int, int, void * );
00420     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00421                               void *, int, int, GDALDataType,
00422                               int, int );
00423     CPLErr         OverviewRasterIO( GDALRWFlag, int, int, int, int,
00424                                      void *, int, int, GDALDataType,
00425                                      int, int );
00426 
00427     CPLErr         AdoptBlock( int, int, GDALRasterBlock * );
00428     void           InitBlockInfo();
00429 
00430   public:
00431                 GDALRasterBand();
00432                 
00433     virtual     ~GDALRasterBand();
00434 
00435     int         GetXSize();
00436     int         GetYSize();
00437     int         GetBand();
00438     GDALDataset*GetDataset();
00439 
00440     GDALDataType GetRasterDataType( void );
00441     void        GetBlockSize( int *, int * );
00442     GDALAccess  GetAccess();
00443     
00444     CPLErr      RasterIO( GDALRWFlag, int, int, int, int,
00445                           void *, int, int, GDALDataType,
00446                           int, int );
00447     CPLErr      ReadBlock( int, int, void * );
00448 
00449     CPLErr      WriteBlock( int, int, void * );
00450 
00451     GDALRasterBlock *GetBlockRef( int, int );
00452     CPLErr      FlushCache();
00453     CPLErr      FlushBlock( int = -1, int = -1 );
00454 
00455     // New OpengIS CV_SampleDimension stuff.
00456 
00457     virtual char **GetCategoryNames();
00458     virtual double GetNoDataValue( int *pbSuccess = NULL );
00459     virtual double GetMinimum( int *pbSuccess = NULL );
00460     virtual double GetMaximum(int *pbSuccess = NULL );
00461     virtual double GetOffset( int *pbSuccess = NULL );
00462     virtual double GetScale( int *pbSuccess = NULL );
00463     virtual const char *GetUnitType();
00464     virtual GDALColorInterp GetColorInterpretation();
00465     virtual GDALColorTable *GetColorTable();
00466 
00467     virtual CPLErr SetCategoryNames( char ** );
00468     virtual CPLErr SetNoDataValue( double );
00469     virtual CPLErr SetColorTable( GDALColorTable * ); 
00470     virtual CPLErr SetColorInterpretation( GDALColorInterp );
00471 
00472     virtual int HasArbitraryOverviews();
00473     virtual int GetOverviewCount();
00474     virtual GDALRasterBand *GetOverview(int);
00475     virtual CPLErr BuildOverviews( const char *, int, int *,
00476                                    GDALProgressFunc, void * );
00477 
00478     CPLErr  GetHistogram( double dfMin, double dfMax,
00479                           int nBuckets, int * panHistogram,
00480                           int bIncludeOutOfRange, int bApproxOK,
00481                           GDALProgressFunc, void *pProgressData );
00482 };
00483 
00484 /* ******************************************************************** */
00485 /*                             GDALOpenInfo                             */
00486 /*                                                                      */
00487 /*      Structure of data about dataset for open functions.             */
00488 /* ******************************************************************** */
00489 
00490 class CPL_DLL GDALOpenInfo
00491 {
00492   public:
00493 
00494                 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn );
00495                 ~GDALOpenInfo( void );
00496     
00497     char        *pszFilename;
00498 
00499     GDALAccess  eAccess;
00500 
00501     int         bStatOK;
00502     int         bIsDirectory;
00503 
00504     FILE        *fp;
00505 
00506     int         nHeaderBytes;
00507     GByte       *pabyHeader;
00508 
00509 };
00510 
00511 /* ******************************************************************** */
00512 /*                              GDALDriver                              */
00513 /* ******************************************************************** */
00514 
00524 class CPL_DLL GDALDriver : public GDALMajorObject
00525 {
00526   public:
00527                         GDALDriver();
00528                         ~GDALDriver();
00529 
00530 /* -------------------------------------------------------------------- */
00531 /*      Public C++ methods.                                             */
00532 /* -------------------------------------------------------------------- */
00533     GDALDataset         *Create( const char * pszName,
00534                                  int nXSize, int nYSize, int nBands,
00535                                  GDALDataType eType, char ** papszOptions );
00536 
00537     CPLErr              Delete( const char * pszName );
00538 
00539     GDALDataset         *CreateCopy( const char *, GDALDataset *, 
00540                                      int, char **,
00541                                      GDALProgressFunc pfnProgress, 
00542                                      void * pProgressData );
00543     
00544 /* -------------------------------------------------------------------- */
00545 /*      The following are semiprivate, not intended to be accessed      */
00546 /*      by anyone but the formats instantiating and populating the      */
00547 /*      drivers.                                                        */
00548 /* -------------------------------------------------------------------- */
00549     GDALDataset         *(*pfnOpen)( GDALOpenInfo * );
00550 
00551     GDALDataset         *(*pfnCreate)( const char * pszName,
00552                                        int nXSize, int nYSize, int nBands,
00553                                        GDALDataType eType,
00554                                        char ** papszOptions );
00555 
00556     CPLErr              (*pfnDelete)( const char * pszName );
00557 
00558     GDALDataset         *(*pfnCreateCopy)( const char *, GDALDataset *, 
00559                                            int, char **,
00560                                            GDALProgressFunc pfnProgress, 
00561                                            void * pProgressData );
00562 
00563     void                *pDriverData;
00564 
00565     void                (*pfnUnloadDriver)(GDALDriver *);
00566 };
00567 
00568 /* ******************************************************************** */
00569 /*                          GDALDriverManager                           */
00570 /* ******************************************************************** */
00571 
00579 class CPL_DLL GDALDriverManager : public GDALMajorObject
00580 {
00581     int         nDrivers;
00582     GDALDriver  **papoDrivers;
00583 
00584     char        *pszHome;
00585     
00586  public:
00587                 GDALDriverManager();
00588                 ~GDALDriverManager();
00589                 
00590     int         GetDriverCount( void );
00591     GDALDriver  *GetDriver( int );
00592     GDALDriver  *GetDriverByName( const char * );
00593 
00594     int         RegisterDriver( GDALDriver * );
00595     void        MoveDriver( GDALDriver *, int );
00596     void        DeregisterDriver( GDALDriver * );
00597 
00598     void        AutoLoadDrivers();
00599     void        AutoSkipDrivers();
00600 
00601     const char *GetHome();
00602     void        SetHome( const char * );
00603 };
00604 
00605 CPL_C_START
00606 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00607 CPL_C_END
00608 
00609 /* ==================================================================== */
00610 /*      An assortment of overview related stuff.                        */
00611 /* ==================================================================== */
00612 
00613 CPL_C_START
00614 
00615 CPLErr 
00616 GTIFFBuildOverviews( const char * pszFilename,
00617                      int nBands, GDALRasterBand **papoBandList, 
00618                      int nOverviews, int * panOverviewList,
00619                      const char * pszResampling, 
00620                      GDALProgressFunc pfnProgress, void * pProgressData );
00621 
00622 CPLErr
00623 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
00624                            const char * pszResampling, 
00625                            int nOverviews, int * panOverviewList,
00626                            int nBands, int * panBandList,
00627                            GDALProgressFunc pfnProgress, void * pProgressData);
00628                            
00629 
00630 CPLErr
00631 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **,
00632                          const char *, GDALProgressFunc, void * );
00633 
00634 CPL_C_END
00635 
00636 #endif /* ndef GDAL_PRIV_H_INCLUDED */

Generated at Sat Dec 21 14:01:58 2002 for GDAL by doxygen1.2.3-20001105 written by Dimitri van Heesch, © 1997-2000