home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWFILEMGR_H__
- #define __RWFILEMGR_H__
- pragma push_align_members(64);
-
- /*
- * RWFileManager --- manages free space in a file
- *
- * $Header: E:/vcs/rw/filemgr.h_v 1.2 18 Feb 1992 09:54:20 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1989, 1990, 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/filemgr.h_v $
- *
- * Rev 1.2 18 Feb 1992 09:54:20 KEFFER
- *
- * Rev 1.1 28 Oct 1991 09:08:14 keffer
- * Changed inclusions to <rw/xxx.h>
- *
- * Rev 1.0 28 Jul 1991 08:15:00 keffer
- * Tools.h++ V4.0.5 PVCS baseline version
- *
- */
-
- #include "rw/rwfile.h"
- #include "rw/tooldefs.h"
-
- #ifdef RDEBUG
- const int freeListArraySize = 2;
- #else
- const int freeListArraySize = 10;
- #endif
-
- class RWExport RWFileManager;
- class RWfreeListData {
- friend RWFileManager;
- unsigned short magicNumber;
- RWoffset freeSpaceOffset [freeListArraySize];
- RWspace freeSpaceSize [freeListArraySize];
- int entries; // Number of free spaces entries.
- RWoffset next; // Next block of free space data.
-
- RWBoolean addFreeSpace(RWoffset, RWspace);
- RWoffset allocate(RWspace);
- void attemptMerge(int);
- RWBoolean coalesce(RWoffset, RWspace);
- RWBoolean enterFreeSpace(RWoffset, RWspace);
- void initialize(RWoffset);
- void slideRight(int);
- void slideLeft(int);
- };
-
- class RWExport RWFileManager : public RWFile {
- private:
- RWfreeListData freeList; // Free list block in memory.
- RWoffset startOfData; // Offset to first data in file.
- RWoffset endOfData; // Offset to last data in file.
- RWoffset here; // Location of freeList on disk.
- RWFileManager(const RWFileManager&); // Cannot have 2 managers for the same file.
- void operator=(const RWFileManager&);
- public:
- RWFileManager(const char* filename);
-
- RWoffset start() const {return startOfData;}
- RWoffset endData() const {return endOfData;}
- RWoffset allocate(RWspace); // Allocate storage
- void deallocate(RWoffset); // Deallocate storage.
- #ifdef RDEBUG
- void summarize();
- #endif
-
- private:
- void addFreeList(RWoffset, RWspace);
- void addToFreeList(RWoffset, RWspace);
- RWoffset allocateAtEnd(RWspace);
- RWoffset allocateInFreeList(RWspace);
- RWBoolean checkForEnd(RWoffset, RWspace);
- void deleteFreeList();
- void fileMgrErr(RWErrNo); // Error handler.
- RWBoolean isRootFreeList() const; // Root free list block?
- RWBoolean onlyRootFreeList() const; // Is root free list block only block?
- RWBoolean readFreeList(RWoffset); // Read free list block from location
- RWBoolean writeFreeList(); // Write free list block to disk
- RWBoolean writeFreeList(RWoffset); // Write free list block to disk
- };
-
- pragma pop_align_members();
- #endif /* __RWFILEMGR_H__ */
-