svcore  1.9
MatrixFile Class Reference

#include <MatrixFile.h>

Inheritance diagram for MatrixFile:
Collaboration diagram for MatrixFile:

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. More...
 
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. More...
 
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
 
ResizeableBitsetm_setColumns
 
bool m_autoClose
 
int m_readyToReadColumn
 

Static Protected Attributes

static std::map< QString, int > m_refcount
 
static QMutex m_createMutex
 

Detailed Description

Definition at line 28 of file MatrixFile.h.

Member Enumeration Documentation

◆ Mode

Enumerator
ReadOnly 
WriteOnly 

Definition at line 33 of file MatrixFile.h.

Constructor & Destructor Documentation

◆ MatrixFile()

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::~MatrixFile ( )
virtual

Member Function Documentation

◆ getMode()

Mode MatrixFile::getMode ( ) const
inline

Definition at line 65 of file MatrixFile.h.

References m_mode.

◆ getWidth()

int MatrixFile::getWidth ( ) const
inline

Definition at line 67 of file MatrixFile.h.

References m_width.

Referenced by FFTFileCacheReader::getWidth(), and FFTFileCacheWriter::getWidth().

◆ getHeight()

◆ getCellSize()

int MatrixFile::getCellSize ( ) const
inline

◆ setAutoClose()

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().

◆ close()

void MatrixFile::close ( )

Definition at line 248 of file MatrixFile.cpp.

References m_fd, openCount, and SVDEBUG.

Referenced by FFTFileCacheWriter::allColumnsWritten(), setColumnAt(), and ~MatrixFile().

◆ haveSetColumnAt()

◆ getColumnAt()

void MatrixFile::getColumnAt ( int  x,
void *  data 
)

◆ setColumnAt()

void MatrixFile::setColumnAt ( int  x,
const void *  data 
)

◆ initialise()

void MatrixFile::initialise ( )
protected

◆ seekTo()

bool MatrixFile::seekTo ( int  col) const
protected

Member Data Documentation

◆ m_fd

int MatrixFile::m_fd
protected

◆ m_mode

Mode MatrixFile::m_mode
protected

◆ m_flags

int MatrixFile::m_flags
protected

Definition at line 86 of file MatrixFile.h.

Referenced by MatrixFile().

◆ m_fmode

mode_t MatrixFile::m_fmode
protected

Definition at line 87 of file MatrixFile.h.

Referenced by MatrixFile().

◆ m_cellSize

int MatrixFile::m_cellSize
protected

Definition at line 88 of file MatrixFile.h.

Referenced by getCellSize(), getColumnAt(), initialise(), seekTo(), setColumnAt(), and ~MatrixFile().

◆ m_width

int MatrixFile::m_width
protected

Definition at line 89 of file MatrixFile.h.

Referenced by getWidth(), initialise(), MatrixFile(), and ~MatrixFile().

◆ m_height

int MatrixFile::m_height
protected

◆ m_headerSize

int MatrixFile::m_headerSize
protected

Definition at line 91 of file MatrixFile.h.

Referenced by initialise(), seekTo(), and ~MatrixFile().

◆ m_fileName

QString MatrixFile::m_fileName
protected

◆ m_setColumns

ResizeableBitset* MatrixFile::m_setColumns
protected

Definition at line 94 of file MatrixFile.h.

Referenced by haveSetColumnAt(), initialise(), setColumnAt(), and ~MatrixFile().

◆ m_autoClose

bool MatrixFile::m_autoClose
protected

Definition at line 95 of file MatrixFile.h.

Referenced by setAutoClose(), and setColumnAt().

◆ m_readyToReadColumn

int MatrixFile::m_readyToReadColumn
mutableprotected

Definition at line 99 of file MatrixFile.h.

Referenced by getColumnAt(), haveSetColumnAt(), and seekTo().

◆ m_refcount

std::map< QString, int > MatrixFile::m_refcount
staticprotected

Definition at line 101 of file MatrixFile.h.

Referenced by MatrixFile(), and ~MatrixFile().

◆ m_createMutex

QMutex MatrixFile::m_createMutex
staticprotected

Definition at line 102 of file MatrixFile.h.

Referenced by MatrixFile(), and ~MatrixFile().


The documentation for this class was generated from the following files: