1 : /******************************************************************************
2 : * $Id: rawdataset.h 17624 2009-09-08 22:49:28Z rouault $
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 : #include "gdal_pam.h"
32 :
33 : /************************************************************************/
34 : /* ==================================================================== */
35 : /* RawDataset */
36 : /* ==================================================================== */
37 : /************************************************************************/
38 :
39 : class RawRasterBand;
40 :
41 : class CPL_DLL RawDataset : public GDALPamDataset
42 : {
43 : friend class RawRasterBand;
44 :
45 : protected:
46 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
47 : void *, int, int, GDALDataType,
48 : int, int *, int, int, int );
49 : public:
50 : RawDataset();
51 : ~RawDataset();
52 :
53 : };
54 :
55 : /************************************************************************/
56 : /* ==================================================================== */
57 : /* RawRasterBand */
58 : /* ==================================================================== */
59 : /************************************************************************/
60 :
61 : class CPL_DLL RawRasterBand : public GDALPamRasterBand
62 : {
63 : protected:
64 : friend class RawDataset;
65 :
66 : FILE *fpRaw;
67 : int bIsVSIL;
68 :
69 : vsi_l_offset nImgOffset;
70 : int nPixelOffset;
71 : int nLineOffset;
72 : int nLineSize;
73 : int bNativeOrder;
74 :
75 : int nLoadedScanline;
76 : void *pLineBuffer;
77 : int bDirty;
78 :
79 : GDALColorTable *poCT;
80 : GDALColorInterp eInterp;
81 :
82 : char **papszCategoryNames;
83 :
84 : int bOwnsFP;
85 :
86 : int Seek( vsi_l_offset, int );
87 : size_t Read( void *, size_t, size_t );
88 : size_t Write( void *, size_t, size_t );
89 :
90 : CPLErr AccessBlock( vsi_l_offset nBlockOff, int nBlockSize,
91 : void * pData );
92 : int IsLineLoaded( int nLineOff, int nLines );
93 : void Initialize();
94 :
95 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
96 : void *, int, int, GDALDataType,
97 : int, int );
98 :
99 : public:
100 :
101 : RawRasterBand( GDALDataset *poDS, int nBand, FILE * fpRaw,
102 : vsi_l_offset nImgOffset, int nPixelOffset,
103 : int nLineOffset,
104 : GDALDataType eDataType, int bNativeOrder,
105 : int bIsVSIL = FALSE, int bOwnsFP = FALSE );
106 :
107 : RawRasterBand( FILE * fpRaw,
108 : vsi_l_offset nImgOffset, int nPixelOffset,
109 : int nLineOffset,
110 : GDALDataType eDataType, int bNativeOrder,
111 : int nXSize, int nYSize, int bIsVSIL = FALSE, int bOwnsFP = FALSE );
112 :
113 : ~RawRasterBand();
114 :
115 : // should override RasterIO eventually.
116 :
117 : virtual CPLErr IReadBlock( int, int, void * );
118 : virtual CPLErr IWriteBlock( int, int, void * );
119 :
120 : virtual GDALColorTable *GetColorTable();
121 : virtual GDALColorInterp GetColorInterpretation();
122 : virtual CPLErr SetColorTable( GDALColorTable * );
123 : virtual CPLErr SetColorInterpretation( GDALColorInterp );
124 :
125 : virtual char **GetCategoryNames();
126 : virtual CPLErr SetCategoryNames( char ** );
127 :
128 : virtual CPLErr FlushCache();
129 :
130 : CPLErr AccessLine( int iLine );
131 :
132 : void SetAccess( GDALAccess eAccess );
133 :
134 : // this is deprecated.
135 : void StoreNoDataValue( double );
136 :
137 : // Query methods for internal data.
138 : vsi_l_offset GetImgOffset() { return nImgOffset; }
139 : int GetPixelOffset() { return nPixelOffset; }
140 : int GetLineOffset() { return nLineOffset; }
141 : int GetNativeOrder() { return bNativeOrder; }
142 : int GetIsVSIL() { return bIsVSIL; }
143 0 : FILE *GetFP() { return fpRaw; }
144 : int GetOwnsFP() { return bOwnsFP; }
145 : };
146 :
|