Isis 3.0 Programmer Reference
Back | Home
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 {
43  m_minLine = 1;
44  }
45 
46 
51  }
52 
53 
66  const Buffer &justRequested) {
67  (void) justRequested; // unused, for fullfilling virtual function signiture
68  QList<RawCubeChunk *> chunksToToss;
69 
70  //std::cerr << "begin" << std::endl;
71 
72  if (justUsed.size() > 0) {
73  // TODO bands
74  int minLine = justUsed[0]->getStartLine();
75 
76  QListIterator<RawCubeChunk *> justUsedIterator(justUsed);
77  while (justUsedIterator.hasNext()) {
78  RawCubeChunk *chunk = justUsedIterator.next();
79  int currentStart = chunk->getStartLine();
80  if (currentStart < minLine) minLine = currentStart;
81  }
82 
83  if (minLine > m_minLine) {
84  m_minLine = minLine;
85  QListIterator<RawCubeChunk *> allocatedIterator(allocated);
86  while (allocatedIterator.hasNext()) {
87  RawCubeChunk *chunk = allocatedIterator.next();
88  int currentEnd = chunk->getStartLine() + chunk->lineCount() - 1;
89 
90  if (currentEnd < minLine) {
91  //std::cerr << "minLine = " << minLine << " | maxLine = " << maxLine << std::endl;
92  //std::cerr << "currentStart = " << currentStart << " | currentEnd = " << currentEnd << std::endl;
93  chunksToToss.append(chunk);
94  }
95  }
96  }
97 
98  //std::cerr << "allocated chunks = " << allocated.size() << std::endl;
99  //std::cerr << "num chunks = " << chunksToToss.size() << std::endl;
100  }
101 
102  return CacheResult(chunksToToss);
103  }
104 }
Buffer for reading and writing cube data.
Definition: Buffer.h:68
virtual ~BoxcarCachingAlgorithm()
Frees the memory allocated by this caching algorithm.
int getStartLine() const
Definition: RawCubeChunk.h:75
int lineCount() const
Definition: RawCubeChunk.h:96
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.
virtual CacheResult recommendChunksToFree(QList< RawCubeChunk * > allocated, QList< RawCubeChunk * > justUsed, const Buffer &justRequested)
Please see the class description for how this algorithm works.
This stores the results of the caching algorithm.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:49