Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _RSCACHE_H
00009 #define _RSCACHE_H
00010
00011 #include <stdint.h>
00012 #include<tr1/unordered_map>
00013 #include<gmpxx.h>
00014
00015 #define VDRIVE_RSCACHE_LT std::tr1::unordered_map<int32_t, mpq_class*>
00016
00017 #define VDRIVE_RSCACHE_LTit std::tr1::unordered_map<int32_t, mpq_class*>::iterator
00018
00019 #define VDRIVE_RSCACHE_NT std::tr1::unordered_map<int32_t, RSCache*>
00020
00021 #define VDRIVE_RSCACHE_NTit std::tr1::unordered_map<int32_t, RSCache*>::iterator
00022
00023 namespace VDRIVE {
00024
00040 class RSCache {
00041 public:
00051 virtual std::pair<const int32_t, mpq_class*>* getHighValue(int32_t* query) = 0;
00052
00062 virtual std::pair<const int32_t, mpq_class*>* getLowValue(int32_t* query) = 0;
00063
00070 virtual void setValue(int32_t* query, mpq_class &value) = 0;
00071
00079 virtual mpq_class* getValue(int32_t* query) = 0;
00080
00089 static RSCache* createInstance(int32_t depth);
00090
00094 virtual ~RSCache() {
00095 }
00096 };
00097
00103 class RSCacheLeaf : public VDRIVE::RSCache {
00104 public:
00108 virtual mpq_class* getValue(int32_t* query);
00109
00113 virtual std::pair<const int32_t, mpq_class*>* getHighValue(int32_t* query);
00114
00118 virtual std::pair<const int32_t, mpq_class*>* getLowValue(int32_t* query);
00119
00123 virtual void setValue(int32_t* query, mpq_class &value);
00124
00128 virtual ~RSCacheLeaf();
00129
00137 RSCacheLeaf() {
00138 cache = new VDRIVE_RSCACHE_LT ();
00139 highVal = 0;
00140 }
00141
00142 private:
00146 VDRIVE_RSCACHE_LT *cache;
00147
00151 int32_t highVal;
00152
00156 int32_t lowVal;
00157 };
00158
00164 class RSCacheNode : public VDRIVE::RSCache {
00165 public:
00169 virtual mpq_class* getValue(int32_t* query);
00170
00174 virtual std::pair<const int32_t, mpq_class*>* getHighValue(int32_t* query);
00175
00179 virtual std::pair<const int32_t, mpq_class*>* getLowValue(int32_t* query);
00180
00184 virtual void setValue(int32_t* query, mpq_class &value);
00185
00189 virtual ~RSCacheNode();
00190
00200 RSCacheNode(int32_t depth) {
00201 cache = new VDRIVE_RSCACHE_NT ();
00202 this->depth = depth;
00203 }
00204
00205 private:
00209 int32_t depth;
00210
00214 VDRIVE_RSCACHE_NT *cache;
00215 };
00216 }
00217 #endif
00218