GDAL
gdal_proxy.h
1/******************************************************************************
2 * $Id: gdal_proxy.h b10430acb1303d18052fc20ebc36de01e01398fd 2018-10-25 14:49:58 -0500 Sander Jansen $
3 *
4 * Project: GDAL Core
5 * Purpose: GDAL Core C++/Private declarations
6 * Author: Even Rouault <even dot rouault at mines dash paris dot org>
7 *
8 ******************************************************************************
9 * Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 ****************************************************************************/
29
30#ifndef GDAL_PROXY_H_INCLUDED
31#define GDAL_PROXY_H_INCLUDED
32
33#ifndef DOXYGEN_SKIP
34
35#include "gdal.h"
36
37#ifdef __cplusplus
38
39#include "gdal_priv.h"
40#include "cpl_hash_set.h"
41
42/* ******************************************************************** */
43/* GDALProxyDataset */
44/* ******************************************************************** */
45
46class CPL_DLL GDALProxyDataset : public GDALDataset
47{
48 protected:
49 GDALProxyDataset() {}
50
51 virtual GDALDataset *RefUnderlyingDataset() = 0;
52 virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
53
54 CPLErr IBuildOverviews( const char *, int, int *,
55 int, int *, GDALProgressFunc, void * ) override;
56 CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
57 void *, int, int, GDALDataType,
58 int, int *, GSpacing, GSpacing, GSpacing,
59 GDALRasterIOExtraArg* psExtraArg ) override;
60
61 public:
62 char **GetMetadataDomainList() override;
63 char **GetMetadata( const char * pszDomain ) override;
64 CPLErr SetMetadata( char ** papszMetadata,
65 const char * pszDomain ) override;
66 const char *GetMetadataItem( const char * pszName,
67 const char * pszDomain ) override;
68 CPLErr SetMetadataItem( const char * pszName,
69 const char * pszValue,
70 const char * pszDomain ) override;
71
72 void FlushCache() override;
73
74 const char *GetProjectionRef(void) override;
75 CPLErr SetProjection( const char * ) override;
76
77 CPLErr GetGeoTransform( double * ) override;
78 CPLErr SetGeoTransform( double * ) override;
79
80 void *GetInternalHandle( const char * ) override;
81 GDALDriver *GetDriver() override;
82 char **GetFileList() override;
83
84 int GetGCPCount() override;
85 const char *GetGCPProjection() override;
86 const GDAL_GCP *GetGCPs() override;
87 CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
88 const char *pszGCPProjection ) override;
89
90 CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
91 int nBufXSize, int nBufYSize,
92 GDALDataType eDT,
93 int nBandCount, int *panBandList,
94 char **papszOptions ) override;
95
96 CPLErr CreateMaskBand( int nFlags ) override;
97
98 private:
99 CPL_DISALLOW_COPY_ASSIGN(GDALProxyDataset)
100};
101
102/* ******************************************************************** */
103/* GDALProxyRasterBand */
104/* ******************************************************************** */
105
106class CPL_DLL GDALProxyRasterBand : public GDALRasterBand
107{
108 protected:
109 GDALProxyRasterBand() {}
110
111 virtual GDALRasterBand* RefUnderlyingRasterBand() = 0;
112 virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
113
114 CPLErr IReadBlock( int, int, void * ) override;
115 CPLErr IWriteBlock( int, int, void * ) override;
116 CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
117 void *, int, int, GDALDataType,
118 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) override;
119
120 public:
121 char **GetMetadataDomainList() override;
122 char **GetMetadata( const char * pszDomain ) override;
123 CPLErr SetMetadata( char ** papszMetadata,
124 const char * pszDomain ) override;
125 const char *GetMetadataItem( const char * pszName,
126 const char * pszDomain ) override;
127 CPLErr SetMetadataItem( const char * pszName,
128 const char * pszValue,
129 const char * pszDomain ) override;
130 CPLErr FlushCache() override;
131 char **GetCategoryNames() override;
132 double GetNoDataValue( int *pbSuccess = nullptr ) override;
133 double GetMinimum( int *pbSuccess = nullptr ) override;
134 double GetMaximum(int *pbSuccess = nullptr ) override;
135 double GetOffset( int *pbSuccess = nullptr ) override;
136 double GetScale( int *pbSuccess = nullptr ) override;
137 const char *GetUnitType() override;
138 GDALColorInterp GetColorInterpretation() override;
139 GDALColorTable *GetColorTable() override;
140 CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0) override;
141
142 CPLErr SetCategoryNames( char ** ) override;
143 CPLErr SetNoDataValue( double ) override;
144 CPLErr DeleteNoDataValue() override;
145 CPLErr SetColorTable( GDALColorTable * ) override;
146 CPLErr SetColorInterpretation( GDALColorInterp ) override;
147 CPLErr SetOffset( double ) override;
148 CPLErr SetScale( double ) override;
149 CPLErr SetUnitType( const char * ) override;
150
151 CPLErr GetStatistics( int bApproxOK, int bForce,
152 double *pdfMin, double *pdfMax,
153 double *pdfMean, double *padfStdDev ) override;
154 CPLErr ComputeStatistics( int bApproxOK,
155 double *pdfMin, double *pdfMax,
156 double *pdfMean, double *pdfStdDev,
157 GDALProgressFunc, void *pProgressData ) override;
158 CPLErr SetStatistics( double dfMin, double dfMax,
159 double dfMean, double dfStdDev ) override;
160 CPLErr ComputeRasterMinMax( int, double* ) override;
161
162 int HasArbitraryOverviews() override;
163 int GetOverviewCount() override;
164 GDALRasterBand *GetOverview( int ) override;
165 GDALRasterBand *GetRasterSampleOverview( GUIntBig ) override;
166 CPLErr BuildOverviews( const char *, int, int *,
167 GDALProgressFunc, void * ) override;
168
169 CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
170 int nBufXSize, int nBufYSize,
171 GDALDataType eDT, char **papszOptions ) override;
172
173 CPLErr GetHistogram( double dfMin, double dfMax,
174 int nBuckets, GUIntBig * panHistogram,
175 int bIncludeOutOfRange, int bApproxOK,
176 GDALProgressFunc, void *pProgressData ) override;
177
178 CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
179 int *pnBuckets, GUIntBig ** ppanHistogram,
180 int bForce,
181 GDALProgressFunc, void *pProgressData) override;
182 CPLErr SetDefaultHistogram( double dfMin, double dfMax,
183 int nBuckets, GUIntBig *panHistogram ) override;
184
185 GDALRasterAttributeTable *GetDefaultRAT() override;
186 CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ) override;
187
188 GDALRasterBand *GetMaskBand() override;
189 int GetMaskFlags() override;
190 CPLErr CreateMaskBand( int nFlags ) override;
191
192 CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
193 int *pnPixelSpace,
194 GIntBig *pnLineSpace,
195 char **papszOptions ) override;
196
197 private:
198 CPL_DISALLOW_COPY_ASSIGN(GDALProxyRasterBand)
199};
200
201/* ******************************************************************** */
202/* GDALProxyPoolDataset */
203/* ******************************************************************** */
204
205typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry;
206class GDALProxyPoolRasterBand;
207
208class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset
209{
210 private:
211 GIntBig responsiblePID = -1;
212
213 char *pszProjectionRef = nullptr;
214 double adfGeoTransform[6]{0,1,0,0,0,1};
215 int bHasSrcProjection = false;
216 int bHasSrcGeoTransform = false;
217 char *pszGCPProjection = nullptr;
218 int nGCPCount = 0;
219 GDAL_GCP *pasGCPList = nullptr;
220 CPLHashSet *metadataSet = nullptr;
221 CPLHashSet *metadataItemSet = nullptr;
222
223 GDALProxyPoolCacheEntry* cacheEntry = nullptr;
224 char *m_pszOwner = nullptr;
225
226 GDALDataset *RefUnderlyingDataset(bool bForceOpen);
227
228 protected:
229 GDALDataset *RefUnderlyingDataset() override;
230 void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset) override;
231
232 friend class GDALProxyPoolRasterBand;
233
234 public:
235 GDALProxyPoolDataset( const char* pszSourceDatasetDescription,
236 int nRasterXSize, int nRasterYSize,
237 GDALAccess eAccess = GA_ReadOnly,
238 int bShared = FALSE,
239 const char * pszProjectionRef = nullptr,
240 double * padfGeoTransform = nullptr,
241 const char* pszOwner = nullptr );
242 ~GDALProxyPoolDataset() override;
243
244 void SetOpenOptions( char** papszOpenOptions );
245 void AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize,
246 int nBlockYSize );
247
248 // Used by VRT SimpleSource to add a single GDALProxyPoolRasterBand while
249 // keeping all other bands initialized to a nullptr. This is under the assumption,
250 // VRT SimpleSource will not have to access any other bands than the one added.
251 void AddSrcBand(int nBand, GDALDataType eDataType, int nBlockXSize,
252 int nBlockYSize );
253 void FlushCache() override;
254
255 const char *GetProjectionRef() override;
256 CPLErr SetProjection( const char * ) override;
257
258 CPLErr GetGeoTransform( double * ) override;
259 CPLErr SetGeoTransform( double * ) override;
260
261 // Special behaviour for the following methods : they return a pointer
262 // data type, that must be cached by the proxy, so it doesn't become invalid
263 // when the underlying object get closed.
264 char **GetMetadata( const char * pszDomain ) override;
265 const char *GetMetadataItem( const char * pszName,
266 const char * pszDomain ) override;
267
268 void *GetInternalHandle( const char * pszRequest ) override;
269
270 const char *GetGCPProjection() override;
271 const GDAL_GCP *GetGCPs() override;
272
273 private:
274 CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolDataset)
275};
276
277/* ******************************************************************** */
278/* GDALProxyPoolRasterBand */
279/* ******************************************************************** */
280
281class GDALProxyPoolOverviewRasterBand;
282class GDALProxyPoolMaskBand;
283
284class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand
285{
286 private:
287 CPLHashSet *metadataSet = nullptr;
288 CPLHashSet *metadataItemSet = nullptr;
289 char *pszUnitType = nullptr;
290 char **papszCategoryNames = nullptr;
291 GDALColorTable *poColorTable = nullptr;
292
293 int nSizeProxyOverviewRasterBand = 0;
294 GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand = nullptr;
295 GDALProxyPoolMaskBand *poProxyMaskBand = nullptr;
296
297 GDALRasterBand* RefUnderlyingRasterBand( bool bForceOpen );
298
299 protected:
300 GDALRasterBand* RefUnderlyingRasterBand() override;
301 void UnrefUnderlyingRasterBand( GDALRasterBand* poUnderlyingRasterBand )
302 override;
303
304 friend class GDALProxyPoolOverviewRasterBand;
305 friend class GDALProxyPoolMaskBand;
306
307 public:
308 GDALProxyPoolRasterBand( GDALProxyPoolDataset* poDS, int nBand,
309 GDALDataType eDataType,
310 int nBlockXSize, int nBlockYSize );
311 GDALProxyPoolRasterBand( GDALProxyPoolDataset* poDS,
312 GDALRasterBand* poUnderlyingRasterBand );
313 ~GDALProxyPoolRasterBand() override;
314
315 void AddSrcMaskBandDescription( GDALDataType eDataType, int nBlockXSize,
316 int nBlockYSize );
317
318 // Special behaviour for the following methods : they return a pointer
319 // data type, that must be cached by the proxy, so it doesn't become invalid
320 // when the underlying object get closed.
321 char **GetMetadata( const char * pszDomain ) override;
322 const char *GetMetadataItem( const char * pszName,
323 const char * pszDomain ) override;
324 char **GetCategoryNames() override;
325 const char *GetUnitType() override;
326 GDALColorTable *GetColorTable() override;
327 GDALRasterBand *GetOverview( int ) override;
328 GDALRasterBand *GetRasterSampleOverview( GUIntBig nDesiredSamples ) override; // TODO
329 GDALRasterBand *GetMaskBand() override;
330
331 CPLErr FlushCache() override;
332
333 private:
334 CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolRasterBand)
335};
336
337/* ******************************************************************** */
338/* GDALProxyPoolOverviewRasterBand */
339/* ******************************************************************** */
340
341class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand
342{
343 private:
344 GDALProxyPoolRasterBand *poMainBand = nullptr;
345 int nOverviewBand = 0;
346
347 GDALRasterBand *poUnderlyingMainRasterBand = nullptr;
348 int nRefCountUnderlyingMainRasterBand = 0;
349
350 CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolOverviewRasterBand)
351
352 protected:
353 GDALRasterBand* RefUnderlyingRasterBand() override;
354 void UnrefUnderlyingRasterBand( GDALRasterBand* poUnderlyingRasterBand )
355 override;
356
357 public:
358 GDALProxyPoolOverviewRasterBand( GDALProxyPoolDataset* poDS,
359 GDALRasterBand* poUnderlyingOverviewBand,
360 GDALProxyPoolRasterBand* poMainBand,
361 int nOverviewBand );
362 ~GDALProxyPoolOverviewRasterBand() override;
363};
364
365/* ******************************************************************** */
366/* GDALProxyPoolMaskBand */
367/* ******************************************************************** */
368
369class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand
370{
371 private:
372 GDALProxyPoolRasterBand *poMainBand = nullptr;
373
374 GDALRasterBand *poUnderlyingMainRasterBand = nullptr;
375 int nRefCountUnderlyingMainRasterBand = 0;
376
377 CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolMaskBand)
378
379 protected:
380 GDALRasterBand* RefUnderlyingRasterBand() override;
381 void UnrefUnderlyingRasterBand( GDALRasterBand* poUnderlyingRasterBand )
382 override;
383
384 public:
385 GDALProxyPoolMaskBand( GDALProxyPoolDataset* poDS,
386 GDALRasterBand* poUnderlyingMaskBand,
387 GDALProxyPoolRasterBand* poMainBand );
388 GDALProxyPoolMaskBand( GDALProxyPoolDataset* poDS,
389 GDALProxyPoolRasterBand* poMainBand,
390 GDALDataType eDataType,
391 int nBlockXSize, int nBlockYSize );
392 ~GDALProxyPoolMaskBand() override;
393};
394
395#endif
396
397/* ******************************************************************** */
398/* C types and methods declarations */
399/* ******************************************************************** */
400
402
403typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH;
404
405GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription,
406 int nRasterXSize, int nRasterYSize,
407 GDALAccess eAccess, int bShared,
408 const char * pszProjectionRef,
409 double * padfGeoTransform);
410
411void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset);
412
413void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset,
414 GDALDataType eDataType,
415 int nBlockXSize, int nBlockYSize);
416
418
419#endif /* #ifndef DOXYGEN_SKIP */
420
421#endif /* GDAL_PROXY_H_INCLUDED */
A color table / palette.
Definition: gdal_priv.h:938
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:336
virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eDT, int nBandCount, int *panBandList, char **papszOptions)
Advise driver of upcoming read requests.
Definition: gdaldataset.cpp:2278
char ** GetMetadataDomainList() override
Fetch list of metadata domains.
Definition: gdaldataset.cpp:3585
virtual void * GetInternalHandle(const char *pszHandleName)
Fetch a format specific internally meaningful handle.
Definition: gdaldataset.cpp:1022
CPLErr BuildOverviews(const char *, int, int *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdaldataset.cpp:1458
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2460
virtual const char * GetGCPProjection()
Get output projection for GCPs.
Definition: gdaldataset.cpp:1299
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const char *pszGCPProjection)
Assign GCPs.
Definition: gdaldataset.cpp:1382
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1264
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:922
virtual CPLErr SetProjection(const char *pszProjection)
Set the projection reference string for this dataset.
Definition: gdaldataset.cpp:864
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
virtual GDALDriver * GetDriver(void)
Fetch the driver to which this dataset relates.
Definition: gdaldataset.cpp:1060
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:977
virtual const char * GetProjectionRef(void)
Fetch the projection definition string for this dataset.
Definition: gdaldataset.cpp:824
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
virtual void FlushCache(void)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:396
void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:3484
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1332
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:2360
const char * GetMetadataItem(const char *pszName, const char *pszDomain) override
Fetch single metadata item.
Format specific driver.
Definition: gdal_priv.h:1387
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:48
A single raster band (or channel).
Definition: gdal_priv.h:1033
CPLErr
Error category.
Definition: cpl_error.h:53
Hash set implementation.
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition: cpl_hash_set.h:52
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:989
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
Public (C callable) GDAL entry points.
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:273
GDALAccess
Definition: gdal.h:113
@ GA_ReadOnly
Definition: gdal.h:114
GDALDataType
Definition: gdal.h:60
GDALColorInterp
Definition: gdal.h:191
GDALRWFlag
Definition: gdal.h:119
C++ GDAL entry points.
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:148
Ground Control Point.
Definition: gdal.h:561

Generated for GDAL by doxygen 1.9.4.