Isis 3 Programmer Reference
BoxcarCachingAlgorithm.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "BoxcarCachingAlgorithm.h"
9 
10 #include <algorithm>
11 #include <iostream>
12 
13 #include <QList>
14 #include <QQueue>
15 
16 #include "IException.h"
17 #include "IString.h"
18 #include "RawCubeChunk.h"
19 
20 namespace Isis {
28  m_minLine = 1;
29  }
30 
31 
36  }
37 
38 
51  const Buffer &justRequested) {
52  (void) justRequested; // unused, for fullfilling virtual function signiture
53  QList<RawCubeChunk *> chunksToToss;
54 
55  if (justUsed.size() > 0) {
56  // TODO bands
57  int minLine = justUsed[0]->getStartLine();
58 
59  QListIterator<RawCubeChunk *> justUsedIterator(justUsed);
60  while (justUsedIterator.hasNext()) {
61  RawCubeChunk *chunk = justUsedIterator.next();
62  int currentStart = chunk->getStartLine();
63  if (currentStart < minLine) minLine = currentStart;
64  }
65 
66  if (minLine > m_minLine) {
67  m_minLine = minLine;
68  QListIterator<RawCubeChunk *> allocatedIterator(allocated);
69  while (allocatedIterator.hasNext()) {
70  RawCubeChunk *chunk = allocatedIterator.next();
71  int currentEnd = chunk->getStartLine() + chunk->lineCount() - 1;
72 
73  if (currentEnd < minLine) {
74  chunksToToss.append(chunk);
75  }
76  }
77  }
78  }
79 
80  return CacheResult(chunksToToss);
81  }
82 }
Isis::RawCubeChunk
A section of raw data on the disk.
Definition: RawCubeChunk.h:27
Isis::RawCubeChunk::getStartLine
int getStartLine() const
Definition: RawCubeChunk.h:60
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::BoxcarCachingAlgorithm::~BoxcarCachingAlgorithm
virtual ~BoxcarCachingAlgorithm()
Frees the memory allocated by this caching algorithm.
Definition: BoxcarCachingAlgorithm.cpp:35
Isis::CubeCachingAlgorithm::CacheResult
This stores the results of the caching algorithm.
Definition: CubeCachingAlgorithm.h:45
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::RawCubeChunk::lineCount
int lineCount() const
Definition: RawCubeChunk.h:81
Isis::BoxcarCachingAlgorithm::m_minLine
int m_minLine
Used to calculate what lines to cache.
Definition: BoxcarCachingAlgorithm.h:42
Isis::BoxcarCachingAlgorithm::recommendChunksToFree
virtual CacheResult recommendChunksToFree(QList< RawCubeChunk * > allocated, QList< RawCubeChunk * > justUsed, const Buffer &justRequested)
Please see the class description for how this algorithm works.
Definition: BoxcarCachingAlgorithm.cpp:49
Isis::BoxcarCachingAlgorithm::BoxcarCachingAlgorithm
BoxcarCachingAlgorithm()
Construct a new BoxcarCachingAlgorithm.
Definition: BoxcarCachingAlgorithm.cpp:27
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16