Wrapper for the linux mmap.
More...
#include <FileMapper.h>
|
| FileMapper () |
| Default constructor.
|
|
| FileMapper (const std::string &filepath, size_t ofs=0, size_t sz=0) |
| Initializing constructor.
|
|
void | initialize () override |
| Use temporary files to map.
|
|
| ~FileMapper () override |
| Destructor.
|
|
void | initialize (const std::string &filepath, size_t ofs=0, size_t sz=0) |
| Initializes the mapper passing a file instance.
|
|
void | createView (size_t size) override |
| Sets the size of the file to be mapped.
|
|
void | setView (size_t ofs, size_t sz) |
| Sets the part of the file to be mapped.
|
|
void | reset () |
| Unlocks the locked file and removes the file reference.
|
|
void * | getPtr () override |
| Gets the pointer of the mapped area.
|
|
template<typename T > |
T * | lock (bool readonly=false) |
| Locks the set area.
|
|
void | unlock (bool sync=false) |
|
bool | mapView () override |
| Locks a pointer in memory which can be unlocked using unmapView().
|
|
bool | unmapView () override |
| Unlocks the pointer locked with mapView().
|
|
const File & | getFile () |
|
bool | isLocked () const |
|
void | sync (bool async) |
|
size_t | getSize () const |
|
| IFileMapper ()=default |
| Default constructor.
|
|
virtual | ~IFileMapper ()=default |
| Virtual destructor.
|
|
|
static IFileMapper * | instantiate (bool native) |
| Gets an instance of this interface using a native or non-native (Qt) implementation.
|
|
Wrapper for the linux mmap.
◆ FileMapper() [1/2]
sf::lnx::FileMapper::FileMapper |
( |
| ) |
|
◆ FileMapper() [2/2]
sf::lnx::FileMapper::FileMapper |
( |
const std::string & |
filepath, |
|
|
size_t |
ofs = 0 , |
|
|
size_t |
sz = 0 |
|
) |
| |
|
explicit |
Initializing constructor.
◆ ~FileMapper()
sf::lnx::FileMapper::~FileMapper |
( |
| ) |
|
|
override |
◆ createView()
void sf::lnx::FileMapper::createView |
( |
size_t |
size | ) |
|
|
overridevirtual |
◆ getFile()
const File & sf::lnx::FileMapper::getFile |
( |
| ) |
|
|
inline |
Returns the underlying file.
- Returns
- File instance reference.
◆ getPtr()
void * sf::lnx::FileMapper::getPtr |
( |
| ) |
|
|
overridevirtual |
◆ getSize()
size_t sf::lnx::FileMapper::getSize |
( |
| ) |
const |
◆ initialize() [1/2]
void sf::lnx::FileMapper::initialize |
( |
| ) |
|
|
overridevirtual |
◆ initialize() [2/2]
void sf::lnx::FileMapper::initialize |
( |
const std::string & |
filepath, |
|
|
size_t |
ofs = 0 , |
|
|
size_t |
sz = 0 |
|
) |
| |
Initializes the mapper passing a file instance.
◆ isLocked()
bool sf::lnx::FileMapper::isLocked |
( |
| ) |
const |
Returns true when locked.
◆ lock()
template<typename T >
T * sf::lnx::FileMapper::lock |
( |
bool |
readonly = false | ) |
|
|
inline |
Locks the set area.
- Template Parameters
-
- Parameters
-
readonly | Flag making the resulting pointer readonly. |
- Returns
- NULL on failure otherwise pointer of specified type.
◆ mapView()
bool sf::lnx::FileMapper::mapView |
( |
| ) |
|
|
overridevirtual |
◆ reset()
void sf::lnx::FileMapper::reset |
( |
| ) |
|
Unlocks the locked file and removes the file reference.
◆ setView()
void sf::lnx::FileMapper::setView |
( |
size_t |
ofs, |
|
|
size_t |
sz |
|
) |
| |
Sets the part of the file to be mapped.
◆ sync()
void sf::lnx::FileMapper::sync |
( |
bool |
async | ) |
|
Returns true on success to invalidated data so it is written to disk. When async is false the function returns after the data is written to disk. When true the function returns immediately.
◆ unlock()
void sf::lnx::FileMapper::unlock |
( |
bool |
sync = false | ) |
|
Unlocks the set area and syncs the data when sync is set.
◆ unmapView()
bool sf::lnx::FileMapper::unmapView |
( |
| ) |
|
|
overridevirtual |
The documentation for this class was generated from the following file: