lsxml::ContextT< _Tag > Class Template Reference

Memory context. More...

#include <lsxml.h>

Inheritance diagram for lsxml::ContextT< _Tag >:

lsxml::StackContext< Size > lsxml::StackContext< Size > List of all members.

Public Member Functions

 ContextT (uint blockSize=(4 *4096), int flags=0)
 Constructs a standard context.
 ContextT (void *memory, uint size)
 Constructs a context which uses the specified memory block.
 ~ContextT ()
 Destructor. Destroys managed objects and releases allocated memory.
void * Allocate (uint size, bool temporary=false)
 Allocates memory in this context.
bool IsTemporary (void *mem)
 Checks if the specified pointer belongs to a temporary block.
void MakeCurrent ()
 Sets this context as the current one.
void Collect ()
 Collects all used memory and resources.
void Manage (ManagedObject *obj)
 Adds the specified object to the list of managed objects.
void Unmanage (ManagedObject *obj)
 Removes the specified object from the list of managed objects.
void BeginFrame ()
 Begins an allocation frame.
void EndFrame ()
 Ends an allocation frame.

Static Public Member Functions

static ContextT< _Tag > * Current ()
 Returns the current context for this thread.

Detailed Description

template<typename _Tag>
class lsxml::ContextT< _Tag >

Memory context.


Constructor & Destructor Documentation

template<typename _Tag>
lsxml::ContextT< _Tag >::ContextT ( uint  blockSize = (4 *4096),
int  flags = 0 
) [explicit]

Constructs a standard context.

Parameters:
blockSize the size of a single block
flags the context flags
See also:
ContextFlags

template<typename _Tag>
lsxml::ContextT< _Tag >::ContextT ( void *  memory,
uint  size 
)

Constructs a context which uses the specified memory block.

Using this constructor, the user can supply the context with a custom memory block (i.e. a stack buffer or memory mapped file). Note that this constructor shoud be used with care - the library does not track the current memory usage, therefore exceeding the buffer capacity will result in a segmentation fault.

Parameters:
memory address of the buffer
size size of the buffer


Member Function Documentation

template<typename _Tag>
void* lsxml::ContextT< _Tag >::Allocate ( uint  size,
bool  temporary = false 
)

Allocates memory in this context.

Allocates a memory block in this context

Parameters:
size number of bytes to allocate
temporary this parameter is used internally by the library
Returns:
address of the allocated memory

template<typename _Tag>
bool lsxml::ContextT< _Tag >::IsTemporary ( void *  mem  ) 

Checks if the specified pointer belongs to a temporary block.

This function is used internally by the library

template<typename _Tag>
static ContextT<_Tag>* lsxml::ContextT< _Tag >::Current (  )  [inline, static]

Returns the current context for this thread.

Returns the current context for the current thread.

Returns:
the current context or NULL if there's no current context

template<typename _Tag>
void lsxml::ContextT< _Tag >::MakeCurrent (  ) 

Sets this context as the current one.

Sets this context as the current context for the current thread

See also:
Current

template<typename _Tag>
void lsxml::ContextT< _Tag >::Collect (  ) 

Collects all used memory and resources.

Releases all managed objects and frees all blocks allocated previously by this context. Does not physically free the memory.

template<typename _Tag>
void lsxml::ContextT< _Tag >::Manage ( ManagedObject obj  ) 

Adds the specified object to the list of managed objects.

This function is used internally by the library

template<typename _Tag>
void lsxml::ContextT< _Tag >::Unmanage ( ManagedObject obj  ) 

Removes the specified object from the list of managed objects.

This function is used internally by the library


The documentation for this class was generated from the following files:
Generated on Tue Sep 29 14:51:12 2009 for lsxml by  doxygen 1.5.1-p1