1 : /******************************************************************************
2 : * $Id: gdalproxydataset.cpp 15193 2008-08-23 12:22:48Z rouault $
3 : *
4 : * Project: GDAL Core
5 : * Purpose: A dataset and raster band classes that act as proxy for underlying
6 : * GDALDataset* and GDALRasterBand*
7 : * Author: Even Rouault <even dot rouault at mines dash paris dot org>
8 : *
9 : ******************************************************************************
10 : * Copyright (c) 2008, Even Rouault
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_proxy.h"
32 :
33 : CPL_CVSID("$Id: gdalproxydataset.cpp 15193 2008-08-23 12:22:48Z rouault $");
34 :
35 : /* ******************************************************************** */
36 : /* GDALProxyDataset */
37 : /* ******************************************************************** */
38 :
39 : #define D_PROXY_METHOD_WITH_RET(retType, retErrValue, methodName, argList, argParams) \
40 : retType GDALProxyDataset::methodName argList \
41 : { \
42 : retType ret; \
43 : GDALDataset* poUnderlyingDataset = RefUnderlyingDataset(); \
44 : if (poUnderlyingDataset) \
45 : { \
46 : ret = poUnderlyingDataset->methodName argParams; \
47 : UnrefUnderlyingDataset(poUnderlyingDataset); \
48 : } \
49 : else \
50 : { \
51 : ret = retErrValue; \
52 : } \
53 : return ret; \
54 : }
55 :
56 :
57 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IRasterIO,
58 : ( GDALRWFlag eRWFlag,
59 : int nXOff, int nYOff, int nXSize, int nYSize,
60 : void * pData, int nBufXSize, int nBufYSize,
61 : GDALDataType eBufType,
62 : int nBandCount, int *panBandMap,
63 : int nPixelSpace, int nLineSpace, int nBandSpace),
64 : ( eRWFlag, nXOff, nYOff, nXSize, nYSize,
65 : pData, nBufXSize, nBufYSize,
66 : eBufType, nBandCount, panBandMap,
67 : nPixelSpace, nLineSpace, nBandSpace ))
68 :
69 :
70 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IBuildOverviews,
71 : ( const char *pszResampling,
72 : int nOverviews, int *panOverviewList,
73 : int nListBands, int *panBandList,
74 : GDALProgressFunc pfnProgress,
75 : void * pProgressData ),
76 : ( pszResampling, nOverviews, panOverviewList,
77 : nListBands, panBandList, pfnProgress, pProgressData ))
78 :
79 0 : void GDALProxyDataset::FlushCache()
80 : {
81 0 : GDALDataset* poUnderlyingDataset = RefUnderlyingDataset();
82 0 : if (poUnderlyingDataset)
83 : {
84 0 : poUnderlyingDataset->FlushCache();
85 0 : UnrefUnderlyingDataset(poUnderlyingDataset);
86 : }
87 0 : }
88 :
89 0 : D_PROXY_METHOD_WITH_RET(char**, NULL, GetMetadata, (const char * pszDomain), (pszDomain))
90 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadata,
91 : (char ** papszMetadata, const char * pszDomain),
92 : (papszMetadata, pszDomain))
93 0 : D_PROXY_METHOD_WITH_RET(const char*, NULL, GetMetadataItem,
94 : (const char * pszName, const char * pszDomain),
95 : (pszName, pszDomain))
96 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadataItem,
97 : (const char * pszName, const char * pszValue, const char * pszDomain),
98 : (pszName, pszValue, pszDomain))
99 :
100 4 : D_PROXY_METHOD_WITH_RET(const char *, NULL, GetProjectionRef, (), ())
101 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetProjection, (const char* pszProjection), (pszProjection))
102 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetGeoTransform, (double* padfGeoTransform), (padfGeoTransform))
103 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetGeoTransform, (double* padfGeoTransform), (padfGeoTransform))
104 :
105 0 : D_PROXY_METHOD_WITH_RET(void *, NULL, GetInternalHandle, ( const char * arg1), (arg1))
106 0 : D_PROXY_METHOD_WITH_RET(GDALDriver *, NULL, GetDriver, (), ())
107 0 : D_PROXY_METHOD_WITH_RET(char **, NULL, GetFileList, (), ())
108 0 : D_PROXY_METHOD_WITH_RET(int, 0, GetGCPCount, (), ())
109 0 : D_PROXY_METHOD_WITH_RET(const char *, NULL, GetGCPProjection, (), ())
110 0 : D_PROXY_METHOD_WITH_RET(const GDAL_GCP *, NULL, GetGCPs, (), ())
111 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetGCPs,
112 : (int nGCPCount, const GDAL_GCP *pasGCPList,
113 : const char *pszGCPProjection),
114 : (nGCPCount, pasGCPList, pszGCPProjection))
115 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, AdviseRead,
116 : ( int nXOff, int nYOff, int nXSize, int nYSize,
117 : int nBufXSize, int nBufYSize,
118 : GDALDataType eDT,
119 : int nBandCount, int *panBandList,
120 : char **papszOptions ),
121 : (nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, eDT, nBandCount, panBandList, papszOptions))
122 0 : D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, CreateMaskBand, ( int nFlags ), (nFlags))
123 :
124 : /************************************************************************/
125 : /* UnrefUnderlyingDataset() */
126 : /************************************************************************/
127 :
128 0 : void GDALProxyDataset::UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset)
129 : {
130 0 : }
131 :
132 : /* ******************************************************************** */
133 : /* GDALProxyRasterBand */
134 : /* ******************************************************************** */
135 :
136 :
137 : #define RB_PROXY_METHOD_WITH_RET(retType, retErrValue, methodName, argList, argParams) \
138 : retType GDALProxyRasterBand::methodName argList \
139 : { \
140 : retType ret; \
141 : GDALRasterBand* poSrcBand = RefUnderlyingRasterBand(); \
142 : if (poSrcBand) \
143 : { \
144 : ret = poSrcBand->methodName argParams; \
145 : UnrefUnderlyingRasterBand(poSrcBand); \
146 : } \
147 : else \
148 : { \
149 : ret = retErrValue; \
150 : } \
151 : return ret; \
152 : }
153 :
154 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IReadBlock,
155 : ( int nXBlockOff, int nYBlockOff, void* pImage),
156 : (nXBlockOff, nYBlockOff, pImage) )
157 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IWriteBlock,
158 : ( int nXBlockOff, int nYBlockOff, void* pImage),
159 : (nXBlockOff, nYBlockOff, pImage) )
160 12710 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IRasterIO,
161 : ( GDALRWFlag eRWFlag,
162 : int nXOff, int nYOff, int nXSize, int nYSize,
163 : void * pData, int nBufXSize, int nBufYSize,
164 : GDALDataType eBufType,
165 : int nPixelSpace,
166 : int nLineSpace ),
167 : (eRWFlag, nXOff, nYOff, nXSize, nYSize,
168 : pData, nBufXSize, nBufYSize, eBufType,
169 : nPixelSpace, nLineSpace ) )
170 :
171 3 : RB_PROXY_METHOD_WITH_RET(char**, NULL, GetMetadata, (const char * pszDomain), (pszDomain))
172 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadata,
173 : (char ** papszMetadata, const char * pszDomain),
174 : (papszMetadata, pszDomain))
175 2 : RB_PROXY_METHOD_WITH_RET(const char*, NULL, GetMetadataItem,
176 : (const char * pszName, const char * pszDomain),
177 : (pszName, pszDomain))
178 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadataItem,
179 : (const char * pszName, const char * pszValue, const char * pszDomain),
180 : (pszName, pszValue, pszDomain))
181 :
182 56 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, FlushCache, (), ())
183 0 : RB_PROXY_METHOD_WITH_RET(char**, NULL, GetCategoryNames, (), ())
184 5 : RB_PROXY_METHOD_WITH_RET(double, 0, GetNoDataValue, (int *pbSuccess), (pbSuccess))
185 0 : RB_PROXY_METHOD_WITH_RET(double, 0, GetMinimum, (int *pbSuccess), (pbSuccess))
186 0 : RB_PROXY_METHOD_WITH_RET(double, 0, GetMaximum, (int *pbSuccess), (pbSuccess))
187 3 : RB_PROXY_METHOD_WITH_RET(double, 0, GetOffset, (int *pbSuccess), (pbSuccess))
188 3 : RB_PROXY_METHOD_WITH_RET(double, 0, GetScale, (int *pbSuccess), (pbSuccess))
189 3 : RB_PROXY_METHOD_WITH_RET(const char*, NULL, GetUnitType, (), ())
190 0 : RB_PROXY_METHOD_WITH_RET(GDALColorInterp, GCI_Undefined, GetColorInterpretation, (), ())
191 0 : RB_PROXY_METHOD_WITH_RET(GDALColorTable*, NULL, GetColorTable, (), ())
192 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, Fill,
193 : (double dfRealValue, double dfImaginaryValue),
194 : (dfRealValue, dfImaginaryValue))
195 :
196 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetCategoryNames, ( char ** arg ), (arg))
197 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetNoDataValue, ( double arg ), (arg))
198 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetColorTable, ( GDALColorTable *arg ), (arg))
199 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetColorInterpretation,
200 : ( GDALColorInterp arg ), (arg))
201 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetOffset, ( double arg ), (arg))
202 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetScale, ( double arg ), (arg))
203 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetUnitType, ( const char * arg ), (arg))
204 :
205 2 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetStatistics,
206 : ( int bApproxOK, int bForce,
207 : double *pdfMin, double *pdfMax,
208 : double *pdfMean, double *padfStdDev ),
209 : (bApproxOK, bForce, pdfMin, pdfMax, pdfMean, padfStdDev))
210 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ComputeStatistics,
211 : ( int bApproxOK,
212 : double *pdfMin, double *pdfMax,
213 : double *pdfMean, double *pdfStdDev,
214 : GDALProgressFunc pfn, void *pProgressData ),
215 : ( bApproxOK, pdfMin, pdfMax, pdfMean, pdfStdDev, pfn, pProgressData))
216 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetStatistics,
217 : ( double dfMin, double dfMax,
218 : double dfMean, double dfStdDev ),
219 : (dfMin, dfMax, dfMean, dfStdDev))
220 1 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ComputeRasterMinMax,
221 : ( int arg1, double* arg2 ), (arg1, arg2))
222 :
223 0 : RB_PROXY_METHOD_WITH_RET(int, 0, HasArbitraryOverviews, (), ())
224 4 : RB_PROXY_METHOD_WITH_RET(int, 0, GetOverviewCount, (), ())
225 3 : RB_PROXY_METHOD_WITH_RET(GDALRasterBand*, NULL, GetOverview, (int arg1), (arg1))
226 0 : RB_PROXY_METHOD_WITH_RET(GDALRasterBand*, NULL, GetRasterSampleOverview,
227 : (int arg1), (arg1))
228 :
229 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, BuildOverviews,
230 : (const char * arg1, int arg2, int *arg3,
231 : GDALProgressFunc arg4, void * arg5),
232 : (arg1, arg2, arg3, arg4, arg5))
233 :
234 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, AdviseRead,
235 : ( int nXOff, int nYOff, int nXSize, int nYSize,
236 : int nBufXSize, int nBufYSize,
237 : GDALDataType eDT, char **papszOptions ),
238 : (nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, eDT, papszOptions))
239 :
240 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetHistogram,
241 : ( double dfMin, double dfMax,
242 : int nBuckets, int * panHistogram,
243 : int bIncludeOutOfRange, int bApproxOK,
244 : GDALProgressFunc pfn, void *pProgressData ),
245 : (dfMin, dfMax, nBuckets, panHistogram, bIncludeOutOfRange,
246 : bApproxOK, pfn, pProgressData))
247 :
248 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetDefaultHistogram,
249 : (double *pdfMin, double *pdfMax,
250 : int *pnBuckets, int ** ppanHistogram,
251 : int bForce,
252 : GDALProgressFunc pfn, void *pProgressData ),
253 : (pdfMin, pdfMax, pnBuckets, ppanHistogram, bForce,
254 : pfn, pProgressData))
255 :
256 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetDefaultHistogram,
257 : ( double dfMin, double dfMax,
258 : int nBuckets, int * panHistogram ),
259 : (dfMin, dfMax, nBuckets, panHistogram))
260 :
261 3 : RB_PROXY_METHOD_WITH_RET(const GDALRasterAttributeTable *, NULL,
262 : GetDefaultRAT, (), ())
263 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetDefaultRAT,
264 : ( const GDALRasterAttributeTable * arg1), (arg1))
265 :
266 0 : RB_PROXY_METHOD_WITH_RET(GDALRasterBand*, NULL, GetMaskBand, (), ())
267 6 : RB_PROXY_METHOD_WITH_RET(int, 0, GetMaskFlags, (), ())
268 0 : RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, CreateMaskBand, ( int nFlags ), (nFlags))
269 :
270 : /************************************************************************/
271 : /* UnrefUnderlyingRasterBand() */
272 : /************************************************************************/
273 :
274 10626 : void GDALProxyRasterBand::UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand)
275 : {
276 10626 : }
|