28 const std::string& prefix,
29 const std::filesystem::path directory =
"",
30 bool delete_cache =
true);
46 const std::string& filename,
47 const std::string& extension,
48 size_t max_tries = 10000);
57 const std::filesystem::path&
get_file_path(
const std::string& filename);
66 std::filesystem::path
get_file_path(
const std::string& filename)
const;
82 std::shared_ptr<Mesh>
read_mesh(
const std::string& name)
const;
96 const std::string& name,
97 const std::map<std::string, std::vector<int64_t>>& multimesh_names = {});
108 bool export_cache(
const std::filesystem::path& export_location);
118 bool import_cache(
const std::filesystem::path& import_location);
142 const std::string& prefix,
143 const std::filesystem::path& location =
"",
144 size_t max_tries = 10000);
void flush_multimeshes()
Unsets the mesh held by each cached mm - useful for debugging whether cache loading works.
std::vector< std::string > mesh_names()
Get all names of the meshes stored in cache.
const std::filesystem::path & get_file_path(const std::string &filename)
Get the path where the file with the given name is stored.
void write_mesh(const Mesh &m, const std::string &name, const std::map< std::string, std::vector< int64_t >> &multimesh_names={})
Write a mesh to cache.
std::filesystem::path get_cache_path() const
Get the path of the cache folder.
const std::filesystem::path & create_unique_file(const std::string &filename, const std::string &extension, size_t max_tries=10000)
Create a file with the given name in the cache without overwriting any file with the same name.
bool equals(const Cache &o)
Compare two caches for equality.
std::map< std::string, std::filesystem::path > m_file_paths
std::map< std::string, CachedMultiMesh > m_multimeshes
static std::filesystem::path create_unique_directory(const std::string &prefix, const std::filesystem::path &location="", size_t max_tries=10000)
Create a unique directory in the given location.
Cache & operator=(Cache &&)
void load_multimesh(const std::string &name) const
bool import_cache(const std::filesystem::path &import_location)
Import a cache from the given location.
static const std::string m_cache_content_name
Cache(const std::string &prefix, const std::filesystem::path directory="", bool delete_cache=true)
This class creates and maintains a cache folder for storing temporary data.
std::vector< int64_t > absolute_multi_mesh_id(const std::string &name) const
bool export_cache(const std::filesystem::path &export_location)
Export the cache to the given location.
std::shared_ptr< Mesh > read_mesh(const std::string &name) const
Load a mesh from cache.
std::filesystem::path m_cache_dir