Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

fl::Pointer Class Reference

#include <pointer.h>

List of all members.

Public Methods

 Pointer ()
 Pointer (const Pointer &that)
 Pointer (void *that, int size=0)
 Pointer (int size)
 ~Pointer ()
Pointer & operator= (const Pointer &that)
Pointer & operator= (void *that)
void attach (void *that, int size=0)
void copyFrom (const Pointer &that)
void copyFrom (const void *that, int size)
void grow (int size)
void clear ()
int refcount () const
int size () const
template<class T>  operator T * () const
void detach ()

Public Attributes

void * memory
 Pointer to block in heap. Must cast as needed.

int metaData

Protected Methods

void attach (const Pointer &that)
void allocate (int size)


Detailed Description

Keeps track of a block of memory, which can be shared by multiple objects and multiple threads. The block can either be managed by Pointer, or it can belong to any other part of the system. Only managed blocks get reference counting, automatic deletion, and reallocation. This class is intended to be thread-safe, but in its current state it is not. Need to implement a semaphore of some sort for the reference count. IE: use an atomic operation such as XADD that includes an exchange. Want to avoid using pthreads so we don't have to link another library.


Constructor & Destructor Documentation

fl::Pointer::Pointer   [inline]
 

fl::Pointer::Pointer const Pointer &    that [inline]
 

fl::Pointer::Pointer void *    that,
int    size = 0
[inline]
 

fl::Pointer::Pointer int    size [inline]
 

fl::Pointer::~Pointer   [inline]
 


Member Function Documentation

void fl::Pointer::allocate int    size [inline, protected]
 

void fl::Pointer::attach const Pointer &    that [inline, protected]
 

This method is protected because it assumes that we aren't responsible for our memory. We must guarantee that we don't own memory when this method is called. This is true just after a call to detach, as well as a few other situations.

void fl::Pointer::attach void *    that,
int    size = 0
[inline]
 

void fl::Pointer::clear   [inline]
 

void fl::Pointer::copyFrom const void *    that,
int    size
[inline]
 

void fl::Pointer::copyFrom const Pointer &    that [inline]
 

Parameters:
that  decouple from memory held by that. "that" could also be this.

void fl::Pointer::detach   [inline]
 

void fl::Pointer::grow int    size [inline]
 

template<class T>
fl::Pointer::operator T *   const [inline]
 

Pointer& fl::Pointer::operator= void *    that [inline]
 

Pointer& fl::Pointer::operator= const Pointer &    that [inline]
 

int fl::Pointer::refcount   const [inline]
 

int fl::Pointer::size   const [inline]
 


Member Data Documentation

void* fl::Pointer::memory
 

Pointer to block in heap. Must cast as needed.

int fl::Pointer::metaData
 

metaData < 0 indicates memory is a special pointer we constructed. There is meta data associated with the pointer, and all "smart" pointer functions are available. This is the only time that we can (and must) delete memory. metaData == 0 indicates either memory == 0 or we don't know how big the block is. metaData > 0 indicates the actual size of the block, and that we don't own it.


The documentation for this class was generated from the following file:
Generated on Thu Dec 9 17:13:26 2004 for fl by doxygen1.2.18