Lunchbox
1.13.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
|
Helper to map a file to a memory address (mmap). More...
#include <memoryMap.h>
Public Member Functions | |
MemoryMap () | |
Construct a new memory map. More... | |
MemoryMap (const std::string &filename) | |
Construct and initialize a new, readonly memory map. More... | |
MemoryMap (const std::string &filename, const size_t size) | |
Construct and initialize a new, read-write memory map. More... | |
~MemoryMap () | |
Destruct the memory map. More... | |
const void * | map (const std::string &filename) |
Map a file to a memory address. More... | |
const void * | remap (const std::string &filename) |
Remap a different file for this memory map. More... | |
void * | create (const std::string &filename, const size_t size) |
Create a writable file to a memory address. More... | |
void * | recreate (const std::string &filename, const size_t size) |
Recreate a different writable file for this memory map. More... | |
void | unmap () |
Unmap the file. More... | |
const void * | getAddress () const |
void * | getAddress () |
template<class T > | |
const T * | getAddress () const |
template<class T > | |
T * | getAddress () |
size_t | getSize () const |
Helper to map a file to a memory address (mmap).
Example:
Definition at line 36 of file memoryMap.h.
lunchbox::MemoryMap::MemoryMap | ( | ) |
Construct a new memory map.
|
explicit |
Construct and initialize a new, readonly memory map.
lunchbox::MemoryMap::MemoryMap | ( | const std::string & | filename, |
const size_t | size | ||
) |
Construct and initialize a new, read-write memory map.
lunchbox::MemoryMap::~MemoryMap | ( | ) |
void* lunchbox::MemoryMap::create | ( | const std::string & | filename, |
const size_t | size | ||
) |
Create a writable file to a memory address.
The file is mapped read-write. An existing file will be overwritten. The file is automatically unmapped when the memory map is deleted.
filename | The filename of the file to map. |
size | this size of the file. |
const void* lunchbox::MemoryMap::getAddress | ( | ) | const |
Referenced by getAddress().
void* lunchbox::MemoryMap::getAddress | ( | ) |
|
inline |
Definition at line 116 of file memoryMap.h.
References getAddress().
|
inline |
Definition at line 120 of file memoryMap.h.
References getAddress().
size_t lunchbox::MemoryMap::getSize | ( | ) | const |
const void* lunchbox::MemoryMap::map | ( | const std::string & | filename | ) |
Map a file to a memory address.
The file is only mapped read-only. The file is automatically unmapped when the memory map is deleted.
filename | The filename of the file to map. |
void* lunchbox::MemoryMap::recreate | ( | const std::string & | filename, |
const size_t | size | ||
) |
Recreate a different writable file for this memory map.
The file is only mapped read-write. An existing map is unmapped.
filename | The filename of the file to map. |
size | this size of the file. |
const void* lunchbox::MemoryMap::remap | ( | const std::string & | filename | ) |
Remap a different file for this memory map.
The file is only mapped read-only. An existing map is unmapped.
filename | The filename of the file to map. |
void lunchbox::MemoryMap::unmap | ( | ) |
Unmap the file.