Loading...
Searching...
No Matches
casacore::BlockTrace Class Reference
casa package (libcasa_casa) » Containers_module

More...

`#include <Block.h>`

## Static Public Member Functions

static void | setTraceSize (size_t sz)
| Set the trace size.

## Static Protected Member Functions

static void | doTraceAlloc (const void *addr, size_t nelem, DataType type, size_t sz)
| Write alloc and free trace messages.
static void | doTraceFree (const void *addr, size_t nelem, DataType type, size_t sz)

## Static Protected Attributes

static size_t | itsTraceSize

## Detailed Description

simple 1-D array

### Intended use:

Public interface

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25

### Etymology

This should be viewed as a block of memory without sophisticated manipulation functions. Thus it is called Block.

### Synopsis

Block<T> is a simple templated 1-D array class. Indices are always 0-based. For efficiency reasons, no index checking is done unless the preprocessor symbol AIPS_ARRAY_INDEX_CHECK is defined. Block<T>'s may be assigned to and constructed from other Block<T>'s. As no reference counting is done this can be an expensive operation, however.

The net effect of this class is meant to be unsurprising to users who think of arrays as first class objects. The name "Block" is intended to convey the concept of a solid "chunk" of things without any intervening "fancy" memory management, etc. This class was written to be used in the implementations of more functional Vector, Matrix, etc. classes, although it is expected Block<T> will be useful on its own.

The Block class should be efficient. You should normally use Block.

Warning: If you use the assignment operator on an element of this class, you may leave dangling references to pointers released from storage(); Resizing the array will also have this effect if the underlying storage is actually affected;

If index checking is turned on, an out-of-bounds index will generate an indexError<uInt> exception.

### Example

Block<Int> a(100,0); // 100 ints initialized to 0
Block<Int> b; // 0-length Block
//..\.
b = a; // resize b and copy a into it
for (size_t i=0; i < a.nelements(); i++) {
a[i] = i; // Generate a sequence
// with Vectors, could simply say "indgen(myVector);"
}
b.set(-1); // All positions in b have the value -1
b.resize(b.nelements()*2); // Make b twice as long, by default the old
// elements are copied over, although this can
// be defeated.
some_c_function(b.storage()); // Use a fn that takes an
// <tt>Int *</tt> pointer
casacore::Block
simple 1-D array
Definition Block.h:198
casacore::Block::storage
T * storage()
If you really, really, need a "raw" pointer to the beginning of the storage area this will give it to...
Definition Block.h:603
casacore::Block::resize
void resize(size_t n, Bool forceSmaller=False, Bool copyElements=True)
Resizes the Block.
Definition Block.h:375
casacore::Block::set
void set(const T &val)
Definition Block.h:585
casacore::Block::nelements
size_t nelements() const
The number of elements contained in this Block<T>.
Definition Block.h:609

Definition at line 105 of file Block.h.

## Member Function Documentation

## doTraceAlloc()

void casacore::BlockTrace::doTraceAlloc | ( | const void * | addr,
|  | size_t | nelem,
|  | DataType | type,
|  | size_t | sz )

static protected

Write alloc and free trace messages.

Referenced by casacore::Block< T >::traceAlloc().

## doTraceFree()

void casacore::BlockTrace::doTraceFree | ( | const void * | addr,
|  | size_t | nelem,
|  | DataType | type,
|  | size_t | sz )

static protected

Referenced by casacore::Block< T >::Array< T >.

## setTraceSize()

void casacore::BlockTrace::setTraceSize | ( | size_t | sz | ) |

static

Set the trace size.

The (de)allocation of Blocks with >= sz elements will be traced using the MemoryTrace class. A value 0 means no tracing.

## Member Data Documentation

## itsTraceSize

size_t casacore::BlockTrace::itsTraceSize

static protected

Definition at line 119 of file Block.h.

Referenced by casacore::Block< T >::Array< T >, and casacore::Block< T >::traceAlloc().

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

- casa/Containers/Block.h