casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
casacore::BlockTrace Class Reference

simple 1-D array More...

#include <Block.h>

Inheritance diagram for casacore::BlockTrace:
casacore::Block< Bool > casacore::Block< casacore::Array< T > > casacore::Block< casacore::CountedPtr< casacore::BaseCompare > > casacore::Block< casacore::IPosition > casacore::Block< casacore::LatticeExprNode > casacore::Block< casacore::LoggerHolder > casacore::Block< casacore::MeasurementSet > casacore::Block< casacore::MeasValue * > casacore::Block< casacore::MSTableIndex > casacore::Block< casacore::RecordFieldPtr< Bool > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< Bool > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< casacore::String > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< Complex > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< DComplex > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< Double > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< Float > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< Int > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< Short > > > casacore::Block< casacore::RecordFieldPtr< casacore::Array< uChar > > > casacore::Block< casacore::RecordFieldPtr< casacore::String > > casacore::Block< casacore::RecordFieldPtr< Complex > > casacore::Block< casacore::RecordFieldPtr< DComplex > > casacore::Block< casacore::RecordFieldPtr< Double > > casacore::Block< casacore::RecordFieldPtr< Float > > casacore::Block< casacore::RecordFieldPtr< Int > > casacore::Block< casacore::RecordFieldPtr< Short > > casacore::Block< casacore::RecordFieldPtr< uChar > > casacore::Block< casacore::RORecordFieldPtr< Bool > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< Bool > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< casacore::String > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< Complex > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< DComplex > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< Double > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< Float > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< Int > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< Short > > > casacore::Block< casacore::RORecordFieldPtr< casacore::Array< uChar > > > casacore::Block< casacore::RORecordFieldPtr< casacore::String > > casacore::Block< casacore::RORecordFieldPtr< Complex > > casacore::Block< casacore::RORecordFieldPtr< DComplex > > casacore::Block< casacore::RORecordFieldPtr< Double > > casacore::Block< casacore::RORecordFieldPtr< Float > > casacore::Block< casacore::RORecordFieldPtr< Int > > casacore::Block< casacore::RORecordFieldPtr< Short > > casacore::Block< casacore::RORecordFieldPtr< uChar > > casacore::Block< casacore::ROTableRow > casacore::Block< casacore::String > casacore::Block< casacore::Table > casacore::Block< casacore::TableExprNode > casacore::Block< casacore::TableRecord > casacore::Block< casacore::Vector< Bool > > casacore::Block< casacore::Vector< casacore::String > > casacore::Block< casacore::Vector< T > > casacore::Block< Domain > casacore::Block< Double > casacore::Block< Int > casacore::Block< Int64 > casacore::Block< Range > casacore::Block< rownr_t > casacore::Block< S > casacore::Block< typename casacore::NumericTraits< FType >::ConjugateType > casacore::Block< uInt > casacore::Block< void * > casacore::Block< T >

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

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< casacore::String >::traceAlloc().

static void casacore::BlockTrace::doTraceFree ( const void *  addr,
size_t  nelem,
DataType  type,
size_t  sz 
)
staticprotected
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

size_t casacore::BlockTrace::itsTraceSize
staticprotected

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