~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to gcore/gdalproxypool.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: gdalproxypool.cpp 17636 2009-09-12 23:19:18Z warmerdam $
 
2
 * $Id: gdalproxypool.cpp 21669 2011-02-10 00:49:16Z rouault $
3
3
 *
4
4
 * Project:  GDAL Core
5
5
 * Purpose:  A dataset and raster band classes that differ the opening of the
31
31
#include "gdal_proxy.h"
32
32
#include "cpl_multiproc.h"
33
33
 
34
 
CPL_CVSID("$Id: gdalproxypool.cpp 17636 2009-09-12 23:19:18Z warmerdam $");
 
34
CPL_CVSID("$Id: gdalproxypool.cpp 21669 2011-02-10 00:49:16Z rouault $");
35
35
 
36
36
/* Functions shared between gdalproxypool.cpp and gdaldataset.cpp */
37
37
void** GDALGetphDLMutex();
102
102
        static void Unref();
103
103
        static GDALProxyPoolCacheEntry* RefDataset(const char* pszFileName, GDALAccess eAccess);
104
104
        static void UnrefDataset(GDALProxyPoolCacheEntry* cacheEntry);
 
105
 
 
106
        static void PreventDestroy();
 
107
        static void ForceDestroy();
105
108
};
106
109
 
107
110
 
319
322
      singleton->refCount++;
320
323
}
321
324
 
 
325
/* keep that in sync with gdaldrivermanager.cpp */
 
326
void GDALDatasetPool::PreventDestroy()
 
327
{
 
328
    CPLMutexHolderD( GDALGetphDLMutex() );
 
329
    if (! singleton)
 
330
        return;
 
331
    singleton->refCountOfDisableRefCount ++;
 
332
}
 
333
 
 
334
/* keep that in sync with gdaldrivermanager.cpp */
 
335
void GDALDatasetPoolPreventDestroy()
 
336
{
 
337
    GDALDatasetPool::PreventDestroy();
 
338
}
 
339
 
 
340
 
322
341
/************************************************************************/
323
342
/*                               Unref()                                */
324
343
/************************************************************************/
342
361
    }
343
362
}
344
363
 
 
364
/* keep that in sync with gdaldrivermanager.cpp */
 
365
void GDALDatasetPool::ForceDestroy()
 
366
{
 
367
    CPLMutexHolderD( GDALGetphDLMutex() );
 
368
    if (! singleton)
 
369
        return;
 
370
    singleton->refCountOfDisableRefCount --;
 
371
    CPLAssert(singleton->refCountOfDisableRefCount == 0);
 
372
    singleton->refCount = 0;
 
373
    delete singleton;
 
374
    singleton = NULL;
 
375
}
 
376
 
 
377
/* keep that in sync with gdaldrivermanager.cpp */
 
378
void GDALDatasetPoolForceDestroy()
 
379
{
 
380
    GDALDatasetPool::ForceDestroy();
 
381
}
 
382
 
345
383
/************************************************************************/
346
384
/*                           RefDataset()                               */
347
385
/************************************************************************/
432
470
/*                     GDALProxyPoolDataset                             */
433
471
/* ******************************************************************** */
434
472
 
 
473
/* Note : the bShared parameter must be used with caution. You can */
 
474
/* set it to TRUE  for being used as a VRT source : in that case, */
 
475
/* VRTSimpleSource will take care of destroying it when there are no */
 
476
/* reference to it (in VRTSimpleSource::~VRTSimpleSource()) */
 
477
/* However this will not be registered as a genuine shared dataset, like it */
 
478
/* would have been with MarkAsShared(). But MarkAsShared() is not usable for */
 
479
/* GDALProxyPoolDataset objects, as they share the same description as their */
 
480
/* underlying dataset. So *NEVER* call MarkAsShared() on a GDALProxyPoolDataset */
 
481
/* object */
 
482
 
435
483
GDALProxyPoolDataset::GDALProxyPoolDataset(const char* pszSourceDatasetDescription,
436
484
                                   int nRasterXSize, int nRasterYSize,
437
485
                                   GDALAccess eAccess, int bShared,
490
538
 
491
539
GDALProxyPoolDataset::~GDALProxyPoolDataset()
492
540
{
 
541
    /* See comment in constructor */
 
542
    /* It is not really a genuine shared dataset, so we don't */
 
543
    /* want ~GDALDataset() to try to release it from its */
 
544
    /* shared dataset hashset. This will save a */
 
545
    /* "Should not happen. Cannot find %s, this=%p in phSharedDatasetSet" debug message */
 
546
    bShared = FALSE;
 
547
 
493
548
    CPLFree(pszProjectionRef);
494
549
    CPLFree(pszGCPProjection);
495
550
    if (nGCPCount)
843
898
 
844
899
 
845
900
/************************************************************************/
 
901
/*                 AddSrcMaskBandDescription()                          */
 
902
/************************************************************************/
 
903
 
 
904
void GDALProxyPoolRasterBand::AddSrcMaskBandDescription( GDALDataType eDataType,
 
905
                                                         int nBlockXSize,
 
906
                                                         int nBlockYSize)
 
907
{
 
908
    CPLAssert(poProxyMaskBand == NULL);
 
909
    poProxyMaskBand = new GDALProxyPoolMaskBand((GDALProxyPoolDataset*)poDS,
 
910
                                                this, eDataType,
 
911
                                                nBlockXSize, nBlockYSize);
 
912
}
 
913
 
 
914
/************************************************************************/
846
915
/*                  RefUnderlyingRasterBand()                           */
847
916
/************************************************************************/
848
917
 
852
921
    if (poUnderlyingDataset == NULL)
853
922
        return NULL;
854
923
 
855
 
    return poUnderlyingDataset->GetRasterBand(nBand);
 
924
    GDALRasterBand* poBand = poUnderlyingDataset->GetRasterBand(nBand);
 
925
    if (poBand == NULL)
 
926
    {
 
927
        ((GDALProxyPoolDataset*)poDS)->UnrefUnderlyingDataset(poUnderlyingDataset);
 
928
    }
 
929
 
 
930
    return poBand;
856
931
}
857
932
 
858
933
/************************************************************************/
1136
1211
}
1137
1212
 
1138
1213
/* ******************************************************************** */
 
1214
/*                     GDALProxyPoolMaskBand()                          */
 
1215
/* ******************************************************************** */
 
1216
 
 
1217
GDALProxyPoolMaskBand::GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS,
 
1218
                                             GDALProxyPoolRasterBand* poMainBand,
 
1219
                                             GDALDataType eDataType,
 
1220
                                             int nBlockXSize, int nBlockYSize) :
 
1221
        GDALProxyPoolRasterBand(poDS, 1, eDataType, nBlockXSize, nBlockYSize)
 
1222
{
 
1223
    this->poMainBand = poMainBand;
 
1224
 
 
1225
    poUnderlyingMainRasterBand = NULL;
 
1226
    nRefCountUnderlyingMainRasterBand = 0;
 
1227
}
 
1228
 
 
1229
/* ******************************************************************** */
1139
1230
/*                          ~GDALProxyPoolMaskBand()                    */
1140
1231
/* ******************************************************************** */
1141
1232