Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _SHAREDISK_H
00009 #define _SHAREDISK_H
00010
00011 #include<stdint.h>
00012
00013 namespace VDRIVE {
00014
00015 class ShareDisk {
00016 public:
00017 ShareDisk(const ShareDisk& orig) {
00018 this->id = orig.id;
00019 this->end = orig.end;
00020 this->rounds = orig.end;
00021 this->start = orig.start;
00022 };
00023
00024 virtual ~ShareDisk() {
00025 };
00026
00027 ShareDisk(int64_t id, uint64_t start, uint64_t end, int32_t rounds, int32_t copy) {
00028 this->id = id;
00029 this->start = start;
00030 this->rounds = rounds;
00031 this->end = end;
00032 this->copy = copy;
00033 }
00034
00035 int64_t getID() {
00036 return id;
00037 }
00038
00039 int64_t getStart() {
00040 return start;
00041 }
00042
00043 int64_t getEnd() {
00044 return end;
00045 }
00046
00047 int32_t getCopy() {
00048 return copy;
00049 }
00050
00051 bool coversPoint(uint64_t point) {
00052 if (rounds > 0)
00053 return true;
00054 if (start < end) {
00055 if ((point > start) && (point < end))
00056 return true;
00057 return false;
00058 }
00059 if (point < end)
00060 return true;
00061 if (point > start)
00062 return true;
00063 return false;
00064 }
00065
00066 int32_t countCoversPoint(uint64_t point) {
00067 if (start < end) {
00068 if ((point > start) && (point < end))
00069 return rounds + 1;
00070 return rounds;
00071 }
00072 if (point < end)
00073 return rounds + 1;
00074 if (point > start)
00075 return rounds + 1;
00076 return rounds;
00077 }
00078 private:
00079 int64_t id;
00080 uint64_t start;
00081 uint64_t end;
00082 int32_t rounds;
00083 int32_t copy;
00084 };
00085 }
00086 #endif
00087