00001
00007 #ifndef KEYPAGE_H
00008 #define KEYPAGE_H
00009 #include"allg.h"
00010 #include<rpointer.h>
00011 typedef off_t ploff_t;
00012 #include"mempl.h"
00013 #include"common_page.h"
00014
00015 struct KeyPage : CommonPage
00016 {
00017 off_t parent;
00018 long anz;
00019 };
00020
00025 class KeyPageAccess: public RAMS::Mseg
00026 {
00027 public:
00028 KeyPageAccess():Mseg() {}
00029 KeyPageAccess(CommonPage * base)
00030 :Mseg((char *)base,PAGESIZE) {}
00031 void setto(CommonPage *base)
00032 {
00033 RAMS::Mseg::setto((char *)base,PAGESIZE);
00034 assert(page()->pagetyp == pagetype());
00035 }
00036
00037 virtual Page_type_t pagetype()=0;
00038 int count() { return page()->anz; }
00039 virtual size_t space() = 0;
00040 virtual mempl_t key(int i)=0;
00041 mempl_t keymax() { return key(count()-1); }
00042 virtual int keycmp(int i,const octet_t *other,size_t olen)=0;
00043
00044 int find(const octet_t *key,size_t keylen);
00045 int find(mempl_t key) { return find(key.ptr,key.l); }
00049 void next(RAMS::RPointer<CommonPage,PAGESIZE>& akt)
00050 {
00051 akt.setoff(page()->next);
00052 }
00056 void prev(RAMS::RPointer<CommonPage,PAGESIZE>& akt)
00057 {
00058 akt.setoff(page()->prev);
00059 }
00063 void get_parent(RAMS::RPointer<CommonPage,PAGESIZE>& akt)
00064 {
00065 akt.setoff(page()->parent);
00066 }
00067 void set_parent(RAMS::RPointer<CommonPage,PAGESIZE>& akt)
00068 {
00069 page()->parent = akt.offset();
00070 }
00071
00078 virtual int splitt(CommonPage *neu1,CommonPage *neu2)=0;
00079 protected:
00080 KeyPage *page() { return (KeyPage *)begin(); }
00081 };
00082 #endif
00083
00084