Store Class Reference

The Store is a file based memory manager. More...

#include <store.h>

Inheritance diagram for Store:

StorageIntf List of all members.

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 ()

Classes

struct  Node

Detailed Description

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.

Definition at line 52 of file store.h.


Constructor & Destructor Documentation

Store::Store (  ) 

Creates a store.

Definition at line 43 of file store.cpp.

Store::~Store (  ) 

Releases the store object. Will close the underlying file if opened.

Definition at line 53 of file store.cpp.


Member Function Documentation

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 66 of file store.cpp.

References BLOCK_SIZE, and STORE_ASSERT.

portable_off_t Store::alloc (  ) 

Allocates a handle to write to and read from.

Definition at line 99 of file store.cpp.

References BLOCK_SIZE, portable_fseek(), portable_ftell(), and STORE_ASSERT.

Referenced by MemberDef::flushToDisk().

int Store::write ( const char *  buf,
uint  size 
) [virtual]

Writes size bytes in array buf to the store. First alloc() has to be called.

Note:
The information can only be read after end() has been called.

Implements StorageIntf.

Definition at line 137 of file store.cpp.

References BLOCK_POINTER_SIZE, BLOCK_SIZE, portable_fseek(), portable_ftell(), and STORE_ASSERT.

void Store::end (  ) 

Ends the sequence of writes.

Note:
After this call, first alloc() has to be called before new writes can be done.

Definition at line 213 of file store.cpp.

References BLOCK_SIZE, portable_ftell(), and STORE_ASSERT.

void Store::release ( portable_off_t  handle  ) 

Releases the memory corresponding to the handle returned with alloc()

Definition at line 229 of file store.cpp.

References BLOCK_POINTER_SIZE, BLOCK_SIZE, portable_fseek(), and STORE_ASSERT.

void Store::close (  ) 

Closes the store

Definition at line 92 of file store.cpp.

Referenced by generateOutput().

void Store::seek ( portable_off_t  handle  ) 

Goes to the start of information corresponding to handle pos

Definition at line 264 of file store.cpp.

References BLOCK_SIZE, portable_fseek(), and STORE_ASSERT.

Referenced by MemberDef::loadFromDisk().

int Store::read ( char *  buf,
uint  size 
) [virtual]

Reads size bytes from the store into the array pointed to be buf.

Note:
Before reading seek() has to be called to set the right start of the store.

Implements StorageIntf.

Definition at line 277 of file store.cpp.

References BLOCK_POINTER_SIZE, BLOCK_SIZE, portable_fseek(), portable_ftell(), and STORE_ASSERT.

void Store::printStats (  ) 

Definition at line 342 of file store.cpp.

References BLOCK_SIZE.


The documentation for this class was generated from the following files:



Generated on Mon Mar 31 10:59:03 2008 by  doxygen 1.5.1