GNU CommonC++
Classes | Public Member Functions | List of all members
ost::StackPager Class Reference

The StackPager provides a repository to stash and retrieve working data in last-in-first-out order. More...

#include <misc.h>

Inheritance diagram for ost::StackPager:
ost::MemPager

Public Member Functions

 StackPager (size_t pagesize)
 Create a lifo pager as a mempager. More...
 
void * push (const void *object, size_t size)
 Push an arbitrary object onto the stack. More...
 
void * push (const char *string)
 Push a string onto the stack. More...
 
void * pull (void)
 Retrieve next object from stack. More...
 
void purge (void)
 Purge the stack of all objects and memory allocations. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ost::MemPager
virtual void * first (size_t size)
 Allocate first workspace from paged memory. More...
 
virtual void * alloc (size_t size)
 Allocate memory from either the currently active page, or allocate a new page for the object. More...
 
char * first (char *str)
 Allocate a string from the memory pager pool and copy the string into it's new memory area. More...
 
char * alloc (const char *str)
 Allocate a string from the memory pager pool and copy the string inti it's new memory area. More...
 
 MemPager (size_t pagesize=4096)
 Create a paged memory pool for cumulative storage. More...
 
void purge (void)
 purge the current memory pool. More...
 
void clean (void)
 Clean for memory cleanup before exiting. More...
 
virtual ~MemPager ()
 Delete the memory pool and all allocated memory. More...
 
int getPages (void)
 Return the total number of pages that have been allocated for this memory pool. More...
 

Detailed Description

The StackPager provides a repository to stash and retrieve working data in last-in-first-out order.

The use of a mempager to support it's operation allows storage of arbitrary sized objects with no fixed limit.

Author
David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m last in first out object pager.

Constructor & Destructor Documentation

ost::StackPager::StackPager ( size_t  pagesize)

Create a lifo pager as a mempager.

Parameters
pagesizefor memory allocation

Member Function Documentation

void* ost::StackPager::pull ( void  )

Retrieve next object from stack.

Returns
object.
void ost::StackPager::purge ( void  )

Purge the stack of all objects and memory allocations.

void* ost::StackPager::push ( const void *  object,
size_t  size 
)

Push an arbitrary object onto the stack.

Returns
stack memory location.
Parameters
objectpointer to data
sizeof data.
void* ost::StackPager::push ( const char *  string)

Push a string onto the stack.

Returns
stack memory location.
Parameters
stringpointer.

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