data_block Class Reference

Base class for holding ref-counted arrays of floating-point data. More...

#include <mtx/datablock.h>

Inheritance diagram for data_block:

Inheritance graph
[legend]

List of all members.

Public Member Functions

void incr_refcount ()
 Increment the reference count.
void decr_refcount ()
 Decrement the reference count.
virtual bool is_unique () const =0
 Query if the data block is unique.
const double * data () const
 Get a pointer to const data.
double * data_nc ()
 Get a pointer to non-const data.
unsigned int length () const
 Get the length of the data array.

Static Public Member Functions

static data_blockmake_zeros (int length)
 Return a new shared data_block whose contents are all set to zero.
static data_blockmake_uninitialized (int length)
 Return a new shared data_block whose contents are uninitialized.
static data_blockmake_data_copy (const double *data, int data_length)
 Make a copy of the given data array.
static data_blockmake_borrowed (double *data, int data_length)
 The 'data' are borrowed, but are never considered unique.
static data_blockmake_referred (double *data, int data_length)
 The 'data' are borrowed, as in make_borrowed(), but...
static data_blockmake (double *data, int mrows, int ncols, mtx_policies::storage_policy s)
static data_blockmake (int mrows, int ncols, mtx_policies::init_policy p)
static void make_unique (data_block *&rep)
 Make the given data_block have a unique copy of its data, copying if needed.

Protected Member Functions

 data_block (double *data, unsigned int len)
 Construct with a given data array and length.
virtual ~data_block ()
 Virtual destructor.
void * operator new (size_t bytes)
 Class-specific operator new.
void operator delete (void *space)
 Class-specific operator delete.
int refcount () const
 Get the current reference count.

Protected Attributes

double *const m_storage
 Pointer to the actual storage.
unsigned int const m_length
 Allocated length of the storage.


Detailed Description

Base class for holding ref-counted arrays of floating-point data.

Serves as the implementation for higher-level matrix classes, etc.

Definition at line 54 of file datablock.h.


Constructor & Destructor Documentation

data_block::data_block ( double *  data,
unsigned int  len 
) [protected]

Construct with a given data array and length.

No copy is made of the data array here; the data_block object will point directly to the given array.

Definition at line 130 of file datablock.cc.


Member Function Documentation

data_block * data_block::make_uninitialized ( int  length  )  [static]

Return a new shared data_block whose contents are uninitialized.

I.e. contents not zero-set as in make_zeros().

Definition at line 181 of file datablock.cc.

data_block * data_block::make_borrowed ( double *  data,
int  data_length 
) [static]

The 'data' are borrowed, but are never considered unique.

Therefore, attempts to make_unique() will always duplicate the data.

Definition at line 190 of file datablock.cc.

data_block * data_block::make_referred ( double *  data,
int  data_length 
) [static]

The 'data' are borrowed, as in make_borrowed(), but...

Uniqueness is determined by the reference count, so it is possible to write to the data through the data_block.

Definition at line 196 of file datablock.cc.


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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:54:01 2008 by Doxygen version 1.5.5.