OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ossimAppFixedTileCache Class Reference

#include <ossimAppFixedTileCache.h>

Public Types

typedef ossim_int32 ossimAppFixedCacheId
 

Public Member Functions

virtual ~ossimAppFixedTileCache ()
 
virtual void flush ()
 
virtual void flush (ossimAppFixedCacheId cacheId)
 
virtual void deleteCache (ossimAppFixedCacheId cacheId)
 
ossimAppFixedCacheId newTileCache (const ossimIrect &tileBoundaryRect, const ossimIpt &tileSize=ossimIpt(0, 0))
 
ossimAppFixedCacheId newTileCache ()
 
virtual void setRect (ossimAppFixedCacheId cacheId, const ossimIrect &boundaryTileRect)
 
virtual void setTileSize (ossimAppFixedCacheId cacheId, const ossimIpt &tileSize)
 
ossimRefPtr< ossimImageDatagetTile (ossimAppFixedCacheId cacheId, const ossimIpt &origin)
 
ossimRefPtr< ossimImageDataaddTile (ossimAppFixedCacheId cacheId, ossimRefPtr< ossimImageData > data, bool duplicateData=true)
 
ossimRefPtr< ossimImageDataremoveTile (ossimAppFixedCacheId cacheId, const ossimIpt &origin)
 
void deleteTile (ossimAppFixedCacheId cacheId, const ossimIpt &origin)
 
const ossimIptgetTileSize (ossimAppFixedCacheId cacheId)
 
virtual void setMaxCacheSize (ossim_uint32 cacheSize)
 

Static Public Member Functions

static ossimAppFixedTileCacheinstance (ossim_uint32 maxSize=0)
 

Static Public Attributes

static const ossim_uint32 DEFAULT_SIZE = 1024*1024*80
 

Protected Member Functions

 ossimAppFixedTileCache ()
 
ossimFixedTileCachegetCache (ossimAppFixedCacheId cacheId)
 
void shrinkGlobalCacheSize (ossim_int32 byteCount)
 
void shrinkCacheSize (ossimAppFixedCacheId id, ossim_int32 byteCount)
 
void shrinkCacheSize (ossimFixedTileCache *cache, ossim_int32 byteCount)
 
void deleteAll ()
 

Protected Attributes

ossimIpt theTileSize
 
ossim_uint32 theMaxCacheSize
 
ossim_uint32 theMaxGlobalCacheSize
 
ossim_uint32 theCurrentCacheSize
 
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap
 
std::mutex theMutex
 

Static Protected Attributes

static ossimAppFixedTileCachetheInstance = 0
 
static ossimAppFixedCacheId theUniqueAppIdCounter = 0
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimAppFixedTileCache &rhs)
 

Detailed Description

Definition at line 26 of file ossimAppFixedTileCache.h.

Member Typedef Documentation

◆ ossimAppFixedCacheId

Definition at line 32 of file ossimAppFixedTileCache.h.

Constructor & Destructor Documentation

◆ ~ossimAppFixedTileCache()

ossimAppFixedTileCache::~ossimAppFixedTileCache ( )
virtual

Definition at line 101 of file ossimAppFixedTileCache.cpp.

References deleteAll().

102 {
103  deleteAll();
104 }

◆ ossimAppFixedTileCache()

ossimAppFixedTileCache::ossimAppFixedTileCache ( )
protected

Definition at line 48 of file ossimAppFixedTileCache.cpp.

Referenced by instance().

49 {
50  if(traceDebug())
51  {
52  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimAppFixedTileCache::ossimAppFixedTileCache() DEBUG: entered ..." << std::endl;
53  }
54  theInstance = this;
55  theTileSize = ossimIpt(64, 64);
57 
58  // ossim::defaultTileSize(theTileSize);
59 
60  ossim_uint32 cacheSize = ossimString(ossimPreferences::instance()->findPreference("cache_size")).toUInt32()*(1024*1024);
61  const char* tileSize = ossimPreferences::instance()->findPreference("tile_size");
62  if(tileSize)
63  {
64  ossimString tempString(tileSize);
65  std::vector<ossimString> splitString;
66  tempString = tempString.trim();
67  tempString.split(splitString, " ");
68  if(splitString.size() > 1)
69  {
70  theTileSize.x = splitString[0].toInt32();
71  theTileSize.y = splitString[1].toInt32();
72  }
73  else
74  {
75  theTileSize = ossimIpt(64,64);
76  }
77 
78  }
79  if(cacheSize)
80  {
81  setMaxCacheSize(cacheSize);
82  }
83  else
84  {
86  }
87  if(traceDebug())
88  {
90  << "DEBUG: cache tile size = " << theTileSize << std::endl
91  << "Cache size = " << cacheSize << " bytes" << std::endl;
92  }
93 
94  if(traceDebug())
95  {
97  << "ossimAppFixedTileCache::ossimAppFixedTileCache() DEBUG: leaving ..." << std::endl;
98  }
99 }
ossim_uint32 toUInt32() const
const char * findPreference(const char *key) const
unsigned int ossim_uint32
static ossimPreferences * instance()
ossim_int32 y
Definition: ossimIpt.h:142
static ossimAppFixedTileCache * theInstance
virtual void setMaxCacheSize(ossim_uint32 cacheSize)
ossim_int32 x
Definition: ossimIpt.h:141
static const ossim_uint32 DEFAULT_SIZE
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Function Documentation

◆ addTile()

ossimRefPtr< ossimImageData > ossimAppFixedTileCache::addTile ( ossimAppFixedCacheId  cacheId,
ossimRefPtr< ossimImageData data,
bool  duplicateData = true 
)

Definition at line 255 of file ossimAppFixedTileCache.cpp.

References ossimFixedTileCache::addTile(), getCache(), ossimFixedTileCache::getCacheSize(), ossimImageData::getDataSizeInBytes(), shrinkCacheSize(), shrinkGlobalCacheSize(), theCurrentCacheSize, theMaxCacheSize, theMaxGlobalCacheSize, and theMutex.

Referenced by ossimCacheTileSource::fillTile(), ossimKakaduJpipHandler::getTileAtRes(), ossimGdalTileSource::getTileBlockRead(), ossimKakaduNitfReader::loadBlock(), ossimKakaduJp2Reader::loadTile(), and ossimKakaduJ2kReader::loadTile().

259 {
260  std::lock_guard<std::mutex> lock(theMutex);
261  ossimRefPtr<ossimImageData> result = 0;
262  ossimFixedTileCache *aCache = this->getCache(cacheId);
263  if(!aCache)
264  {
265  return result;
266  }
267  ossim_uint32 dataSize = data->getDataSizeInBytes();
268 
270  {
272  }
273 
274  ossim_uint32 cacheSize = 0;
275  {
276  cacheSize = aCache->getCacheSize();
277  }
278  if(cacheSize > theMaxCacheSize)
279  {
280 // shrinkCacheSize(aCache,
281 // (ossim_int32)(aCache->getCacheSize()*.1));
282  shrinkCacheSize(aCache,
283  (ossim_int32)(1024*1024));
284  }
285  {
286  cacheSize = aCache->getCacheSize();
287  result = aCache->addTile(data, duplicateData);
288 
289  theCurrentCacheSize += (aCache->getCacheSize() - cacheSize);
290  }
291 
292  return result;
293 }
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
unsigned int ossim_uint32
void shrinkGlobalCacheSize(ossim_int32 byteCount)
void shrinkCacheSize(ossimAppFixedCacheId id, ossim_int32 byteCount)
virtual ossim_uint32 getDataSizeInBytes() const
virtual ossimRefPtr< ossimImageData > addTile(ossimRefPtr< ossimImageData > imageData, bool duplicateData=true)
int ossim_int32

◆ deleteAll()

void ossimAppFixedTileCache::deleteAll ( )
protected

Definition at line 295 of file ossimAppFixedTileCache.cpp.

References theAppCacheMap, theCurrentCacheSize, and theMutex.

Referenced by ~ossimAppFixedTileCache().

296 {
297  std::lock_guard<std::mutex> lock(theMutex);
299  theAppCacheMap.clear();
300 }
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap

◆ deleteCache()

void ossimAppFixedTileCache::deleteCache ( ossimAppFixedCacheId  cacheId)
virtual

Definition at line 153 of file ossimAppFixedTileCache.cpp.

References getCache(), ossimFixedTileCache::getCacheSize(), theAppCacheMap, theCurrentCacheSize, theMutex, and ossimRefPtr< T >::valid().

Referenced by ossimJpegTileSource::allocate(), ossimPngReader::allocate(), ossimNitfTileSource::allocate(), ossimKakaduJp2Reader::closeEntry(), ossimKakaduJ2kReader::closeEntry(), ossimCacheTileSource::deleteRlevelCache(), ossimKakaduJpipHandler::deleteRlevelCache(), ossimGdalTileSource::deleteRlevelCache(), ossimJpegTileSource::destroy(), ossimPngReader::destroy(), ossimNitfTileSource::destroy(), and ossimNitfTileSource::setCacheEnabledFlag().

154 {
155  std::lock_guard<std::mutex> lock(theMutex);
157  {
158  std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator iter = theAppCacheMap.find(cacheId);
159 
160  if(cache.valid())
161  {
162  theAppCacheMap.erase(iter);
163  theCurrentCacheSize -= cache->getCacheSize();
164  }
165  cache = 0;
166  }
167 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap

◆ deleteTile()

void ossimAppFixedTileCache::deleteTile ( ossimAppFixedCacheId  cacheId,
const ossimIpt origin 
)

Definition at line 320 of file ossimAppFixedTileCache.cpp.

References ossimFixedTileCache::deleteTile(), getCache(), ossimFixedTileCache::getCacheSize(), theCurrentCacheSize, and theMutex.

322 {
323  std::lock_guard<std::mutex> lock(theMutex);
324  ossimFixedTileCache* cache = getCache(cacheId);
325  if(cache)
326  {
327  ossim_uint32 cacheSize = cache->getCacheSize();
328  cache->deleteTile(origin);
329  theCurrentCacheSize += (cache->getCacheSize() - cacheSize);
330  }
331 }
virtual void deleteTile(const ossimIpt &origin)
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
unsigned int ossim_uint32

◆ flush() [1/2]

void ossimAppFixedTileCache::flush ( )
virtual

Will flush all cache registered

Definition at line 127 of file ossimAppFixedTileCache.cpp.

References theAppCacheMap, theCurrentCacheSize, and theMutex.

Referenced by ossimCacheTileSource::flush(), ossimKakaduJpipHandler::flushCache(), and shrinkGlobalCacheSize().

128 {
129  std::lock_guard<std::mutex> lock(theMutex);
130  std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator currentIter = theAppCacheMap.begin();
131 
132  while(currentIter != theAppCacheMap.end())
133  {
134  (*currentIter).second->flush();
135  ++currentIter;
136  }
138 }
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap

◆ flush() [2/2]

void ossimAppFixedTileCache::flush ( ossimAppFixedCacheId  cacheId)
virtual

Definition at line 140 of file ossimAppFixedTileCache.cpp.

References ossimFixedTileCache::flush(), getCache(), ossimFixedTileCache::getCacheSize(), theCurrentCacheSize, and theMutex.

141 {
142  std::lock_guard<std::mutex> lock(theMutex);
143  ossimFixedTileCache* cache = getCache(cacheId);
144  {
145  if(cache)
146  {
147  theCurrentCacheSize -= cache->getCacheSize();
148  cache->flush();
149  }
150  }
151 }
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const

◆ getCache()

ossimFixedTileCache * ossimAppFixedTileCache::getCache ( ossimAppFixedCacheId  cacheId)
protected

Definition at line 333 of file ossimAppFixedTileCache.cpp.

References theAppCacheMap.

Referenced by addTile(), deleteCache(), deleteTile(), flush(), getTile(), getTileSize(), removeTile(), setRect(), setTileSize(), shrinkCacheSize(), and shrinkGlobalCacheSize().

335 {
336  std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::const_iterator
337  currentIter = theAppCacheMap.find(cacheId);
338  ossimFixedTileCache* result = 0;
339 
340  if(currentIter != theAppCacheMap.end())
341  {
342  result = (*currentIter).second;
343  }
344 
345  return result;
346 }
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap

◆ getTile()

ossimRefPtr< ossimImageData > ossimAppFixedTileCache::getTile ( ossimAppFixedCacheId  cacheId,
const ossimIpt origin 
)

Definition at line 239 of file ossimAppFixedTileCache.cpp.

References getCache(), ossimFixedTileCache::getTile(), and theMutex.

Referenced by ossimCacheTileSource::fillTile(), ossimKakaduJpipHandler::getTileAtRes(), ossimGdalTileSource::getTileBlockRead(), ossimNitfTileSource::loadBlockFromCache(), ossimKakaduJp2Reader::loadTileFromCache(), and ossimKakaduJ2kReader::loadTileFromCache().

242 {
243  std::lock_guard<std::mutex> lock(theMutex);
244  ossimRefPtr<ossimImageData> result = 0;
245  ossimFixedTileCache* cache = getCache(cacheId);
246  if(cache)
247  {
248  result = cache->getTile(origin);
249  }
250 
251  return result;
252 }
virtual ossimRefPtr< ossimImageData > getTile(ossim_int32 id)
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)

◆ getTileSize()

const ossimIpt & ossimAppFixedTileCache::getTileSize ( ossimAppFixedCacheId  cacheId)

Definition at line 420 of file ossimAppFixedTileCache.cpp.

References getCache(), ossimFixedTileCache::getTileSize(), theMutex, and theTileSize.

Referenced by ossimCacheTileSource::fillTile().

421 {
422  std::lock_guard<std::mutex> lock(theMutex);
423  ossimFixedTileCache* cache = getCache(cacheId);
424  if(cache)
425  {
426  return cache->getTileSize();
427  }
428  return theTileSize;
429 }
virtual const ossimIpt & getTileSize() const
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)

◆ instance()

ossimAppFixedTileCache * ossimAppFixedTileCache::instance ( ossim_uint32  maxSize = 0)
static

Definition at line 106 of file ossimAppFixedTileCache.cpp.

References ossimAppFixedTileCache(), setMaxCacheSize(), and theInstance.

Referenced by ossimJpegTileSource::allocate(), ossimPngReader::allocate(), ossimNitfTileSource::allocate(), ossimNitfTileSource::allocateBuffers(), ossimKakaduJp2Reader::closeEntry(), ossimKakaduJ2kReader::closeEntry(), ossimCacheTileSource::deleteRlevelCache(), ossimKakaduJpipHandler::deleteRlevelCache(), ossimGdalTileSource::deleteRlevelCache(), ossimJpegTileSource::destroy(), ossimPngReader::destroy(), ossimNitfTileSource::destroy(), ossimCacheTileSource::fillTile(), ossimCacheTileSource::flush(), ossimKakaduJpipHandler::flushCache(), ossimCacheTileSource::getCacheId(), ossimKakaduJpipHandler::getTileAtRes(), ossimGdalTileSource::getTileBlockRead(), ossimKakaduJpipHandler::initializeRlevelCache(), ossimKakaduNitfReader::loadBlock(), ossimNitfTileSource::loadBlockFromCache(), ossimKakaduJp2Reader::loadTile(), ossimKakaduJ2kReader::loadTile(), ossimKakaduJp2Reader::loadTileFromCache(), ossimKakaduJ2kReader::loadTileFromCache(), ossimKakaduJpipHandler::performRlevelSetup(), ossimNitfTileSource::setCacheEnabledFlag(), and ossimGdalTileSource::setRlevelCache().

107 {
108  if(!theInstance)
109  {
111  if(maxSize)
112  {
113  theInstance->setMaxCacheSize(maxSize);
114  }
115  }
116  return theInstance;
117 }
static ossimAppFixedTileCache * theInstance
virtual void setMaxCacheSize(ossim_uint32 cacheSize)

◆ newTileCache() [1/2]

ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::newTileCache ( const ossimIrect tileBoundaryRect,
const ossimIpt tileSize = ossimIpt(0,0) 
)

Will create a new Tile cache for this application if the tile size is 0,0 it will use the default tile size. Will return 0 if not successful.

Definition at line 169 of file ossimAppFixedTileCache.cpp.

References ossimFixedTileCache::getTileSize(), ossimFixedTileCache::setRect(), theAppCacheMap, theMutex, theUniqueAppIdCounter, ossimIpt::x, and ossimIpt::y.

Referenced by ossimJpegTileSource::allocate(), ossimCacheTileSource::getCacheId(), and ossimGdalTileSource::setRlevelCache().

171 {
172  std::lock_guard<std::mutex> lock(theMutex);
173  ossimAppFixedCacheId result = -1;
175  if(tileSize.x == 0 ||
176  tileSize.y == 0)
177  {
178  // newCache->setRect(tileBoundaryRect, theTileSize);
179  newCache->setRect(tileBoundaryRect,
180  newCache->getTileSize());
181  }
182  else
183  {
184  newCache->setRect(tileBoundaryRect, tileSize);
185  }
186  result = theUniqueAppIdCounter;
187  theAppCacheMap.insert(std::make_pair(result, newCache));
189 
190  return result;
191 }
virtual const ossimIpt & getTileSize() const
virtual void setRect(const ossimIrect &rect)
static ossimAppFixedCacheId theUniqueAppIdCounter
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141

◆ newTileCache() [2/2]

ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::newTileCache ( )

Definition at line 193 of file ossimAppFixedTileCache.cpp.

References theAppCacheMap, theMutex, and theUniqueAppIdCounter.

194 {
195  std::lock_guard<std::mutex> lock(theMutex);
196  ossimAppFixedCacheId result = -1;
198 
199  {
200  result = theUniqueAppIdCounter;
201  theAppCacheMap.insert(std::make_pair(result, newCache));
203  }
204 
205  return result;
206 
207 }
static ossimAppFixedCacheId theUniqueAppIdCounter
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap

◆ removeTile()

ossimRefPtr< ossimImageData > ossimAppFixedTileCache::removeTile ( ossimAppFixedCacheId  cacheId,
const ossimIpt origin 
)

Definition at line 302 of file ossimAppFixedTileCache.cpp.

References getCache(), ossimFixedTileCache::getCacheSize(), ossimFixedTileCache::removeTile(), theCurrentCacheSize, and theMutex.

305 {
306  std::lock_guard<std::mutex> lock(theMutex);
307  ossimRefPtr<ossimImageData> result = 0;
308 
309  ossimFixedTileCache* cache = getCache(cacheId);
310  if(cache)
311  {
312  ossim_uint32 cacheSize = cache->getCacheSize();
313  result = cache->removeTile(origin);
314  theCurrentCacheSize += (cache->getCacheSize() - cacheSize);
315  }
316 
317  return result;
318 }
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
unsigned int ossim_uint32
virtual ossimRefPtr< ossimImageData > removeTile(const ossimIpt &origin)

◆ setMaxCacheSize()

void ossimAppFixedTileCache::setMaxCacheSize ( ossim_uint32  cacheSize)
virtual

Definition at line 119 of file ossimAppFixedTileCache.cpp.

References theMaxCacheSize, theMaxGlobalCacheSize, and theMutex.

Referenced by instance().

120 {
121  std::lock_guard<std::mutex> lock(theMutex);
122  theMaxGlobalCacheSize = cacheSize;
123  theMaxCacheSize = cacheSize;
124  // theMaxCacheSize = (ossim_uint32)(theMaxGlobalCacheSize*.2);
125 }

◆ setRect()

void ossimAppFixedTileCache::setRect ( ossimAppFixedCacheId  cacheId,
const ossimIrect boundaryTileRect 
)
virtual

Definition at line 209 of file ossimAppFixedTileCache.cpp.

References getCache(), ossimFixedTileCache::getCacheSize(), ossimFixedTileCache::getTileSize(), ossimFixedTileCache::setRect(), theCurrentCacheSize, and theMutex.

211 {
212  std::lock_guard<std::mutex> lock(theMutex);
213  ossimFixedTileCache* cache = getCache(cacheId);
214  if(cache)
215  {
216 
217  ossim_uint32 cacheSize = cache->getCacheSize();
218  // cache->setRect(boundaryTileRect, theTileSize);
219  cache->setRect(boundaryTileRect,
220  cache->getTileSize());
221  theCurrentCacheSize += (cache->getCacheSize() - cacheSize);
222  }
223 }
virtual const ossimIpt & getTileSize() const
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
virtual void setRect(const ossimIrect &rect)
unsigned int ossim_uint32

◆ setTileSize()

void ossimAppFixedTileCache::setTileSize ( ossimAppFixedCacheId  cacheId,
const ossimIpt tileSize 
)
virtual

Definition at line 225 of file ossimAppFixedTileCache.cpp.

References getCache(), ossimFixedTileCache::getCacheSize(), ossimFixedTileCache::getTileBoundaryRect(), ossimFixedTileCache::getTileSize(), ossimFixedTileCache::setRect(), theCurrentCacheSize, theMutex, and theTileSize.

227 {
228  std::lock_guard<std::mutex> lock(theMutex);
229  ossimFixedTileCache* cache = getCache(cacheId);
230  if(cache)
231  {
232  ossim_uint32 cacheSize = cache->getCacheSize();
233  cache->setRect(cache->getTileBoundaryRect(), tileSize);
234  theCurrentCacheSize += (cache->getCacheSize() - cacheSize);
235  theTileSize = cache->getTileSize();
236  }
237 }
virtual const ossimIpt & getTileSize() const
virtual const ossimIrect & getTileBoundaryRect() const
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
virtual void setRect(const ossimIrect &rect)
unsigned int ossim_uint32

◆ shrinkCacheSize() [1/2]

void ossimAppFixedTileCache::shrinkCacheSize ( ossimAppFixedCacheId  id,
ossim_int32  byteCount 
)
protected

Definition at line 377 of file ossimAppFixedTileCache.cpp.

References getCache().

Referenced by addTile().

379 {
380  ossimFixedTileCache* cache = getCache(id);
381 
382  if(cache)
383  {
384  shrinkCacheSize(cache, byteCount);
385  }
386 }
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
void shrinkCacheSize(ossimAppFixedCacheId id, ossim_int32 byteCount)

◆ shrinkCacheSize() [2/2]

void ossimAppFixedTileCache::shrinkCacheSize ( ossimFixedTileCache cache,
ossim_int32  byteCount 
)
protected

Definition at line 388 of file ossimAppFixedTileCache.cpp.

References abs, ossimFixedTileCache::deleteTile(), ossimFixedTileCache::flush(), ossimFixedTileCache::getCacheSize(), and theCurrentCacheSize.

390 {
391  if(cache)
392  {
393  ossim_int32 cacheSize = cache->getCacheSize();
394  if(cacheSize <= byteCount)
395  {
396  cache->flush();
397  }
398  else
399  {
400  while(byteCount > 0)
401  {
402  ossim_uint32 before = cache->getCacheSize();
403  cache->deleteTile();
404  ossim_uint32 after = cache->getCacheSize();
405  ossim_uint32 delta = std::abs((int)(before - after));
406  if(delta)
407  {
408  byteCount -= delta;
409  theCurrentCacheSize -= (delta);
410  }
411  else
412  {
413  byteCount = 0;
414  }
415  }
416  }
417  }
418 }
virtual void deleteTile(const ossimIpt &origin)
#define abs(a)
Definition: auxiliary.h:74
virtual ossim_uint32 getCacheSize() const
unsigned int ossim_uint32
int ossim_int32

◆ shrinkGlobalCacheSize()

void ossimAppFixedTileCache::shrinkGlobalCacheSize ( ossim_int32  byteCount)
protected

Definition at line 348 of file ossimAppFixedTileCache.cpp.

References ossimFixedTileCache::deleteTile(), flush(), getCache(), ossimFixedTileCache::getCacheSize(), theAppCacheMap, and theCurrentCacheSize.

Referenced by addTile().

349 {
350  if(static_cast<ossim_uint32>(byteCount) >= theCurrentCacheSize)
351  {
352  flush();
353  }
354  else
355  {
356  while(byteCount > 0)
357  {
358  std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator iter = theAppCacheMap.begin();
359  while( (iter != theAppCacheMap.end())&&(byteCount>0))
360  {
361  ossimFixedTileCache* cache = getCache((*iter).first);
362  if(cache)
363  {
364  ossim_uint32 before = cache->getCacheSize();
365  cache->deleteTile();
366  ossim_uint32 after = cache->getCacheSize();
367  ossim_uint32 delta = (before - after);
368  byteCount -= delta;
369  theCurrentCacheSize -= (delta);
370  }
371  ++iter;
372  }
373  }
374  }
375 }
virtual void deleteTile(const ossimIpt &origin)
ossimFixedTileCache * getCache(ossimAppFixedCacheId cacheId)
virtual ossim_uint32 getCacheSize() const
unsigned int ossim_uint32
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimAppFixedTileCache rhs 
)
friend

Definition at line 26 of file ossimAppFixedTileCache.cpp.

27 {
28  std::map<ossimAppFixedTileCache::ossimAppFixedCacheId, ossimFixedTileCache*>::const_iterator iter = rhs.theAppCacheMap.begin();
29 
30  if(iter == rhs.theAppCacheMap.end())
31  {
33  << "***** APP CACHE EMPTY *****" << endl;
34  }
35  else
36  {
37  while(iter != rhs.theAppCacheMap.end())
38  {
39  out << "Cache id = "<< (*iter).first << " size = " << (*iter).second->getCacheSize() << endl;
40  ++iter;
41  }
42  }
43 
44  return out;
45 }
std::map< ossimAppFixedCacheId, ossimFixedTileCache * > theAppCacheMap
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Data Documentation

◆ DEFAULT_SIZE

const ossim_uint32 ossimAppFixedTileCache::DEFAULT_SIZE = 1024*1024*80
static

Definition at line 31 of file ossimAppFixedTileCache.h.

◆ theAppCacheMap

std::map<ossimAppFixedCacheId, ossimFixedTileCache*> ossimAppFixedTileCache::theAppCacheMap
protected

◆ theCurrentCacheSize

ossim_uint32 ossimAppFixedTileCache::theCurrentCacheSize
protected

◆ theInstance

ossimAppFixedTileCache * ossimAppFixedTileCache::theInstance = 0
staticprotected

Definition at line 101 of file ossimAppFixedTileCache.h.

Referenced by instance().

◆ theMaxCacheSize

ossim_uint32 ossimAppFixedTileCache::theMaxCacheSize
protected

Definition at line 108 of file ossimAppFixedTileCache.h.

Referenced by addTile(), and setMaxCacheSize().

◆ theMaxGlobalCacheSize

ossim_uint32 ossimAppFixedTileCache::theMaxGlobalCacheSize
protected

Definition at line 109 of file ossimAppFixedTileCache.h.

Referenced by addTile(), and setMaxCacheSize().

◆ theMutex

std::mutex ossimAppFixedTileCache::theMutex
protected

◆ theTileSize

ossimIpt ossimAppFixedTileCache::theTileSize
protected

Definition at line 107 of file ossimAppFixedTileCache.h.

Referenced by getTileSize(), and setTileSize().

◆ theUniqueAppIdCounter

ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::theUniqueAppIdCounter = 0
staticprotected

Will hold the current unique Application id.

Definition at line 106 of file ossimAppFixedTileCache.h.

Referenced by newTileCache().


The documentation for this class was generated from the following files: