Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

mfile.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      mfile.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __MFILE_H__
00022 #define __MFILE_H__
00023 
00024 #include "htdata.h"
00025 #include "stream.h"
00026 
00027 typedef FILEOFS PAGEOFS;
00028 
00029 /*
00030  *      CLASS ht_mod_page
00031  */
00032 
00033 #define DEFAULT_MOD_PAGE_SIZE 8*1024    /* MUST BE 2^n */
00034 
00035 class ht_mod_page: public Object {
00036 public:
00037         UINT size;
00038         byte *data;
00039 
00040                         ht_mod_page(UINT size);
00041                         ~ht_mod_page();
00042 /* new */
00043         virtual UINT    read(PAGEOFS pofs, byte *buf, UINT len);
00044         virtual UINT    write(PAGEOFS pofs, const byte *buf, UINT len);
00045 };
00046 
00047 /*
00048  *      CLASS ht_streamfile_modifier
00049  */
00050 
00051 class ht_streamfile_modifier: public ht_layer_streamfile {
00052 protected:
00053         ht_tree *mod_pages;
00054 
00055         bool modified;
00056 
00057         FILEOFS offset;
00058         UINT size;
00059 
00060         UINT page_granularity;
00061         UINT page_mask;
00062 
00063         bool active;
00064 /* new */
00065         virtual void    mod_pages_create();
00066         virtual void    mod_pages_destroy();
00067 
00068                    void mod_pages_flush();
00069                    void mod_pages_invd();
00070                          
00071         virtual ht_mod_page *mod_page_create(FILEOFS offset);
00072         virtual void    mod_page_destroy(FILEOFS offset);
00073         virtual ht_mod_page *mod_page_find(FILEOFS offset);
00074         virtual void    mod_page_flush(FILEOFS offset);
00075 
00076                    void cleardirtybyte(FILEOFS offset);
00077                    
00078                    bool isdirty(FILEOFS offset, UINT range);
00079 
00080                    bool isdirtybit(FILEOFS offset, UINT bit);
00081                    bool isdirtybyte(FILEOFS offset);
00082                    bool readbyte(FILEOFS offset, byte *b);
00083                    bool writebyte(FILEOFS offset, byte b);
00084 public:
00085                    void init(ht_streamfile *streamfile, int own_streamfile, UINT page_granularity = DEFAULT_MOD_PAGE_SIZE);
00086         virtual void    done();
00087 /* overwritten */
00088         virtual int     extend(UINT newsize);
00089         virtual UINT    get_size();
00090         virtual UINT    read(void *buf, UINT size);
00091         virtual int     seek(FILEOFS offset);
00092         virtual bool    set_access_mode(UINT access_mode);
00093         virtual FILEOFS tell();
00094         virtual int     truncate(UINT newsize);
00095         virtual int     vcntl(UINT cmd, va_list vargs);
00096         virtual UINT    write(const void *buf, UINT size);
00097 };
00098 
00099 #endif /* __MFILE_H__ */

Generated on Fri May 7 21:15:41 2004 by doxygen 1.3.5