The Store is a file based memory manager. More...
#include <store.h>
Classes | |
struct | Node |
Public Member Functions | |
Store () | |
~Store () | |
int | open (const char *name) |
portable_off_t | alloc () |
int | write (const char *buf, uint size) |
void | end () |
void | release (portable_off_t handle) |
void | close () |
void | seek (portable_off_t handle) |
int | read (char *buf, uint size) |
void | printStats () |
portable_off_t | pos () const |
void | dumpBlock (portable_off_t start, portable_off_t end) |
Public Member Functions inherited from StorageIntf | |
virtual | ~StorageIntf () |
Private Types | |
enum | State { Init, Reading, Writing } |
Private Member Functions | |
void | printFreeList () |
Private Attributes | |
FILE * | m_file |
portable_off_t | m_front |
portable_off_t | m_cur |
Node * | m_head |
State | m_state |
int | m_reads |
int | m_writes |
The Store is a file based memory manager.
You can open the store using open(). Then obtain a handle via alloc() followed by a sequence of write() commands to store information, and finalize it using end().
Later on you locate the information with seek() using the handle obtained with alloc(), and then use a sequence of read() calls to read the information back.
If no longer needed the storage space can be freed using release().
The store will dynamically grow the file on disk if needed.
|
private |
Enumerator | |
---|---|
Init | |
Reading | |
Writing |
Store::Store | ( | ) |
Store::~Store | ( | ) |
portable_off_t Store::alloc | ( | ) |
Allocates a handle to write to and read from.
Definition at line 108 of file store.cpp.
void Store::close | ( | ) |
void Store::dumpBlock | ( | portable_off_t | start, |
portable_off_t | end | ||
) |
Definition at line 400 of file store.cpp.
void Store::end | ( | ) |
Ends the sequence of writes.
Definition at line 249 of file store.cpp.
int Store::open | ( | const char * | name | ) |
Opens the file underlying the store using name as the file name. Returns 0 upon success, or -1 otherwise.
Definition at line 74 of file store.cpp.
|
inline |
void Store::printStats | ( | ) |
|
virtual |
Reads size bytes from the store into the array pointed to be buf.
Implements StorageIntf.
Definition at line 319 of file store.cpp.
void Store::release | ( | portable_off_t | handle | ) |
Releases the memory corresponding to the handle returned with alloc()
Definition at line 269 of file store.cpp.
void Store::seek | ( | portable_off_t | handle | ) |
Goes to the start of information corresponding to handle pos
Definition at line 305 of file store.cpp.
|
virtual |
Writes size bytes in array buf to the store. First alloc() has to be called.
Implements StorageIntf.
Definition at line 154 of file store.cpp.
|
private |
|
private |