X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FScenery%2Fnewcache.hxx;h=4a10884bd04cd800fcd7e0b6ab10582f21a2d6d7;hb=140f58b4cae71671cd6f3c945f9102cd5011d966;hp=ed7486f572c19803e86ff78b760c105671ee796b;hpb=191bb3956a2b82b856f7981bc886d33d89fcd7d1;p=flightgear.git diff --git a/src/Scenery/newcache.hxx b/src/Scenery/newcache.hxx index ed7486f57..4a10884bd 100644 --- a/src/Scenery/newcache.hxx +++ b/src/Scenery/newcache.hxx @@ -49,15 +49,13 @@ SG_USING_STD(map); - -typedef map < long, FGTileEntry * > tile_map; -typedef tile_map::iterator tile_map_iterator; -typedef tile_map::const_iterator const_tile_map_iterator; - - // A class to store and manage a pile of tiles class FGNewCache { + typedef map < long, FGTileEntry * > tile_map; + typedef tile_map::iterator tile_map_iterator; + typedef tile_map::const_iterator const_tile_map_iterator; + // cache storage space tile_map tile_cache; @@ -82,18 +80,22 @@ public: void init( void ); // Check if the specified "bucket" exists in the cache - bool exists( const SGBucket& b ); + bool exists( const SGBucket& b ) const; // Ensure at least one entry is free in the cache - void make_space(); + bool make_space(); + + // Clear all completely loaded tiles (ignores partially loaded tiles) + void clear_cache(); // Fill in a tile cache entry with real data for the specified bucket - void fill_in( const SGBucket& b ); + // void fill_in( const SGBucket& b ); // Return a pointer to the specified tile cache entry inline FGTileEntry *get_tile( const long tile_index ) { tile_map_iterator it = tile_cache.find( tile_index ); if ( it != tile_cache.end() ) { + it->second->set_timestamp(globals->get_sim_time_sec()); return it->second; } else { return NULL; @@ -119,11 +121,14 @@ public: inline int get_max_cache_size() const { return max_cache_size; } inline void set_max_cache_size( int m ) { max_cache_size = m; } -}; - -// the tile cache -extern FGNewCache global_tile_cache; + /** + * Create a new tile and enqueue it for loading. + * @param b + * @return success/failure + */ + bool insert_tile( FGTileEntry* e ); +}; #endif // _NEWCACHE_HXX