11 #ifndef __GU_AgentFileCache__
12 #define __GU_AgentFileCache__
41 CachedFile(
T *
ptr =
nullptr, time_t mod_time = 0)
42 : myPtr(
ptr), myModTime(mod_time)
50 using CachedFileMap = UT_ConcurrentHashMap<UT_StringHolder, CachedFile>;
51 CachedFileMap myFiles;
74 typename CachedFileMap::const_accessor acc;
76 acc->second.myModTime == mod_time)
78 return acc->second.myPtr;
82 typename CachedFileMap::accessor acc;
83 if (myFiles.insert(acc, key) || acc->second.myModTime != mod_time)
86 auto new_item = load_new_item();
88 acc->second = CachedFile(new_item.get(), mod_time);
94 (
void) myFiles.erase(acc);
100 return acc->second.myPtr;
103 template <
typename T>
GT_API const UT_StringHolder filename
bool hasAccess(int mode=0) const
GU_API void GUgetAgentFilePaths(UT_StringArray &paths, const UT_StringHolder &condensed_path, const UT_StringHolder &expanded_path)
SYS_FORCE_INLINE const UT_StringHolder & UTmakeUnsafeRef(const UT_StringRef &ref)
Convert a UT_StringRef into a UT_StringHolder that is a shallow reference.
void removeCachedFile(const UT_StringRef &key)
Removes a cached file with the given key.
Wrapper around hboost::intrusive_ptr.
UT_IntrusivePtr< T > findCachedFileOrLoad(const UT_StringRef &filename, const UT_StringRef &key, F load_new_item)
time_t getModTime() const
Class for retrieving file information.
GLenum const void * paths