2009-11-21 01:45:08 +00:00
|
|
|
#ifndef __BITMAP_H__
|
|
|
|
#define __BITMAP_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2011-03-13 16:02:30 +00:00
|
|
|
#include <vector>
|
2009-11-24 04:57:41 +00:00
|
|
|
|
|
|
|
|
2011-03-13 16:02:30 +00:00
|
|
|
namespace Device
|
|
|
|
{
|
|
|
|
class BlockDevice;
|
|
|
|
class BlockCache;
|
|
|
|
}
|
2009-11-21 01:45:08 +00:00
|
|
|
|
|
|
|
|
2011-03-13 16:02:30 +00:00
|
|
|
namespace ProDOS {
|
2009-11-24 04:57:41 +00:00
|
|
|
|
|
|
|
|
2009-11-21 01:45:08 +00:00
|
|
|
class Bitmap {
|
|
|
|
public:
|
|
|
|
|
|
|
|
Bitmap(unsigned blocks);
|
2011-03-13 16:02:30 +00:00
|
|
|
Bitmap(Device::BlockCache *cache, unsigned keyPointer, unsigned blocks);
|
|
|
|
|
2009-11-21 01:45:08 +00:00
|
|
|
~Bitmap();
|
|
|
|
|
|
|
|
int allocBlock();
|
|
|
|
int allocBlock(unsigned block);
|
|
|
|
|
|
|
|
void freeBlock(unsigned block);
|
|
|
|
|
|
|
|
|
|
|
|
unsigned freeBlocks() const { return _freeBlocks; }
|
|
|
|
unsigned blocks() const { return _blocks; }
|
|
|
|
unsigned bitmapBlocks() const { return _bitmapBlocks; }
|
|
|
|
unsigned bitmapSize() const { return _bitmapBlocks * 512; }
|
2011-03-13 16:02:30 +00:00
|
|
|
const void *bitmap() const { return &_bitmap[0]; }
|
2009-11-21 01:45:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
unsigned _freeIndex;
|
|
|
|
unsigned _freeBlocks;
|
|
|
|
|
|
|
|
unsigned _blocks;
|
|
|
|
unsigned _bitmapBlocks;
|
|
|
|
|
2011-03-13 16:02:30 +00:00
|
|
|
std::vector<uint8_t> _bitmap;
|
2009-11-21 01:45:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|