VOXELFORMAT: allow to remove entries from VolumeCache

master
Martin Gerhardy 2020-09-12 19:24:36 +02:00
parent c6a38d5167
commit e5ca8e44c0
3 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,8 @@ namespace voxelformat {
/**
* @brief Cache @c voxel::Mesh instances by their name
* @note The cache is @b not threadsafe
* @sa MeshCache
*/
class MeshCache : public core::IComponent {
protected:

View File

@ -55,6 +55,17 @@ voxel::RawVolume* VolumeCache::loadVolume(const char* fullPath) {
return v;
}
bool VolumeCache::removeVolume(const char* fullPath) {
const core::String filename = fullPath;
core::ScopedLock lock(_mutex);
auto i = _volumes.find(filename);
if (i != _volumes.end()) {
_volumes.erase(i);
return true;
}
return false;
}
void VolumeCache::construct() {
command::Command::registerCommand("volumecachelist", [&] (const command::CmdArgs& argv) {
Log::info("Cache content");

View File

@ -13,6 +13,11 @@
namespace voxelformat {
/**
* @brief Caches @c voxel::RawVolume instances by their name
* @note The cache is threadsafe
* @sa MeshCache
*/
class VolumeCache : public core::IComponent {
private:
core::StringMap<voxel::RawVolume*> _volumes;
@ -23,6 +28,7 @@ public:
* The returned volume is not owned by the caller. The cache will delete the memory.
*/
voxel::RawVolume* loadVolume(const char* fullPath);
bool removeVolume(const char* fullPath);
bool init() override;
void shutdown() override;