19#ifndef POOLTESTS_FILEMANAGER_H
20#define POOLTESTS_FILEMANAGER_H
22#include <boost/filesystem/path.hpp>
39template <
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
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)
std::pair< FileId, TFD > open(const boost::filesystem::path &path, bool write, std::function< bool(FileId)> request_close)
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.
static TFD open(const boost::filesystem::path &path, bool write)