#include "BlockArray.h"
Public Member Functions | |
BlockArray () | |
Creates a history file for holding maximal size blocks. More... | |
~BlockArray () | |
destructor More... | |
size_t | append (Block *block) |
adds the Block at the end of history. More... | |
const Block * | at (size_t index) |
gets the block at the index. More... | |
size_t | getCurrent () const |
bool | has (size_t index) const |
Block * | lastBlock () const |
size_t | len () const |
size_t | newBlock () |
bool | setHistorySize (size_t newsize) |
reorders blocks as needed. More... | |
bool | setSize (size_t newsize) |
Convenient function to set the size in KBytes instead of blocks. More... | |
Private Member Functions | |
void | decreaseBuffer (size_t newsize) |
void | increaseBuffer () |
void | unmap () |
Private Attributes | |
size_t | current |
size_t | index |
int | ion |
Block * | lastblock |
Block * | lastmap |
size_t | lastmap_index |
size_t | length |
size_t | size |
Definition at line 39 of file BlockArray.h.
BlockArray::BlockArray | ( | ) |
Creates a history file for holding maximal size blocks.
If more blocks are requested, then it drops earlier added ones.
Definition at line 39 of file BlockArray.cpp.
References blocksize.
BlockArray::~BlockArray | ( | ) |
destructor
Definition at line 54 of file BlockArray.cpp.
References lastblock, and setHistorySize().
size_t BlockArray::append | ( | Block * | block | ) |
adds the Block at the end of history.
This may drop other blocks.
The ownership on the block is transfered. An unique index number is returned for accessing it later (if not yet dropped then)
Note, that the block may be dropped completely if history is turned off.
Definition at line 60 of file BlockArray.cpp.
References blocksize, current, index, ion, length, SEEK_SET, setHistorySize(), and size.
Referenced by newBlock().
const Block * BlockArray::at | ( | size_t | index | ) |
gets the block at the index.
Function may return 0 if the block isn't available any more.
The returned block is strictly readonly as only maped in memory - and will be invalid on the next operation on this class.
Definition at line 108 of file BlockArray.cpp.
References blocksize, index, ion, lastblock, lastmap, lastmap_index, size, and unmap().
Referenced by HistoryScrollBlockArray::getCells().
|
private |
Definition at line 227 of file BlockArray.cpp.
References blocksize, current, index, ion, length, moveBlock(), and size.
Referenced by setHistorySize().
|
inline |
Definition at line 97 of file BlockArray.h.
References current.
Referenced by HistoryScrollBlockArray::addCells().
bool BlockArray::has | ( | size_t | index | ) | const |
Definition at line 96 of file BlockArray.cpp.
|
private |
Definition at line 273 of file BlockArray.cpp.
References blocksize, current, index, ion, length, moveBlock(), SEEK_SET, and size.
Referenced by setHistorySize().
Block * BlockArray::lastBlock | ( | ) | const |
Definition at line 91 of file BlockArray.cpp.
References lastblock.
Referenced by HistoryScrollBlockArray::addCells().
|
inline |
Definition at line 93 of file BlockArray.h.
References length.
size_t BlockArray::newBlock | ( | ) |
Definition at line 81 of file BlockArray.cpp.
References append(), index, lastblock, and size.
Referenced by HistoryScrollBlockArray::addCells().
bool BlockArray::setHistorySize | ( | size_t | newsize | ) |
reorders blocks as needed.
If newsize is null, the history is emptied completely. The indices returned on append won't change their semantic, but they may not be valid after this call.
Definition at line 156 of file BlockArray.cpp.
References blocksize, current, decreaseBuffer(), increaseBuffer(), ion, lastblock, length, size, and unmap().
Referenced by HistoryScrollBlockArray::HistoryScrollBlockArray(), ~BlockArray(), append(), and setSize().
bool BlockArray::setSize | ( | size_t | newsize | ) |
Convenient function to set the size in KBytes instead of blocks.
Definition at line 151 of file BlockArray.cpp.
References blocksize, and setHistorySize().
|
private |
Definition at line 141 of file BlockArray.cpp.
References blocksize, lastmap, and lastmap_index.
Referenced by at(), and setHistorySize().
|
private |
Definition at line 106 of file BlockArray.h.
Referenced by append(), decreaseBuffer(), getCurrent(), increaseBuffer(), and setHistorySize().
|
private |
Definition at line 107 of file BlockArray.h.
Referenced by append(), at(), decreaseBuffer(), has(), increaseBuffer(), and newBlock().
|
private |
Definition at line 113 of file BlockArray.h.
Referenced by append(), at(), decreaseBuffer(), increaseBuffer(), and setHistorySize().
|
private |
Definition at line 111 of file BlockArray.h.
Referenced by ~BlockArray(), at(), lastBlock(), newBlock(), and setHistorySize().
|
private |
Definition at line 109 of file BlockArray.h.
|
private |
Definition at line 110 of file BlockArray.h.
|
private |
Definition at line 114 of file BlockArray.h.
Referenced by append(), decreaseBuffer(), has(), increaseBuffer(), len(), and setHistorySize().
|
private |
Definition at line 104 of file BlockArray.h.
Referenced by append(), at(), decreaseBuffer(), increaseBuffer(), newBlock(), and setHistorySize().