[gdal-dev] Overriding methods for particular formats

Frank Warmerdam warmerda at h...
Sat Dec 5 23:02:14 EST 1998


Folks,

Up to now I have expected those writing support for particular formats
to directly override the application callable methods they wish to
supply. For instance, the GXFDataset would directly override the
ReadBlock() method on the GDALDataset. 

The problem with this approach was that the base class implementation
had no way of providing generic argument checking, interposing access
to caches and so forth. 

In order to allow an extra layer of indirection I have decided to have
two versions of these overridable methods. First is the application
callback method such as ReadBlock(). This will contain a bunch of
argument validation (and potentially short circuiting code). It will
then call the ``internal'' method (ie. IReadBlock()). This is the
method that the subclasses would be expected to override. 

For instance, the read, and write definitions within GDALRasterBand
now look like this:

public:
CPLErr ReadBlock( int, int, void * );
CPLErr WriteBlock( int, int, void * );

protected:
virtual CPLErr IReadBlock( int, int, void * ) = 0;
virtual CPLErr IWriteBlock( int, int, void * );

Applications can call ReadBlock(), and WriteBlock() directly. Drivers
are expected to override the internal methods (IReadBlock() and 
IWriteBlock()). I will attempt to follow this convention (of prefixing
an I) for all external/internal method pairs. 

Later,

-----------------------------------+---------------------------------------
Who can give them back their lives | Frank Warmerdam, Software Developer
and all those wasted years? - Rush | URL http://members.home.com/warmerda
| warmerda at h...
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com





More information about the Gdal-dev mailing list