Isis 3 Programmer Reference
BoxcarCachingAlgorithm.cpp
Go to the documentation of this file.
1 
21 #include "BoxcarCachingAlgorithm.h"
22 
23 #include <algorithm>
24 #include <iostream>
25 
26 #include <QList>
27 #include <QQueue>
28 
29 #include "IException.h"
30 #include "IString.h"
31 #include "RawCubeChunk.h"
32 
33 namespace Isis {
41  m_minLine = 1;
42  }
43 
44 
49  }
50 
51 
64  const Buffer &justRequested) {
65  (void) justRequested; // unused, for fullfilling virtual function signiture
66  QList<RawCubeChunk *> chunksToToss;
67 
68  if (justUsed.size() > 0) {
69  // TODO bands
70  int minLine = justUsed[0]->getStartLine();
71 
72  QListIterator<RawCubeChunk *> justUsedIterator(justUsed);
73  while (justUsedIterator.hasNext()) {
74  RawCubeChunk *chunk = justUsedIterator.next();
75  int currentStart = chunk->getStartLine();
76  if (currentStart < minLine) minLine = currentStart;
77  }
78 
79  if (minLine > m_minLine) {
80  m_minLine = minLine;
81  QListIterator<RawCubeChunk *> allocatedIterator(allocated);
82  while (allocatedIterator.hasNext()) {
83  RawCubeChunk *chunk = allocatedIterator.next();
84  int currentEnd = chunk->getStartLine() + chunk->lineCount() - 1;
85 
86  if (currentEnd < minLine) {
87  chunksToToss.append(chunk);
88  }
89  }
90  }
91  }
92 
93  return CacheResult(chunksToToss);
94  }
95 }
Buffer for reading and writing cube data.
Definition: Buffer.h:69
int getStartLine() const
Definition: RawCubeChunk.h:75
virtual ~BoxcarCachingAlgorithm()
Frees the memory allocated by this caching algorithm.
virtual CacheResult recommendChunksToFree(QList< RawCubeChunk *> allocated, QList< RawCubeChunk *> justUsed, const Buffer &justRequested)
Please see the class description for how this algorithm works.
int lineCount() const
Definition: RawCubeChunk.h:96
int m_minLine
Used to calculate what lines to cache.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
A section of raw data on the disk.
Definition: RawCubeChunk.h:42
BoxcarCachingAlgorithm()
Construct a new BoxcarCachingAlgorithm.
This stores the results of the caching algorithm.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31