#include <datablock.h>
Collaboration diagram for datablock< T >:
Public Member Functions | |
itype | Size () const |
Returns the size of the datablock. | |
itype | CountRefs () |
Returns the current number of views linked to this block. | |
itype | AddRef () |
Informs the datablock that another view is linking to it. Returns new reference count. | |
itype | RemoveRef () |
Informs the datablock that a view is not linked to it anymore. Returns new reference count. | |
itype | Resize (itype newsize) |
Changes the size of the block; returns the new size. | |
void | CopyFrom (T *ptr) |
Copy size elements of data from a pointer. Use with caution! | |
void | CopyFrom (T *ptr, itype max_items) |
Copy MIN(max_items ,size ) elements of data from a pointer. Safer than CopyFrom( T *ptr ). | |
void | CopyFrom (datablock< T > &other) |
Copy data from another datablock. Safest and recommended. | |
datablock () | |
Construct a datablock of size zero. | |
datablock (itype s) | |
Construct a datablock of size s . | |
datablock (const datablock< T > &other) | |
Construct a datablock as a copy of other . | |
datablock (const datablock< T > &other, itype s) | |
Construct a datablock as a copy of other , but up- or down-sizing to size s . | |
~datablock () | |
Destroy the datablock, returning its memory to the heap. | |
Public Attributes | |
T * | data |
A pointer to the array of T's. |
Datablocks do the dirty work of holding the contents of Vectors and Matrices. They can be resized nondestructively (of course, reducing the size will lose some data!), and keep track of references. A dataview<T> may therefore link to a datablock without worrying about memory management; as long as the view informs the block that it is linking to it or disconnecting, the datablock will delete itself when appropriate.
|
Changes the size of the block; returns the new size. < When the datablock hits zero references, it will delete itself |
|
Copy < If the new size is the same as the old, nothing is done. Otherwise, a new chunk of memory is allocated, and initialized to zero. As much of the old data as will fit is then copied to the new block, and the old memory is deallocated. |