GDAL
gdal_proxy.h
1 /******************************************************************************
2  * $Id: gdal_proxy.h 39386 2017-06-29 15:21:47Z rouault $
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 
46 class CPL_DLL GDALProxyDataset : public GDALDataset
47 {
48  protected:
49  GDALProxyDataset() {}
50 
51  virtual GDALDataset *RefUnderlyingDataset() = 0;
52  virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset);
53 
54  virtual CPLErr IBuildOverviews( const char *, int, int *,
55  int, int *, GDALProgressFunc, void * ) CPL_OVERRIDE;
56  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
57  void *, int, int, GDALDataType,
58  int, int *, GSpacing, GSpacing, GSpacing,
59  GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
60  public:
61 
62  virtual char **GetMetadataDomainList() CPL_OVERRIDE;
63  virtual char **GetMetadata( const char * pszDomain ) CPL_OVERRIDE;
64  virtual CPLErr SetMetadata( char ** papszMetadata,
65  const char * pszDomain ) CPL_OVERRIDE;
66  virtual const char *GetMetadataItem( const char * pszName,
67  const char * pszDomain ) CPL_OVERRIDE;
68  virtual CPLErr SetMetadataItem( const char * pszName,
69  const char * pszValue,
70  const char * pszDomain ) CPL_OVERRIDE;
71 
72  virtual void FlushCache(void) CPL_OVERRIDE;
73 
74  virtual const char *GetProjectionRef(void) CPL_OVERRIDE;
75  virtual CPLErr SetProjection( const char * ) CPL_OVERRIDE;
76 
77  virtual CPLErr GetGeoTransform( double * ) CPL_OVERRIDE;
78  virtual CPLErr SetGeoTransform( double * ) CPL_OVERRIDE;
79 
80  virtual void *GetInternalHandle( const char * ) CPL_OVERRIDE;
81  virtual GDALDriver *GetDriver(void) CPL_OVERRIDE;
82  virtual char **GetFileList(void) CPL_OVERRIDE;
83 
84  virtual int GetGCPCount() CPL_OVERRIDE;
85  virtual const char *GetGCPProjection() CPL_OVERRIDE;
86  virtual const GDAL_GCP *GetGCPs() CPL_OVERRIDE;
87  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
88  const char *pszGCPProjection ) CPL_OVERRIDE;
89 
90  virtual 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 ) CPL_OVERRIDE;
95 
96  virtual CPLErr CreateMaskBand( int nFlags ) CPL_OVERRIDE;
97 
98  private:
99  CPL_DISALLOW_COPY_ASSIGN(GDALProxyDataset)
100 };
101 
102 /* ******************************************************************** */
103 /* GDALProxyRasterBand */
104 /* ******************************************************************** */
105 
106 class CPL_DLL GDALProxyRasterBand : public GDALRasterBand
107 {
108  protected:
109  GDALProxyRasterBand() {}
110 
111  virtual GDALRasterBand* RefUnderlyingRasterBand() = 0;
112  virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand);
113 
114  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
115  virtual CPLErr IWriteBlock( int, int, void * ) CPL_OVERRIDE;
116  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
117  void *, int, int, GDALDataType,
118  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
119 
120  public:
121 
122  virtual char **GetMetadataDomainList() CPL_OVERRIDE;
123  virtual char **GetMetadata( const char * pszDomain ) CPL_OVERRIDE;
124  virtual CPLErr SetMetadata( char ** papszMetadata,
125  const char * pszDomain ) CPL_OVERRIDE;
126  virtual const char *GetMetadataItem( const char * pszName,
127  const char * pszDomain ) CPL_OVERRIDE;
128  virtual CPLErr SetMetadataItem( const char * pszName,
129  const char * pszValue,
130  const char * pszDomain ) CPL_OVERRIDE;
131  virtual CPLErr FlushCache() CPL_OVERRIDE;
132  virtual char **GetCategoryNames() CPL_OVERRIDE;
133  virtual double GetNoDataValue( int *pbSuccess = NULL ) CPL_OVERRIDE;
134  virtual double GetMinimum( int *pbSuccess = NULL ) CPL_OVERRIDE;
135  virtual double GetMaximum(int *pbSuccess = NULL ) CPL_OVERRIDE;
136  virtual double GetOffset( int *pbSuccess = NULL ) CPL_OVERRIDE;
137  virtual double GetScale( int *pbSuccess = NULL ) CPL_OVERRIDE;
138  virtual const char *GetUnitType() CPL_OVERRIDE;
139  virtual GDALColorInterp GetColorInterpretation() CPL_OVERRIDE;
140  virtual GDALColorTable *GetColorTable() CPL_OVERRIDE;
141  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0) CPL_OVERRIDE;
142 
143  virtual CPLErr SetCategoryNames( char ** ) CPL_OVERRIDE;
144  virtual CPLErr SetNoDataValue( double ) CPL_OVERRIDE;
145  virtual CPLErr DeleteNoDataValue() CPL_OVERRIDE;
146  virtual CPLErr SetColorTable( GDALColorTable * ) CPL_OVERRIDE;
147  virtual CPLErr SetColorInterpretation( GDALColorInterp ) CPL_OVERRIDE;
148  virtual CPLErr SetOffset( double ) CPL_OVERRIDE;
149  virtual CPLErr SetScale( double ) CPL_OVERRIDE;
150  virtual CPLErr SetUnitType( const char * ) CPL_OVERRIDE;
151 
152  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
153  double *pdfMin, double *pdfMax,
154  double *pdfMean, double *padfStdDev ) CPL_OVERRIDE;
155  virtual CPLErr ComputeStatistics( int bApproxOK,
156  double *pdfMin, double *pdfMax,
157  double *pdfMean, double *pdfStdDev,
158  GDALProgressFunc, void *pProgressData ) CPL_OVERRIDE;
159  virtual CPLErr SetStatistics( double dfMin, double dfMax,
160  double dfMean, double dfStdDev ) CPL_OVERRIDE;
161  virtual CPLErr ComputeRasterMinMax( int, double* ) CPL_OVERRIDE;
162 
163  virtual int HasArbitraryOverviews() CPL_OVERRIDE;
164  virtual int GetOverviewCount() CPL_OVERRIDE;
165  virtual GDALRasterBand *GetOverview(int) CPL_OVERRIDE;
166  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig ) CPL_OVERRIDE;
167  virtual CPLErr BuildOverviews( const char *, int, int *,
168  GDALProgressFunc, void * ) CPL_OVERRIDE;
169 
170  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
171  int nBufXSize, int nBufYSize,
172  GDALDataType eDT, char **papszOptions ) CPL_OVERRIDE;
173 
174  virtual CPLErr GetHistogram( double dfMin, double dfMax,
175  int nBuckets, GUIntBig * panHistogram,
176  int bIncludeOutOfRange, int bApproxOK,
177  GDALProgressFunc, void *pProgressData ) CPL_OVERRIDE;
178 
179  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
180  int *pnBuckets, GUIntBig ** ppanHistogram,
181  int bForce,
182  GDALProgressFunc, void *pProgressData) CPL_OVERRIDE;
183  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
184  int nBuckets, GUIntBig *panHistogram ) CPL_OVERRIDE;
185 
186  virtual GDALRasterAttributeTable *GetDefaultRAT() CPL_OVERRIDE;
187  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ) CPL_OVERRIDE;
188 
189  virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE;
190  virtual int GetMaskFlags() CPL_OVERRIDE;
191  virtual CPLErr CreateMaskBand( int nFlags ) CPL_OVERRIDE;
192 
193  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
194  int *pnPixelSpace,
195  GIntBig *pnLineSpace,
196  char **papszOptions ) CPL_OVERRIDE;
197  private:
198  CPL_DISALLOW_COPY_ASSIGN(GDALProxyRasterBand)
199 };
200 
201 /* ******************************************************************** */
202 /* GDALProxyPoolDataset */
203 /* ******************************************************************** */
204 
205 typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry;
206 class GDALProxyPoolRasterBand;
207 
208 class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset
209 {
210  private:
211  GIntBig responsiblePID;
212 
213  char *pszProjectionRef;
214  double adfGeoTransform[6];
215  int bHasSrcProjection;
216  int bHasSrcGeoTransform;
217  char *pszGCPProjection;
218  int nGCPCount;
219  GDAL_GCP *pasGCPList;
220  CPLHashSet *metadataSet;
221  CPLHashSet *metadataItemSet;
222 
223  GDALProxyPoolCacheEntry* cacheEntry;
224  char *m_pszOwner;
225 
226  GDALDataset *RefUnderlyingDataset(bool bForceOpen);
227 
228  protected:
229  virtual GDALDataset *RefUnderlyingDataset() CPL_OVERRIDE;
230  virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset) CPL_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 = NULL,
240  double * padfGeoTransform = NULL,
241  const char* pszOwner = NULL);
242  virtual ~GDALProxyPoolDataset();
243 
244  void SetOpenOptions(char** papszOpenOptions);
245  void AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
246 
247  virtual void FlushCache(void) CPL_OVERRIDE;
248 
249  virtual const char *GetProjectionRef(void) CPL_OVERRIDE;
250  virtual CPLErr SetProjection( const char * ) CPL_OVERRIDE;
251 
252  virtual CPLErr GetGeoTransform( double * ) CPL_OVERRIDE;
253  virtual CPLErr SetGeoTransform( double * ) CPL_OVERRIDE;
254 
255  /* Special behaviour for the following methods : they return a pointer */
256  /* data type, that must be cached by the proxy, so it doesn't become invalid */
257  /* when the underlying object get closed */
258  virtual char **GetMetadata( const char * pszDomain ) CPL_OVERRIDE;
259  virtual const char *GetMetadataItem( const char * pszName,
260  const char * pszDomain ) CPL_OVERRIDE;
261 
262  virtual void *GetInternalHandle( const char * pszRequest ) CPL_OVERRIDE;
263 
264  virtual const char *GetGCPProjection() CPL_OVERRIDE;
265  virtual const GDAL_GCP *GetGCPs() CPL_OVERRIDE;
266  private:
267  CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolDataset)
268 };
269 
270 /* ******************************************************************** */
271 /* GDALProxyPoolRasterBand */
272 /* ******************************************************************** */
273 
274 class GDALProxyPoolOverviewRasterBand;
275 class GDALProxyPoolMaskBand;
276 
277 class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand
278 {
279  private:
280  CPLHashSet *metadataSet;
281  CPLHashSet *metadataItemSet;
282  char *pszUnitType;
283  char **papszCategoryNames;
284  GDALColorTable *poColorTable;
285 
286  int nSizeProxyOverviewRasterBand;
287  GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand;
288  GDALProxyPoolMaskBand *poProxyMaskBand;
289 
290  void Init();
291 
292  GDALRasterBand* RefUnderlyingRasterBand(bool bForceOpen);
293 
294  protected:
295  virtual GDALRasterBand* RefUnderlyingRasterBand() CPL_OVERRIDE;
296  virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand) CPL_OVERRIDE;
297 
298  friend class GDALProxyPoolOverviewRasterBand;
299  friend class GDALProxyPoolMaskBand;
300 
301  public:
302  GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, int nBand,
303  GDALDataType eDataType,
304  int nBlockXSize, int nBlockYSize);
305  GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS,
306  GDALRasterBand* poUnderlyingRasterBand);
307  virtual ~GDALProxyPoolRasterBand();
308 
309  void AddSrcMaskBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize);
310 
311  /* Special behaviour for the following methods : they return a pointer */
312  /* data type, that must be cached by the proxy, so it doesn't become invalid */
313  /* when the underlying object get closed */
314  virtual char **GetMetadata( const char * pszDomain ) CPL_OVERRIDE;
315  virtual const char *GetMetadataItem( const char * pszName,
316  const char * pszDomain ) CPL_OVERRIDE;
317  virtual char **GetCategoryNames() CPL_OVERRIDE;
318  virtual const char *GetUnitType() CPL_OVERRIDE;
319  virtual GDALColorTable *GetColorTable() CPL_OVERRIDE;
320  virtual GDALRasterBand *GetOverview(int) CPL_OVERRIDE;
321  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig nDesiredSamples) CPL_OVERRIDE; // TODO
322  virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE;
323 
324  virtual CPLErr FlushCache() CPL_OVERRIDE;
325  private:
326  CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolRasterBand)
327 };
328 
329 /* ******************************************************************** */
330 /* GDALProxyPoolOverviewRasterBand */
331 /* ******************************************************************** */
332 
333 class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand
334 {
335  private:
336  GDALProxyPoolRasterBand *poMainBand;
337  int nOverviewBand;
338 
339  GDALRasterBand *poUnderlyingMainRasterBand;
340  int nRefCountUnderlyingMainRasterBand;
341 
342  protected:
343  virtual GDALRasterBand* RefUnderlyingRasterBand() CPL_OVERRIDE;
344  virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand) CPL_OVERRIDE;
345 
346  public:
347  GDALProxyPoolOverviewRasterBand(GDALProxyPoolDataset* poDS,
348  GDALRasterBand* poUnderlyingOverviewBand,
349  GDALProxyPoolRasterBand* poMainBand,
350  int nOverviewBand);
351  virtual ~GDALProxyPoolOverviewRasterBand();
352 };
353 
354 /* ******************************************************************** */
355 /* GDALProxyPoolMaskBand */
356 /* ******************************************************************** */
357 
358 class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand
359 {
360  private:
361  GDALProxyPoolRasterBand *poMainBand;
362 
363  GDALRasterBand *poUnderlyingMainRasterBand;
364  int nRefCountUnderlyingMainRasterBand;
365 
366  protected:
367  virtual GDALRasterBand* RefUnderlyingRasterBand() CPL_OVERRIDE;
368  virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand) CPL_OVERRIDE;
369 
370  public:
371  GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
372  GDALRasterBand* poUnderlyingMaskBand,
373  GDALProxyPoolRasterBand* poMainBand);
374  GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
375  GDALProxyPoolRasterBand* poMainBand,
376  GDALDataType eDataType,
377  int nBlockXSize, int nBlockYSize);
378  virtual ~GDALProxyPoolMaskBand();
379 };
380 
381 #endif
382 
383 /* ******************************************************************** */
384 /* C types and methods declarations */
385 /* ******************************************************************** */
386 
388 
389 typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH;
390 
391 GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription,
392  int nRasterXSize, int nRasterYSize,
393  GDALAccess eAccess, int bShared,
394  const char * pszProjectionRef,
395  double * padfGeoTransform);
396 
397 void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset);
398 
399 void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset,
400  GDALDataType eDataType,
401  int nBlockXSize, int nBlockYSize);
402 
403 CPL_C_END
404 
405 #endif /* #ifndef DOXYGEN_SKIP */
406 
407 #endif /* GDAL_PROXY_H_INCLUDED */
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:46
GDALDataType
Definition: gdal.h:57
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:352
C++ GDAL entry points.
#define CPL_OVERRIDE
To be used in public headers only.
Definition: cpl_port.h:1055
GDALRWFlag
Definition: gdal.h:113
Hash set implementation.
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:267
Public (C callable) GDAL entry points.
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:141
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:253
A single raster band (or channel).
Definition: gdal_priv.h:831
GDALAccess
Definition: gdal.h:107
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:324
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:354
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:250
GDALColorInterp
Definition: gdal.h:184
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition: cpl_hash_set.h:52
Definition: gdal.h:108
Format specific driver.
Definition: gdal_priv.h:1162
A color table / palette.
Definition: gdal_priv.h:751
Ground Control Point.
Definition: gdal.h:536
CPLErr
Error category.
Definition: cpl_error.h:52
#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:1085

Generated for GDAL by doxygen 1.8.8.