|
kwave
18.07.70
|
#include <SwapFile.h>

Public Member Functions | |
| SwapFile (const QString &name) | |
| virtual | ~SwapFile () |
| bool | allocate (size_t size) |
| void * | address () const |
| size_t | size () const |
| int | mapCount () const |
| size_t | pagesize () const |
| bool | resize (size_t size) |
| void * | map () |
| int | unmap () |
| int | read (unsigned int offset, void *buffer, unsigned int length) |
| int | write (unsigned int offset, const void *buffer, unsigned int length) |
Private Member Functions | |
| void | close () |
Private Attributes | |
| QTemporaryFile | m_file |
| void * | m_address |
| size_t | m_size |
| size_t | m_pagesize |
| int | m_map_count |
Definition at line 32 of file SwapFile.h.
|
explicit |
Constructor
| name | full path to the swap file, actually a template that must contain 6 "X" characters at the end! |
Definition at line 37 of file SwapFile.cpp.
References g_instances, m_pagesize, and Kwave::toInt().

|
virtual |
Destructor
Definition at line 58 of file SwapFile.cpp.
References close(), and g_instances.

|
inline |
Returns the address of the allocated memory or 0 if nothing has been allocated.
Definition at line 58 of file SwapFile.h.
References m_address.
Referenced by Kwave::MemoryManager::map(), and Kwave::MemoryManager::readFrom().

| bool Kwave::SwapFile::allocate | ( | size_t | size | ) |
Allocates virtual memory by creating an empty swap file. Must be mapped into memory before used.
| size | number of bytes to allocate |
Definition at line 65 of file SwapFile.cpp.
References close(), DBG, m_address, m_file, m_pagesize, m_size, size(), and Kwave::toUint().
Referenced by Kwave::MemoryManager::allocateVirtual().


|
private |
Frees the allocated memory by unmapping and deleting the swap file.
Definition at line 187 of file SwapFile.cpp.
References DBG, m_address, m_file, m_map_count, and m_size.
Referenced by allocate(), pagesize(), resize(), and ~SwapFile().

| void * Kwave::SwapFile::map | ( | ) |
Map the memory and return the physical address.
Definition at line 206 of file SwapFile.cpp.
References DBG, m_address, m_file, m_map_count, and m_size.
Referenced by Kwave::MemoryManager::map(), and pagesize().

|
inline |
returns the map count
Definition at line 67 of file SwapFile.h.
References m_map_count.
Referenced by Kwave::MemoryManager::free(), Kwave::MemoryManager::map(), Kwave::MemoryManager::readFrom(), Kwave::MemoryManager::unmap(), and Kwave::MemoryManager::unmapFromCache().

|
inline |
Returns the size of one storage unit in bytes
Definition at line 72 of file SwapFile.h.
References close(), m_pagesize, map(), read(), resize(), unmap(), and write().

| int Kwave::SwapFile::read | ( | unsigned int | offset, |
| void * | buffer, | ||
| unsigned int | length | ||
| ) |
Read bytes into a buffer
| offset | offset within the file [bytes] |
| buffer | pointer to a buffer that is to be filled |
| length | number of bytes to read |
Definition at line 258 of file SwapFile.cpp.
References m_file, and Kwave::toInt().
Referenced by Kwave::MemoryManager::convertToPhysical(), pagesize(), and Kwave::MemoryManager::readFrom().


| bool Kwave::SwapFile::resize | ( | size_t | size | ) |
Resizes the allocated swap file.
| size | the new size |
Definition at line 122 of file SwapFile.cpp.
References BLOCK_SIZE, close(), m_address, m_file, m_map_count, m_pagesize, m_size, MINIMUM_SIZE, and size().
Referenced by pagesize(), and Kwave::MemoryManager::resize().


|
inline |
Returns the size of the allocated memory or 0 if nothing has been allocated.
Definition at line 64 of file SwapFile.h.
References m_size.
Referenced by allocate(), Kwave::MemoryManager::convertToPhysical(), Kwave::MemoryManager::free(), Kwave::MemoryManager::map(), Kwave::MemoryManager::resize(), resize(), Kwave::MemoryManager::sizeOf(), Kwave::MemoryManager::tryToMakePhysical(), Kwave::MemoryManager::unmap(), Kwave::MemoryManager::unmapFromCache(), and Kwave::MemoryManager::virtualUsed().

| int Kwave::SwapFile::unmap | ( | ) |
Unmap a memory area, previously mapped with map()
Definition at line 235 of file SwapFile.cpp.
References DBG, m_address, m_file, m_map_count, and m_size.
Referenced by pagesize(), Kwave::MemoryManager::unmap(), and Kwave::MemoryManager::unmapFromCache().

| int Kwave::SwapFile::write | ( | unsigned int | offset, |
| const void * | buffer, | ||
| unsigned int | length | ||
| ) |
Write bytes from a buffer
| offset | offset within the file [bytes] |
| buffer | pointer to a buffer with data |
| length | number of bytes to write |
Definition at line 274 of file SwapFile.cpp.
References m_file, and Kwave::toInt().
Referenced by Kwave::MemoryManager::convertToVirtual(), pagesize(), and Kwave::MemoryManager::writeTo().


|
private |
address of the allocated virtual memory or 0
Definition at line 129 of file SwapFile.h.
Referenced by address(), allocate(), close(), map(), resize(), and unmap().
|
private |
file used for swapping
Definition at line 126 of file SwapFile.h.
Referenced by allocate(), close(), map(), read(), resize(), unmap(), and write().
|
private |
reference count for mmap [0...N]
Definition at line 138 of file SwapFile.h.
Referenced by close(), map(), mapCount(), resize(), and unmap().
|
private |
size of one storage unit
Definition at line 135 of file SwapFile.h.
Referenced by allocate(), pagesize(), resize(), and SwapFile().
|
private |
number of allocated bytes or 0
Definition at line 132 of file SwapFile.h.
Referenced by allocate(), close(), map(), resize(), size(), and unmap().