LatticeBase.h

Classes

LatticeBase -- A non-templated, abstract base class for array-like objects. (full description)

class LatticeBase

Interface

Public Members
virtual ~LatticeBase()
virtual LatticeBase* clone() const = 0
virtual Bool isPersistent() const
virtual Bool isPaged() const
virtual Bool canReferenceArray() const
virtual Bool isWritable() const
virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const
virtual void resync()
virtual void flush()
virtual void tempClose()
virtual void reopen()
virtual String name (Bool stripPath=False) const
virtual IPosition shape() const = 0
virtual uInt ndim() const
virtual uInt nelements() const
Bool conform (const LatticeBase& other) const
virtual LELCoordinates lelCoordinates() const
virtual uInt advisedMaxPixels() const = 0
IPosition niceCursorShape (uInt maxPixels) const
IPosition niceCursorShape() const
virtual Bool ok() const
virtual IPosition doNiceCursorShape (uInt maxPixels) const
virtual uInt maximumCacheSize() const
virtual void setMaximumCacheSize (uInt howManyPixels)
virtual void setCacheSizeInTiles (uInt howManyTiles)
virtual void setCacheSizeFromPath (const IPosition& sliceShape, const IPosition& windowStart, const IPosition& windowLength, const IPosition& axisPath)
virtual void clearCache()
virtual void showCacheStatistics (ostream& os) const
Protected Members
LatticeBase()
LatticeBase (const LatticeBase&)
LatticeBase& operator= (const LatticeBase&)
void throwBoolMath() const

Description

Review Status

Reviewed By:
Bob Garwood
Date Reviewed:
2000/01/18
Programs:
Demos:
Tests:

Synopsis

This pure abstract base class defines the operations which may be performed on a lattice of any type.
See class Lattice for a detailed description of a lattice.

Motivation

It is very useful to be able to keep a pointer to a non-templated base class. Furthermore it gives the opportunity to factor out some non-templated code.

The cache functions (maximumCacheSize, setMaximumCacheSize, setCacheSizeInTiles, setCacheSizeFromPath, clearCache, and showCacheStatistics) should all be over-ridden together as in PagedArray.

Member Description

virtual ~LatticeBase()

A virtual destructor is needed so that it will use the actual destructor in the derived class.

virtual LatticeBase* clone() const = 0

Make a copy of the derived object (reference semantics).

virtual Bool isPersistent() const

Is the lattice persistent and can it be loaded by other processes as well? That is the case for a PagedArray or PagedImage and for an ImageExpr which does not use transient lattices or regions.
The default implementation returns False.

virtual Bool isPaged() const

Is the lattice paged to disk?
The default implementation returns False.

virtual Bool canReferenceArray() const

Can the lattice data be referenced as an array section? That is the case for an ArrayLattice or a Temp/SubLattice using it. It is used by LatticeIterInterface.
The default implementation returns False.

virtual Bool isWritable() const

Is the lattice writable?
The default implementation returns True.

virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const

It is strongly recommended to use class LatticeLocker to handle lattice locking. It also contains a more detailed explanation of the locking process.
By default the functions do not do anything at all. lock() and hasLock return True, which is suitable for all non-paged lattices.

virtual void resync()

Resynchronize the Lattice object with the lattice file. This function is only useful if no read-locking is used, ie. if the table lock option is UserNoReadLocking or AutoNoReadLocking. In that cases the table system does not acquire a read-lock, thus does not synchronize itself automatically.
By default the function does not do anything at all.

virtual void flush()

Flush the data (but do not unlock).
By default the function does not do anything at all.

virtual void tempClose()

Temporarily close the lattice. It will be reopened automatically on the next access.
By default the function does not do anything at all.

virtual void reopen()

Explicitly reopen the temporarily closed lattice.
By default the function does not do anything at all.

virtual String name (Bool stripPath=False) const

Return the name of the current Lattice object. This will generally be a file name for lattices that have a persistent form. Any path before the actual file name can be optionally stripped off.
The default implementation returns an empty string.

virtual IPosition shape() const = 0

Return the shape of the Lattice including all degenerate axes (ie. axes with a length of one)

virtual uInt ndim() const

Return the number of axes in this Lattice. This includes all degenerate axes.
The default implementation returns shape().nelements().

virtual uInt nelements() const

Return the total number of elements in this Lattice.
The default implementation returns shape().product().

Bool conform (const LatticeBase& other) const

Return a value of "True" if this instance of Lattice and 'other' have the same shape, otherwise returns a value of "False".

virtual LELCoordinates lelCoordinates() const

Return the coordinates of the lattice.
The default implementation returns an 'empty' LELLattCoord object.

virtual uInt advisedMaxPixels() const = 0

This function returns the recommended maximum number of pixels to include in the cursor of an iterator. The Lattice class has a default implementation which returns a number that is a power of two and includes enough pixels to consume between 4 and 8 MBytes of memory.

IPosition niceCursorShape (uInt maxPixels) const
IPosition niceCursorShape() const

Returns a recommended cursor shape for iterating through all the pixels in the Lattice. The default implementation sets up a shape that completely fills as many axes as possible, but always at least the first axis. For example, given a 10x20x30 Lattice

    maxPixels = 1     --> niceCursorShape = [10,1,1]
                100   --> niceCursorShape = [10,1,1]
                300   --> niceCursorShape = [10,20,1] 
                10000 --> niceCursorShape = [10,20,30] 
    
The default argument is the result of advisedMaxPixels().

virtual Bool ok() const

Check class internals - used for debugging. Should always return True

virtual IPosition doNiceCursorShape (uInt maxPixels) const

The function (in the derived classes) doing the actual work. This function is public, so it can be used internally in the various Lattice classes.
The default implementation tries to fit as many axes as possible given maxPixels.

virtual uInt maximumCacheSize() const

Maximum cache size - not necessarily all used. In pixels. Default returns 0, which means that there is no maximum.

virtual void setMaximumCacheSize (uInt howManyPixels)

Set the maximum (allowed) cache size as indicated.
The default implementation does nothing.

virtual void setCacheSizeInTiles (uInt howManyTiles)

Set the actual cache size for this Array to be big enough for the indicated number of tiles. This cache is not shared with PagedArrays in other rows and is always clipped to be less than the maximum value set using the setMaximumCacheSize member function. Tiles are cached using a first in first out algorithm.
The default implementation does nothing.

virtual void setCacheSizeFromPath (const IPosition& sliceShape, const IPosition& windowStart, const IPosition& windowLength, const IPosition& axisPath)

Set the cache size as to "fit" the indicated path.
The default implementation does nothing.

virtual void clearCache()

Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSize was called.
The default implementation does nothing.

virtual void showCacheStatistics (ostream& os) const

Report on cache success.
The default implementation does nothing.

LatticeBase()

Define default constructor to be used by derived classes.

LatticeBase (const LatticeBase&)
LatticeBase& operator= (const LatticeBase&)

Copy constructor and assignment can only be used by derived classes.

void throwBoolMath() const

Throw an exception for arithmetic on a Bool Lattice.