00001 #ifndef _PUP_PAGED_H_
00002 #define _PUP_PAGED_H_
00003 #define PUP_BLOCK 512
00004 #include <stdio.h>
00005 #include <string.h>
00006 #include "pup.h"
00007 typedef struct _list{
00008 int n;
00009 struct _list *next;
00010 } pup_list;
00011
00012 typedef struct _pageentry{
00013 void *ptr;
00014 pup_list *blklist;
00015 struct _pageentry *next;
00016 } pup_pageentry;
00017
00018 typedef struct {
00019 pup_list *freelist;
00020 pup_list *tailfreelist;
00021 pup_pageentry *table;
00022 pup_pageentry *tailtable;
00023 int maxblk;
00024 FILE *fp;
00025 char *fName;
00026 } pup_pagetable;
00027
00028
00029 pup_pagetable *getNewPagetable(char *fName);
00030
00031 class PUP_pagedDisk : public PUP::er {
00032 protected:
00033 pup_pagetable *_pagetable;
00034 void *handle;
00035 PUP_pagedDisk(unsigned int type,void *objhandle,pup_pagetable *pgtable):PUP::er(type),_pagetable(pgtable),handle(objhandle){
00036 }
00037
00038 };
00039
00040 class PUP_toPagedDisk : public PUP_pagedDisk{
00041 protected:
00042 virtual void bytes(void *p,size_t n,size_t itemSize,PUP::dataType t);
00043 pup_pageentry *entry;
00044 long current_block;
00045 long bytes_left;
00046 FILE *fp;
00047 pup_list *tailblklist;
00048 public:
00049 PUP_toPagedDisk(void *objhandle,pup_pagetable *pgtable):PUP_pagedDisk(IS_PACKING,objhandle,pgtable){
00050 addpageentry();
00051 nextblock();
00052 fp = _pagetable->fp;
00053 }
00054
00055 void addpageentry();
00056 void nextblock();
00057
00058
00059 };
00060
00061 class PUP_fromPagedDisk : public PUP_pagedDisk{
00062 protected:
00063 virtual void bytes(void *p,size_t n,size_t itemSize,PUP::dataType );
00064 pup_pageentry *entry;
00065 long current_block;
00066 long bytes_unread;
00067 FILE *fp;
00068 public:
00069 PUP_fromPagedDisk(void *objhandle,pup_pagetable *pgtable):PUP_pagedDisk(IS_UNPACKING,objhandle,pgtable){
00070 findpageentry();
00071 current_block = -1;
00072 nextblock();
00073 fp = _pagetable->fp;
00074 }
00075
00076 ~PUP_fromPagedDisk(){
00077 nextblock();
00078 delete entry;
00079 }
00080 void findpageentry();
00081 void nextblock();
00082 };
00083
00084 #endif