svcore
1.9
|
#include <MatrixFile.h>
Public Types | |
enum | Mode { ReadOnly, WriteOnly } |
Public Member Functions | |
MatrixFile (QString fileBase, Mode mode, int cellSize, int width, int height) | |
Construct a MatrixFile object reading from and/or writing to the matrix file with the given base name in the application's temporary directory. | |
virtual | ~MatrixFile () |
Mode | getMode () const |
int | getWidth () const |
int | getHeight () const |
int | getCellSize () const |
void | setAutoClose (bool a) |
If this is set true on a write-mode MatrixFile, then the file will close() itself when all columns have been written. | |
void | close () |
bool | haveSetColumnAt (int x) const |
void | getColumnAt (int x, void *data) |
void | setColumnAt (int x, const void *data) |
Protected Member Functions | |
void | initialise () |
bool | seekTo (int col) const |
Protected Attributes | |
int | m_fd |
Mode | m_mode |
int | m_flags |
mode_t | m_fmode |
int | m_cellSize |
int | m_width |
int | m_height |
int | m_headerSize |
QString | m_fileName |
ResizeableBitset * | m_setColumns |
bool | m_autoClose |
int | m_readyToReadColumn |
Static Protected Attributes | |
static std::map< QString, int > | m_refcount |
static QMutex | m_createMutex |
Definition at line 28 of file MatrixFile.h.
enum MatrixFile::Mode |
Definition at line 33 of file MatrixFile.h.
MatrixFile::MatrixFile | ( | QString | fileBase, |
Mode | mode, | ||
int | cellSize, | ||
int | width, | ||
int | height | ||
) |
Construct a MatrixFile object reading from and/or writing to the matrix file with the given base name in the application's temporary directory.
If mode is ReadOnly, the file must exist and be readable.
If mode is WriteOnly, the file must not exist.
cellSize specifies the size in bytes of the object type stored in the matrix. For example, use cellSize = sizeof(float) for a matrix of floats. The MatrixFile object doesn't care about the objects themselves, it just deals with raw data of a given size.
width and height specify the dimensions of the file. These cannot be changed after construction.
MatrixFiles are reference counted by name. When the last MatrixFile with a given name is destroyed, the file is removed. These are temporary files; the normal usage is to have one MatrixFile of WriteOnly type creating the file and then persisting until all readers are complete.
MatrixFile has no built-in cache and is not thread-safe. Use a separate MatrixFile in each thread.
Definition at line 54 of file MatrixFile.cpp.
References TempDirectory::getInstance(), initialise(), m_createMutex, m_fd, m_fileName, m_flags, m_fmode, m_height, m_mode, m_refcount, m_width, openCount, ReadOnly, SVDEBUG, totalCount, and WriteOnly.
MatrixFile::~MatrixFile | ( | ) | [virtual] |
Definition at line 158 of file MatrixFile.cpp.
References close(), m_cellSize, m_createMutex, m_fd, m_fileName, m_headerSize, m_height, m_mode, m_refcount, m_setColumns, m_width, openCount, totalCount, totalStorage, and WriteOnly.
Mode MatrixFile::getMode | ( | ) | const [inline] |
Definition at line 65 of file MatrixFile.h.
References m_mode.
int MatrixFile::getWidth | ( | ) | const [inline] |
Definition at line 67 of file MatrixFile.h.
References m_width.
Referenced by FFTFileCacheReader::getWidth(), and FFTFileCacheWriter::getWidth().
int MatrixFile::getHeight | ( | ) | const [inline] |
Definition at line 68 of file MatrixFile.h.
References m_height.
Referenced by FFTFileCacheReader::getFromReadBufCompactSigned(), FFTFileCacheReader::getFromReadBufCompactUnsigned(), FFTFileCacheReader::getFromReadBufStandard(), FFTFileCacheWriter::getHeight(), FFTFileCacheReader::getHeight(), FFTFileCacheReader::getNormalizationFactor(), FFTFileCacheReader::populateReadBuf(), and FFTFileCacheWriter::setNormalizationFactorToWritebuf().
int MatrixFile::getCellSize | ( | ) | const [inline] |
Definition at line 69 of file MatrixFile.h.
References m_cellSize.
Referenced by FFTFileCacheWriter::FFTFileCacheWriter(), and FFTFileCacheReader::populateReadBuf().
void MatrixFile::setAutoClose | ( | bool | a | ) | [inline] |
If this is set true on a write-mode MatrixFile, then the file will close() itself when all columns have been written.
Definition at line 75 of file MatrixFile.h.
References m_autoClose.
Referenced by FFTFileCacheWriter::FFTFileCacheWriter().
void MatrixFile::close | ( | ) |
Definition at line 248 of file MatrixFile.cpp.
References m_fd, openCount, and SVDEBUG.
Referenced by FFTFileCacheWriter::allColumnsWritten(), setColumnAt(), and ~MatrixFile().
bool MatrixFile::haveSetColumnAt | ( | int | x | ) | const |
Definition at line 306 of file MatrixFile.cpp.
References ResizeableBitset::get(), m_fd, m_fileName, m_mode, m_readyToReadColumn, m_setColumns, seekTo(), and WriteOnly.
Referenced by FFTFileCacheWriter::haveSetColumnAt(), FFTFileCacheReader::haveSetColumnAt(), and FFTFileCacheReader::populateReadBuf().
void MatrixFile::getColumnAt | ( | int | x, |
void * | data | ||
) |
Definition at line 266 of file MatrixFile.cpp.
References m_cellSize, m_fd, m_fileName, m_height, m_mode, m_readyToReadColumn, ReadOnly, and seekTo().
Referenced by FFTFileCacheReader::populateReadBuf().
void MatrixFile::setColumnAt | ( | int | x, |
const void * | data | ||
) |
Definition at line 341 of file MatrixFile.cpp.
References close(), ResizeableBitset::isAllOn(), m_autoClose, m_cellSize, m_fd, m_fileName, m_height, m_mode, m_setColumns, seekTo(), ResizeableBitset::set(), and WriteOnly.
Referenced by FFTFileCacheWriter::setColumnAt().
void MatrixFile::initialise | ( | ) | [protected] |
Definition at line 195 of file MatrixFile.cpp.
References m_cellSize, m_fd, m_fileName, m_headerSize, m_height, m_mode, m_setColumns, m_width, seekTo(), totalStorage, and WriteOnly.
Referenced by MatrixFile().
bool MatrixFile::seekTo | ( | int | col | ) | const [protected] |
Definition at line 411 of file MatrixFile.cpp.
References m_cellSize, m_fd, m_headerSize, m_height, m_mode, m_readyToReadColumn, and ReadOnly.
Referenced by getColumnAt(), haveSetColumnAt(), initialise(), and setColumnAt().
int MatrixFile::m_fd [protected] |
Definition at line 84 of file MatrixFile.h.
Referenced by close(), getColumnAt(), haveSetColumnAt(), initialise(), MatrixFile(), seekTo(), setColumnAt(), and ~MatrixFile().
Mode MatrixFile::m_mode [protected] |
Definition at line 85 of file MatrixFile.h.
Referenced by getColumnAt(), getMode(), haveSetColumnAt(), initialise(), MatrixFile(), seekTo(), setColumnAt(), and ~MatrixFile().
int MatrixFile::m_flags [protected] |
Definition at line 86 of file MatrixFile.h.
Referenced by MatrixFile().
mode_t MatrixFile::m_fmode [protected] |
Definition at line 87 of file MatrixFile.h.
Referenced by MatrixFile().
int MatrixFile::m_cellSize [protected] |
Definition at line 88 of file MatrixFile.h.
Referenced by getCellSize(), getColumnAt(), initialise(), seekTo(), setColumnAt(), and ~MatrixFile().
int MatrixFile::m_width [protected] |
Definition at line 89 of file MatrixFile.h.
Referenced by getWidth(), initialise(), MatrixFile(), and ~MatrixFile().
int MatrixFile::m_height [protected] |
Definition at line 90 of file MatrixFile.h.
Referenced by getColumnAt(), getHeight(), initialise(), MatrixFile(), seekTo(), setColumnAt(), and ~MatrixFile().
int MatrixFile::m_headerSize [protected] |
Definition at line 91 of file MatrixFile.h.
Referenced by initialise(), seekTo(), and ~MatrixFile().
QString MatrixFile::m_fileName [protected] |
Definition at line 92 of file MatrixFile.h.
Referenced by getColumnAt(), haveSetColumnAt(), initialise(), MatrixFile(), setColumnAt(), and ~MatrixFile().
ResizeableBitset* MatrixFile::m_setColumns [protected] |
Definition at line 94 of file MatrixFile.h.
Referenced by haveSetColumnAt(), initialise(), setColumnAt(), and ~MatrixFile().
bool MatrixFile::m_autoClose [protected] |
Definition at line 95 of file MatrixFile.h.
Referenced by setAutoClose(), and setColumnAt().
int MatrixFile::m_readyToReadColumn [mutable, protected] |
Definition at line 99 of file MatrixFile.h.
Referenced by getColumnAt(), haveSetColumnAt(), and seekTo().
std::map< QString, int > MatrixFile::m_refcount [static, protected] |
Definition at line 101 of file MatrixFile.h.
Referenced by MatrixFile(), and ~MatrixFile().
QMutex MatrixFile::m_createMutex [static, protected] |
Definition at line 102 of file MatrixFile.h.
Referenced by MatrixFile(), and ~MatrixFile().