casacore
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
casacore::BlockTrace Class Reference

More...

#include <Block.h>

Static Public Member Functions

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

Static Protected Member Functions

static void doTraceAlloc (const void *addr, size_t nelem, DataType type, size_t sz)
 Write alloc and free trace messages. More...
 
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

Definition at line 107 of file Block.h.

Member Function Documentation

◆ doTraceAlloc()

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

Write alloc and free trace messages.

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

◆ doTraceFree()

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

◆ setTraceSize()

static 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
staticprotected

Definition at line 121 of file Block.h.

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


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