Provides files accessing from multiple threads. Singleton.
More...
#include <FileManager.h>
|
FileHandle * | createHandle (const std::filesystem::path &filePath, RequestFileHandleType handleType) |
|
void | notify (std::filesystem::path &&filePath) |
|
void | addRequest (const std::filesystem::path &filePath, FileCallback &&callback, std::promise< void > &&requestPromise, RequestFileHandleType handleType) |
|
void | decreaseReadRequests (const std::filesystem::path &filePath) |
|
void | completeWriteRequest (const std::filesystem::path &filePath) |
|
void | addFile (const std::filesystem::path &filePath, bool isFileAlreadyExist=true) |
| Add file to manager.
|
|
std::future< void > | readFile (const std::filesystem::path &filePath, const std::function< void(std::unique_ptr< ReadFileHandle > &&)> &callback, bool isWait=true) |
| Read file in standard mode.
|
|
std::future< void > | readBinaryFile (const std::filesystem::path &filePath, const std::function< void(std::unique_ptr< ReadFileHandle > &&)> &callback, bool isWait=true) |
| Read file in binary mode.
|
|
std::future< void > | writeFile (const std::filesystem::path &filePath, const std::function< void(std::unique_ptr< WriteFileHandle > &&)> &callback, bool isWait=true) |
| Create/Recreate and write file in standard mode.
|
|
std::future< void > | appendFile (const std::filesystem::path &filePath, const std::function< void(std::unique_ptr< WriteFileHandle > &&)> &callback, bool isWait=true) |
| Create file if it does not exist and write file in standard mode.
|
|
std::future< void > | writeBinaryFile (const std::filesystem::path &filePath, const std::function< void(std::unique_ptr< WriteFileHandle > &&)> &callback, bool isWait=true) |
| Create/Recreate and write file in binary mode.
|
|
std::future< void > | appendBinaryFile (const std::filesystem::path &filePath, const std::function< void(std::unique_ptr< WriteFileHandle > &&)> &callback, bool isWait=true) |
| Create file if it does not exist and write file in binary mode.
|
|
Cache & | getCache () |
| Cache getter.
|
|
const Cache & | getCache () const |
| Cache getter.
|
|
|
static FileManager & | getInstance () |
| Singleton getter Also initialize thread pool with max threads for current hardware Default getter after initialization.
|
|
static FileManager & | getInstance (size_t threadsNumber) |
| Singleton getter. Will reinitialize if threadsNumber != current threadsNumber.
|
|
static FileManager & | getInstance (std::shared_ptr< threading::ThreadPool > threadPool) |
| Singleton getter.
|
|
static std::string | getVersion () |
| FileManager version.
|
|
Provides files accessing from multiple threads. Singleton.
Definition at line 24 of file FileManager.h.
◆ addFile()
void file_manager::FileManager::addFile |
( |
const std::filesystem::path & | filePath, |
|
|
bool | isFileAlreadyExist = true ) |
Add file to manager.
- Parameters
-
filePath | Path to file |
isFileAlreadyExist | If true and file does not exist FileDoesNotExistException will be thrown. If true and filePath contains path to non regular file NotAFileException will be thrown |
- Exceptions
-
FileDoesNotExistException | |
NotAFileException |
|
Definition at line 321 of file FileManager.cpp.
◆ addRequest()
void file_manager::FileManager::addRequest |
( |
const std::filesystem::path & | filePath, |
|
|
FileCallback && | callback, |
|
|
std::promise< void > && | requestPromise, |
|
|
RequestFileHandleType | handleType ) |
◆ appendBinaryFile()
future< void > file_manager::FileManager::appendBinaryFile |
( |
const std::filesystem::path & | filePath, |
|
|
const std::function< void(std::unique_ptr< WriteFileHandle > &&)> & | callback, |
|
|
bool | isWait = true ) |
Create file if it does not exist and write file in binary mode.
- Parameters
-
filePath | Path to file |
callback | Function that will be called for writing file |
isWait | If true thread will wait till callback end |
Definition at line 369 of file FileManager.cpp.
◆ appendFile()
future< void > file_manager::FileManager::appendFile |
( |
const std::filesystem::path & | filePath, |
|
|
const std::function< void(std::unique_ptr< WriteFileHandle > &&)> & | callback, |
|
|
bool | isWait = true ) |
Create file if it does not exist and write file in standard mode.
- Parameters
-
filePath | Path to file |
callback | Function that will be called for writing file |
isWait | If true thread will wait till callback end |
Definition at line 359 of file FileManager.cpp.
◆ completeWriteRequest()
void file_manager::FileManager::completeWriteRequest |
( |
const std::filesystem::path & | filePath | ) |
|
◆ createHandle()
FileHandle * file_manager::FileManager::createHandle |
( |
const std::filesystem::path & | filePath, |
|
|
RequestFileHandleType | handleType ) |
◆ decreaseReadRequests()
void file_manager::FileManager::decreaseReadRequests |
( |
const std::filesystem::path & | filePath | ) |
|
◆ getCache() [1/2]
Cache & file_manager::FileManager::getCache |
( |
| ) |
|
◆ getCache() [2/2]
const Cache & file_manager::FileManager::getCache |
( |
| ) |
const |
◆ getInstance() [1/3]
FileManager & file_manager::FileManager::getInstance |
( |
| ) |
|
|
static |
Singleton getter Also initialize thread pool with max threads for current hardware Default getter after initialization.
- Returns
- Singleton instance
Definition at line 267 of file FileManager.cpp.
◆ getInstance() [2/3]
FileManager & file_manager::FileManager::getInstance |
( |
size_t | threadsNumber | ) |
|
|
static |
Singleton getter. Will reinitialize if threadsNumber != current threadsNumber.
- Parameters
-
threadsNumber | ThreadPool threads number |
- Returns
- Singleton instance
Definition at line 280 of file FileManager.cpp.
◆ getInstance() [3/3]
static FileManager & file_manager::FileManager::getInstance |
( |
std::shared_ptr< threading::ThreadPool > | threadPool | ) |
|
|
static |
Singleton getter.
- Parameters
-
threadPool | FileManager will use this thread pool instead of initializing its own thread pool |
- Returns
- Singleton instance
◆ getVersion()
string file_manager::FileManager::getVersion |
( |
| ) |
|
|
static |
◆ notify()
void file_manager::FileManager::notify |
( |
std::filesystem::path && | filePath | ) |
|
◆ readBinaryFile()
future< void > file_manager::FileManager::readBinaryFile |
( |
const std::filesystem::path & | filePath, |
|
|
const std::function< void(std::unique_ptr< ReadFileHandle > &&)> & | callback, |
|
|
bool | isWait = true ) |
Read file in binary mode.
- Parameters
-
filePath | Path to file |
callback | Function that will be called for reading file |
isWait | If true thread will wait till callback end |
- Exceptions
-
FileDoesNotExistException | |
NotAFileException |
|
Definition at line 349 of file FileManager.cpp.
◆ readFile()
future< void > file_manager::FileManager::readFile |
( |
const std::filesystem::path & | filePath, |
|
|
const std::function< void(std::unique_ptr< ReadFileHandle > &&)> & | callback, |
|
|
bool | isWait = true ) |
Read file in standard mode.
- Parameters
-
filePath | Path to file |
callback | Function that will be called for reading file |
isWait | If true thread will wait till callback end |
- Exceptions
-
FileDoesNotExistException | |
NotAFileException |
|
Definition at line 344 of file FileManager.cpp.
◆ writeBinaryFile()
future< void > file_manager::FileManager::writeBinaryFile |
( |
const std::filesystem::path & | filePath, |
|
|
const std::function< void(std::unique_ptr< WriteFileHandle > &&)> & | callback, |
|
|
bool | isWait = true ) |
Create/Recreate and write file in binary mode.
- Parameters
-
filePath | Path to file |
callback | Function that will be called for writing file |
isWait | If true thread will wait till callback end |
Definition at line 364 of file FileManager.cpp.
◆ writeFile()
future< void > file_manager::FileManager::writeFile |
( |
const std::filesystem::path & | filePath, |
|
|
const std::function< void(std::unique_ptr< WriteFileHandle > &&)> & | callback, |
|
|
bool | isWait = true ) |
Create/Recreate and write file in standard mode.
- Parameters
-
filePath | Path to file |
callback | Function that will be called for writing file |
isWait | If true thread will wait till callback end |
Definition at line 354 of file FileManager.cpp.
◆ Cache
◆ FileHandle
◆ operator==
bool operator== |
( |
const RequestStruct & | request, |
|
|
FileManager::RequestType | type ) |
|
friend |
◆ ReadFileHandle
◆ std::default_delete< FileManager >
◆ WriteFileHandle
The documentation for this class was generated from the following files: