19 #ifndef POOLTESTS_FILEMANAGER_H
20 #define POOLTESTS_FILEMANAGER_H
22 #include <boost/filesystem/path.hpp>
38 template <
typename TFD>
40 static TFD
open(
const boost::filesystem::path&
path,
bool write) {
43 "Specialization of OpenCloseTrait or a constructible(path,bool) and movable");
44 return TFD(
path, write);
49 "Specialization of OpenCloseTrait or a constructible(path,bool) and movable");
120 template <
typename TFD>
129 template <
typename TFD>
185 #define FILEMANAGER_IMPL
187 #undef FILEMANAGER_IMPL
virtual ~FileManager()
Destructor.
intptr_t FileId
Opaque FileId, its concrete type should only be assumed to be copyable and hashable.
std::map< boost::filesystem::path, std::weak_ptr< FileHandler > > m_handlers
static std::shared_ptr< FileManager > getDefault()
virtual void notifyOpenedFile(FileId)=0
virtual void notifyUsed(FileId id)
Clock::time_point Timestamp
std::map< FileId, std::unique_ptr< FileMetadata > > m_files
void close(FileId id, TFD &fd)
std::shared_ptr< FileHandler > getFileHandler(const boost::filesystem::path &path)
virtual void notifyIntentToOpen(bool write)=0
bool hasHandler(const boost::filesystem::path &path) const
virtual void notifyClosedFile(FileId)=0
FileManager()
Constructor.
std::pair< FileId, TFD > open(const boost::filesystem::path &path, bool write, std::function< bool(FileId)> request_close)
Elements::Path::Item path
static TFD open(const boost::filesystem::path &path, bool write)