1 : /******************************************************************************
2 : * $Id: rawdataset.h 18538 2010-01-12 17:52:08Z mloskot $
3 : *
4 : * Project: Raw Translator
5 : * Purpose: Implementation of RawDataset class. Intented to be subclassed
6 : * by other raw formats.
7 : * Author: Frank Warmerdam, warmerdam@pobox.com
8 : *
9 : ******************************************************************************
10 : * Copyright (c) 1999, Frank Warmerdam
11 : *
12 : * Permission is hereby granted, free of charge, to any person obtaining a
13 : * copy of this software and associated documentation files (the "Software"),
14 : * to deal in the Software without restriction, including without limitation
15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : * and/or sell copies of the Software, and to permit persons to whom the
17 : * Software is furnished to do so, subject to the following conditions:
18 : *
19 : * The above copyright notice and this permission notice shall be included
20 : * in all copies or substantial portions of the Software.
21 : *
22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 : * DEALINGS IN THE SOFTWARE.
29 : ****************************************************************************/
30 :
31 : #ifndef GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED
32 : #define GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED
33 :
34 : #include "gdal_pam.h"
35 :
36 : /************************************************************************/
37 : /* ==================================================================== */
38 : /* RawDataset */
39 : /* ==================================================================== */
40 : /************************************************************************/
41 :
42 : class RawRasterBand;
43 :
44 : /**
45 : * \brief Abstract Base Class dedicated to define new raw dataset types.
46 : */
47 : class CPL_DLL RawDataset : public GDALPamDataset
48 : {
49 : friend class RawRasterBand;
50 :
51 : protected:
52 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
53 : void *, int, int, GDALDataType,
54 : int, int *, int, int, int );
55 : public:
56 : RawDataset();
57 : ~RawDataset() = 0;
58 :
59 : };
60 :
61 : /************************************************************************/
62 : /* ==================================================================== */
63 : /* RawRasterBand */
64 : /* ==================================================================== */
65 : /************************************************************************/
66 :
67 : /**
68 : * \brief Abstract Base Class dedicated to define raw datasets.
69 : * \note It is not defined an Abstract Base Class, but it's advised to
70 : * consider it as such and not use it directly in client's code.
71 : */
72 : class CPL_DLL RawRasterBand : public GDALPamRasterBand
73 : {
74 : protected:
75 : friend class RawDataset;
76 :
77 : FILE *fpRaw;
78 : int bIsVSIL;
79 :
80 : vsi_l_offset nImgOffset;
81 : int nPixelOffset;
82 : int nLineOffset;
83 : int nLineSize;
84 : int bNativeOrder;
85 :
86 : int nLoadedScanline;
87 : void *pLineBuffer;
88 : int bDirty;
89 :
90 : GDALColorTable *poCT;
91 : GDALColorInterp eInterp;
92 :
93 : char **papszCategoryNames;
94 :
95 : int bOwnsFP;
96 :
97 : int Seek( vsi_l_offset, int );
98 : size_t Read( void *, size_t, size_t );
99 : size_t Write( void *, size_t, size_t );
100 :
101 : CPLErr AccessBlock( vsi_l_offset nBlockOff, int nBlockSize,
102 : void * pData );
103 : int IsLineLoaded( int nLineOff, int nLines );
104 : void Initialize();
105 :
106 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
107 : void *, int, int, GDALDataType,
108 : int, int );
109 :
110 : public:
111 :
112 : RawRasterBand( GDALDataset *poDS, int nBand, FILE * fpRaw,
113 : vsi_l_offset nImgOffset, int nPixelOffset,
114 : int nLineOffset,
115 : GDALDataType eDataType, int bNativeOrder,
116 : int bIsVSIL = FALSE, int bOwnsFP = FALSE );
117 :
118 : RawRasterBand( FILE * fpRaw,
119 : vsi_l_offset nImgOffset, int nPixelOffset,
120 : int nLineOffset,
121 : GDALDataType eDataType, int bNativeOrder,
122 : int nXSize, int nYSize, int bIsVSIL = FALSE, int bOwnsFP = FALSE );
123 :
124 : ~RawRasterBand() /* = 0 */ ;
125 :
126 : // should override RasterIO eventually.
127 :
128 : virtual CPLErr IReadBlock( int, int, void * );
129 : virtual CPLErr IWriteBlock( int, int, void * );
130 :
131 : virtual GDALColorTable *GetColorTable();
132 : virtual GDALColorInterp GetColorInterpretation();
133 : virtual CPLErr SetColorTable( GDALColorTable * );
134 : virtual CPLErr SetColorInterpretation( GDALColorInterp );
135 :
136 : virtual char **GetCategoryNames();
137 : virtual CPLErr SetCategoryNames( char ** );
138 :
139 : virtual CPLErr FlushCache();
140 :
141 : CPLErr AccessLine( int iLine );
142 :
143 : void SetAccess( GDALAccess eAccess );
144 :
145 : // this is deprecated.
146 : void StoreNoDataValue( double );
147 :
148 : // Query methods for internal data.
149 3 : vsi_l_offset GetImgOffset() { return nImgOffset; }
150 3 : int GetPixelOffset() { return nPixelOffset; }
151 3 : int GetLineOffset() { return nLineOffset; }
152 4 : int GetNativeOrder() { return bNativeOrder; }
153 : int GetIsVSIL() { return bIsVSIL; }
154 10 : FILE *GetFP() { return fpRaw; }
155 : int GetOwnsFP() { return bOwnsFP; }
156 : };
157 :
158 : #endif // GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED
|