RegionHandlerMemory.h

Classes

RegionHandlerMemory -- Class for keeping regions in memory. (full description)

class RegionHandlerMemory: public RegionHandler

Interface

Public Members
RegionHandlerMemory()
RegionHandlerMemory (const RegionHandlerMemory&)
virtual ~RegionHandlerMemory()
RegionHandlerMemory& operator= (const RegionHandlerMemory&)
virtual RegionHandlerMemory* clone() const
virtual Bool canDefineRegion() const
virtual void setDefaultMask (const String& maskName)
virtual String getDefaultMask() const
virtual Bool defineRegion (const String& name, const ImageRegion& region, RegionHandler::GroupType, Bool overwrite = False)
virtual Bool hasRegion (const String& name, RegionHandler::GroupType = RegionHandler::Any) const
virtual ImageRegion* getRegion (const String& name, RegionHandler::GroupType = Any, Bool throwIfUnknown = True) const
virtual Bool renameRegion (const String& newName, const String& oldName, RegionHandler::GroupType = Any, Bool overwrite = False)
virtual Bool removeRegion (const String& name, RegionHandler::GroupType = Any, Bool throwIfUnknown = True)
virtual Vector<String> regionNames (RegionHandler::GroupType = Any) const
virtual ImageRegion makeMask (const LatticeBase& lattice, const String& name)
Private Members
Int findRegionGroup (const String& regionName, RegionHandler::GroupType = Any, Bool throwIfUnknown = True) const
virtual ImageRegion* findRegion (const String& name, RegionHandler::GroupType = Any, Bool throwIfUnknown = True) const
void clear()

Description

Review Status

Programs:
Tests:

Prerequisite

Synopsis

Persistent regions are stored as subrecords of the table keywords "regions" and "masks". The user can choose one of both keywords. Keyword "masks" is meant for true image masks, i.e. telling for each pixel if it is good or bad. Keyword "regions" is meant for true regions in an image.

This class handles defining, getting and removing such regions. It is used by class , but it can also be used by other code to handle regions in other tables.

Another function performed by this class for PagedImage is the definition of the default region to be used with an image.

The class consists of static functions only.

Example

Motivation

This class has 2 purposes:
  1. This untemplated code can be factored out from the templated Image classes.
  2. The functions can easily be used by other code.

Member Description

RegionHandlerMemory()

RegionHandlerMemory (const RegionHandlerMemory&)

Copy constructor (copy semantics).

virtual ~RegionHandlerMemory()

RegionHandlerMemory& operator= (const RegionHandlerMemory&)

Assignment (copy semantics).

virtual RegionHandlerMemory* clone() const

Make a copy of the object.

virtual Bool canDefineRegion() const

This class can define and handle regions.

virtual void setDefaultMask (const String& maskName)

Set the default mask to the mask with the given name. If the given maskName is the empty string, the default mask is unset.

virtual String getDefaultMask() const

Get the name of the default mask. An empty string is returned if no default mask.

virtual Bool defineRegion (const String& name, const ImageRegion& region, RegionHandler::GroupType, Bool overwrite = False)

Define a region. The group type determines if it is kept as a region or a mask. If overwrite=False, an exception will be thrown if the region already exists in the "regions" or "masks" group. Otherwise the region will be removed first.
It always returns a True status.

virtual Bool hasRegion (const String& name, RegionHandler::GroupType = RegionHandler::Any) const

Is there a region with the given name?

virtual ImageRegion* getRegion (const String& name, RegionHandler::GroupType = Any, Bool throwIfUnknown = True) const

Get a region with the given name from the given group. A zero pointer is returned if the region does not exist. The caller has to delete the ImageRegion object created.
No exception is thrown if the region does not exist.

virtual Bool renameRegion (const String& newName, const String& oldName, RegionHandler::GroupType = Any, Bool overwrite = False)

Rename a region. If a region with the new name already exists, it is deleted or an exception is thrown (depending on overwrite). The region name is looked up in the given group(s).
An exception is thrown if the old region name does not exist.
It always returns a True status.

virtual Bool removeRegion (const String& name, RegionHandler::GroupType = Any, Bool throwIfUnknown = True)

Remove a region from the given group.
Optionally an exception is thrown if the region does not exist.
It always returns a True status.

virtual Vector<String> regionNames (RegionHandler::GroupType = Any) const

Get the names of all regions/masks.

virtual ImageRegion makeMask (const LatticeBase& lattice, const String& name)

Make a mask (an LCMask) for a temporary lattice (a TempImage). It creates it with the shape and tile shape of the lattice.

Int findRegionGroup (const String& regionName, RegionHandler::GroupType = Any, Bool throwIfUnknown = True) const

Find group number of the region group to which a region belongs (i.e. the field number of the "regions" or "masks" field). -1 is returned if the region does not exist.
Optionally an exception is thrown if the region does not exist.

virtual ImageRegion* findRegion (const String& name, RegionHandler::GroupType = Any, Bool throwIfUnknown = True) const

Find a region.. It is used by getRegion (which makes a clone of the object). A zero pointer is returned if the region does not exist.

void clear()

Remove all regions from the maps.