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