]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/tgdb/TileCache.cxx
Remove using std:: from the metar header, remove HTTP support, add very basic unit...
[simgear.git] / simgear / scene / tgdb / TileCache.cxx
index 3032dea18bdb69b3f5b340059c40c7e203b2917d..04ef996f282a3b026ebb0115eea9d68cf9e0449c 100644 (file)
@@ -47,12 +47,11 @@ TileCache::~TileCache( void ) {
 
 
 // Free a tile cache entry
-void TileCache::entry_free( long cache_index ) {
-    SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << cache_index );
-    TileEntry *tile = tile_cache[cache_index];
+void TileCache::entry_free( long tile_index ) {
+    SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << tile_index );
+    TileEntry *tile = tile_cache[tile_index];
     tile->removeFromSceneGraph();
-    tile_cache.erase( cache_index );
-
+    tile_cache.erase( tile_index );
     delete tile;
 }
 
@@ -144,8 +143,8 @@ void TileCache::clear_current_view()
 
 // Clear a cache entry, note that the cache only holds pointers
 // and this does not free the object which is pointed to.
-void TileCache::clear_entry( long cache_index ) {
-    tile_cache.erase( cache_index );
+void TileCache::clear_entry( long tile_index ) {
+    tile_cache.erase( tile_index );
 }
 
 
@@ -182,13 +181,28 @@ bool TileCache::insert_tile( TileEntry *e ) {
     return true;
 }
 
+/**
+ * Reloads a tile when it's already in memory.
+ */
+void TileCache::refresh_tile(long tile_index)
+{
+    const_tile_map_iterator it = tile_cache.find( tile_index );
+    if ( it == tile_cache.end() )
+        return;
+
+    SG_LOG( SG_TERRAIN, SG_DEBUG, "REFRESHING CACHE ENTRY = " << tile_index );
+
+    if (it->second)
+        it->second->refresh();
+}
+
 // update tile's priority and expiry time according to current request
 void TileCache::request_tile(TileEntry* t,float priority,bool current_view,double request_time)
 {
     if ((!current_view)&&(request_time<=0.0))
         return;
 
-    // update priority when hire - or old has expired
+    // update priority when higher - or old request has expired
     if ((t->is_expired(current_time))||
          (priority > t->get_priority()))
     {