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) {
42 "Specialization of OpenCloseTrait or a constructible(path,bool) and movable");
43 return TFD(path, write);
47 "Specialization of OpenCloseTrait or a constructible(path,bool) and movable");
118 template <
typename TFD>
126 template <
typename TFD>
146 bool hasHandler(
const boost::filesystem::path& path)
const;
182 #define FILEMANAGER_IMPL
184 #undef FILEMANAGER_IMPL
186 #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.
FileMetadata * 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
Elements::Path::Item path
virtual void notifyIntentToOpen(bool write)=0