00001 #ifndef PATCHCACHE_H
00002 #define PATCHCACHE_H
00003
00011 #include "PatchCacheLine.h"
00012
00013 #include <vector>
00014 #include <queue>
00015 class FormFactorEngine;
00016 class PatchRandomAccessEnumerator;
00017
00022 class PatchCache {
00023 public:
00030 PatchCache(PatchRandomAccessEnumerator *patchEnumerator, float ffTreshold, long maxCacheSize);
00031 ~PatchCache();
00032
00038 Color totalRadiosity(int destPatch);
00039
00044 long int cacheRawSize() const;
00045
00046 private:
00047 PatchRandomAccessEnumerator *patchEnumerator_;
00048 float ffTreshold_;
00049 long maxCacheSize_;
00050 size_t patchCount_;
00051 FormFactorEngine *ffe_;
00052
00053
00054 typedef std::vector<PatchCacheLine*> TCache;
00055 TCache *cache_;
00056 long int cachedItems_;
00057
00058
00059 class TQueueItem {
00060 PatchCacheLine **cl_;
00061 public:
00062 TQueueItem(PatchCacheLine **cl): cl_(cl) { }
00063
00064 operator int() const {
00065 return (*cl_)->itemCount();
00066 }
00067
00068 PatchCacheLine*& pCacheLine() const {
00069 return (*cl_);
00070 }
00071 };
00072 typedef std::priority_queue<TQueueItem> TQueue;
00073 TQueue *cacheQueue_;
00074 };
00075
00076 #endif // PATCHCACHE_H