libsswf: sswf::MemBuffer Class Reference

# sswf::MemBuffer Class Reference

A type of smart pointer used to manage memory buffers. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::MemBuffer:

List of all members.

## Public Member Functions
void | AttachBuffer (Buffer *buffer)
| Attaches the specified buffer to this memory buffer.
Buffer * | GetBuffer (void) const
| Retrieve the Buffer of this MemBuffer.
| MemBuffer (void)
| Initializes a memory buffer.
virtual | ~MemBuffer ()
| Cleans up a memory buffer.
## Private Attributes
Buffer * | f_buffer

## Detailed Description

The MemBuffer class can be viewed as a buffer of memory which needs to be automatically managed.

The idea is to derive new classes from MemBuffer. These classes can then be managed by an sswf::MemoryManager. This is necessary for items put in vectors, the vectors themselves and a few othe objects which would otherwise not be managed.

A good examples are the actions. All the actions put in a vector are managed by that vector. In effect, when you destroy that vector, it automatically deletes all the actions.

See also:
  sswf::MemoryManager

  sswf::Buffer

## Constructor & Destructor Documentation

MemBuffer::MemBuffer | ( | void |  | ) |

The constructor initializes the memory buffer with a null (i.e. no buffer).

References f_buffer.

MemBuffer::~MemBuffer | ( |  | ) | `[virtual]`

The destructor ensures that any buffer still allocated gets deleted.

References f_buffer.

## Member Function Documentation

void MemBuffer::AttachBuffer | ( | Buffer * | buffer | ) |

This function is used when you attach a MemBuffer to a Buffer. The Buffer saves itself in the MemBuffer. In effect the item derived from this MemBuffer class becomes part of a MemoryManager.

It is an error to get attached to multiple buffers without first clearing the MemBuffer once. This should not be necessary since once an item is in a MemoryManager it does not need to be moved.

Parameters:

  | buffer | The buffer to attach to this MemBuffer

References sswf::assert(), f_buffer, and sswf::Buffer::Info().

Referenced by sswf::Buffer::Buffer().

Buffer * MemBuffer::GetBuffer | ( | void |  | ) | const

This function is used to retrieve the Buffer which was previously attached with this MemBuffer object.

Returns:
  A pointer to the Buffer or NULL when no buffer was attached

References f_buffer.

## Member Data Documentation

Buffer* sswf::MemBuffer::f_buffer`[private]`

Referenced by AttachBuffer(), GetBuffer(), MemBuffer(), and ~MemBuffer().

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

- libsswf.h
- libsswf_memory.c++