Chris@87: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@87: Chris@87: /* Chris@87: Sonic Visualiser Chris@87: An audio file viewer and annotation editor. Chris@87: Centre for Digital Music, Queen Mary, University of London. Chris@87: This file copyright 2006 Chris Cannam. Chris@87: Chris@87: This program is free software; you can redistribute it and/or Chris@87: modify it under the terms of the GNU General Public License as Chris@87: published by the Free Software Foundation; either version 2 of the Chris@87: License, or (at your option) any later version. See the file Chris@87: COPYING included with this distribution for more information. Chris@87: */ Chris@87: Chris@87: #ifndef _MATRIX_FILE_CACHE_H_ Chris@87: #define _MATRIX_FILE_CACHE_H_ Chris@87: Chris@87: #include Chris@87: #include Chris@87: Chris@87: // This class is _not_ thread safe. Each instance must only be used Chris@87: // within a single thread. You may however have as many instances as Chris@87: // you like referring to the same file in separate threads. Chris@87: Chris@87: class MatrixFileCache Chris@87: { Chris@87: public: Chris@87: enum Mode { ReadOnly, ReadWrite }; Chris@87: Chris@87: MatrixFileCache(QString fileBase, Mode mode); Chris@87: virtual ~MatrixFileCache(); Chris@87: Chris@87: size_t getWidth() const; Chris@87: size_t getHeight() const; Chris@87: Chris@87: void resize(size_t width, size_t height); Chris@87: void reset(); Chris@87: Chris@87: void setRangeOfInterest(size_t x, size_t width); Chris@87: Chris@87: float getValueAt(size_t x, size_t y) const; Chris@87: void getColumnAt(size_t x, float *values) const; Chris@87: // float getColumnMaximum(size_t x) const; Chris@87: // float getColumnMinimum(size_t x) const; Chris@87: Chris@87: void setValueAt(size_t x, size_t y, float value); Chris@87: void setColumnAt(size_t x, float *values); Chris@87: Chris@87: protected: Chris@87: int m_fd; Chris@87: Mode m_mode; Chris@87: size_t m_width; Chris@87: size_t m_height; Chris@87: size_t m_rx; Chris@87: size_t m_rw; Chris@87: float **m_range; Chris@87: size_t m_headerSize; Chris@87: Chris@87: mutable off_t m_off; Chris@87: Chris@87: bool seekTo(size_t x, size_t y) const; Chris@87: }; Chris@87: Chris@87: #endif Chris@87: