Mercurial > hg > svcore
comparison data/fileio/MatrixFile.cpp @ 1154:aa588c391d1a 3.0-integration
Convert 3d model column type from QVector to std::vector; replace another user of ResizeableBitset
author | Chris Cannam |
---|---|
date | Fri, 22 Jan 2016 13:39:45 +0000 |
parents | ce82bcdc95d0 |
children |
comparison
equal
deleted
inserted
replaced
1153:ece369c5bb68 | 1154:aa588c391d1a |
---|---|
174 openCount --; | 174 openCount --; |
175 } | 175 } |
176 | 176 |
177 QMutexLocker locker(&m_createMutex); | 177 QMutexLocker locker(&m_createMutex); |
178 | 178 |
179 delete m_setColumns; | |
180 | |
181 if (m_fileName != "") { | 179 if (m_fileName != "") { |
182 | 180 |
183 if (--m_refcount[m_fileName] == 0) { | 181 if (--m_refcount[m_fileName] == 0) { |
184 | 182 |
185 if (::unlink(m_fileName.toLocal8Bit())) { | 183 if (::unlink(m_fileName.toLocal8Bit())) { |
206 { | 204 { |
207 Profiler profiler("MatrixFile::initialise", true); | 205 Profiler profiler("MatrixFile::initialise", true); |
208 | 206 |
209 assert(m_mode == WriteOnly); | 207 assert(m_mode == WriteOnly); |
210 | 208 |
211 m_setColumns = new ResizeableBitset(m_width); | 209 m_setColumns.resize(m_width, false); |
212 | 210 |
213 off_t off = m_headerSize + (m_width * m_height * m_cellSize) + m_width; | 211 off_t off = m_headerSize + (m_width * m_height * m_cellSize) + m_width; |
214 | 212 |
215 #ifdef DEBUG_MATRIX_FILE | 213 #ifdef DEBUG_MATRIX_FILE |
216 cerr << "MatrixFile[" << m_fd << "]::initialise(" << m_width << ", " << m_height << "): cell size " << m_cellSize << ", header size " << m_headerSize << ", resizing fd " << m_fd << " to " << off << endl; | 214 cerr << "MatrixFile[" << m_fd << "]::initialise(" << m_width << ", " << m_height << "): cell size " << m_cellSize << ", header size " << m_headerSize << ", resizing fd " << m_fd << " to " << off << endl; |
314 | 312 |
315 bool | 313 bool |
316 MatrixFile::haveSetColumnAt(int x) const | 314 MatrixFile::haveSetColumnAt(int x) const |
317 { | 315 { |
318 if (m_mode == WriteOnly) { | 316 if (m_mode == WriteOnly) { |
319 return m_setColumns->get(x); | 317 return m_setColumns[x]; |
320 } | 318 } |
321 | 319 |
322 if (m_readyToReadColumn >= 0 && | 320 if (m_readyToReadColumn >= 0 && |
323 int(m_readyToReadColumn) == x) return true; | 321 int(m_readyToReadColumn) == x) return true; |
324 | 322 |
396 if (w != 1) { | 394 if (w != 1) { |
397 ::perror("WARNING: MatrixFile::setColumnAt: write failed (3)"); | 395 ::perror("WARNING: MatrixFile::setColumnAt: write failed (3)"); |
398 throw FileOperationFailed(m_fileName, "write"); | 396 throw FileOperationFailed(m_fileName, "write"); |
399 } | 397 } |
400 | 398 |
401 m_setColumns->set(x); | 399 m_setColumns[x] = true; |
402 if (m_autoClose) { | 400 if (m_autoClose) { |
403 if (m_setColumns->isAllOn()) { | 401 if (std::all_of(m_setColumns.begin(), m_setColumns.end(), |
402 [](bool c) { return c; })) { | |
404 #ifdef DEBUG_MATRIX_FILE | 403 #ifdef DEBUG_MATRIX_FILE |
405 cerr << "MatrixFile[" << m_fd << "]::setColumnAt(" << x << "): All columns set: auto-closing" << endl; | 404 cerr << "MatrixFile[" << m_fd << "]::setColumnAt(" << x << "): All columns set: auto-closing" << endl; |
406 #endif | 405 #endif |
407 close(); | 406 close(); |
408 /* | 407 /* |