casacore
Loading...
Searching...
No Matches
RegionHandlerTable.h
Go to the documentation of this file.
1//# RegionHandlerTable.h: Class for keeping regions in memory
2//# Copyright (C) 2000
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef IMAGES_REGIONHANDLERTABLE_H
27#define IMAGES_REGIONHANDLERTABLE_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/images/Regions/RegionHandler.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward declarations
37class Table;
38
39
40// <summary>
41// Class for keeping regions in memory.
42// </summary>
43
44// <use visibility=local>
45
46// <reviewed reviewer="" date="" tests="tPagedImage2.cc" demos="">
47// </reviewed>
48
49// <prerequisite>
50// <li> <linkto class=PagedImage>PagedImage</linkto>
51// <li> <linkto class=ImageRegion>ImageRegion</linkto>
52// </prerequisite>
53
54// <synopsis>
55// Persistent regions are stored as subrecords of the table keywords
56// "regions" and "masks". The user can choose one of both keywords.
57// Keyword "masks" is meant for true image masks, i.e. telling for
58// each pixel if it is good or bad. Keyword "regions" is meant for
59// true regions in an image.
60// <p>
61// This class handles defining, getting and removing such regions.
62// It is used by class <linkto class=PagedImage</linkto>, but it can also
63// be used by other code to handle regions in other tables.
64// <p>
65// Another function performed by this class for PagedImage is the
66// definition of the default region to be used with an image.
67// </synopsis>
68
69// <example>
70// </example>
71
72// <motivation>
73// This class has 2 purposes:
74// <ol>
75// <li> This untemplated code can be factored out from the templated
76// Image classes.
77// <li> The functions can easily be used by other code.
78// </ol>
79// </motivation>
80
81//# <todo asof="1999/02/16">
82//# <li>
83//# </todo>
84
85
87{
88public:
89 // Define the signature of the function being called to get
90 // the table object needed for the region operations.
91 typedef Table& GetCallback (void* objectPtr, Bool writable);
92
93 RegionHandlerTable (GetCallback* callback, void* objectPtr);
94
95 // Copy constructor (copy semantics).
97
99
100 // Assignment (copy semantics).
102
103 // Make a copy of the object.
104 virtual RegionHandlerTable* clone() const;
105
106 // Set the object pointer for callback function.
107 virtual void setObjectPtr (void* objectPtr);
108
109 // This class can define and handle regions.
110 virtual Bool canDefineRegion() const;
111
112 // Set the default mask to the mask with the given name.
113 // It constructs a ImageRegion object for the new default mask.
114 // If the table is writable, the setting is persistent by writing
115 // the name as a keyword.
116 // If the given maskName is the empty string, the default mask is unset.
117 virtual void setDefaultMask (const String& maskName);
118
119 // Get the name of the default mask.
120 // An empty string is returned if no default mask.
121 virtual String getDefaultMask() const;
122
123 // Define a region belonging to the table.
124 // The group type determines if it stored as a region or mask.
125 // If overwrite=False, an exception will be thrown if the region
126 // already exists in the "regions" or "masks" keyword.
127 // Otherwise the region will be removed first.
128 // <br>A False status is returned if the table is not writable
129 virtual Bool defineRegion (const String& name,
130 const ImageRegion& region,
132 Bool overwrite = False);
133
134 // Does the table have a region with the given name?
135 virtual Bool hasRegion (const String& name,
137
138 // Get a region belonging to the table.
139 // A zero pointer is returned if the region does not exist.
140 // The caller has to delete the <src>ImageRegion</src> object created.
141 // <br>No exception is thrown if the region does not exist.
142 virtual ImageRegion* getRegion (const String& name,
144 Bool throwIfUnknown = True) const;
145
146 // Rename a region.
147 // If a region with the new name already exists, it is deleted or
148 // an exception is thrown (depending on <src>overwrite</src>).
149 // The region name is looked up in the given group(s).
150 // <br>An exception is thrown if the old region name does not exist.
151 virtual Bool renameRegion (const String& newName,
152 const String& oldName,
154 Bool overwrite = False);
155
156 // Remove a region belonging to the table.
157 // <br>Optionally an exception is thrown if the region does not exist.
158 // <br>A False status is returned if the table is not writable
159 virtual Bool removeRegion (const String& name,
161 Bool throwIfUnknown = True);
162
163 // Get the names of all regions/masks.
165
166 // Make a mask (an LCPagedMask) for a stored lattice (a PagedImage).
167 // It creates it with the shape and tile shape of the lattice.
168 virtual ImageRegion makeMask (const LatticeBase& lattice,
169 const String& name);
170
171private:
172 // Get the table object.
173 // <group>
176 const Table& table() const
177 { return itsCallback (const_cast<RegionHandlerTable*>(this)->itsObjectPtr,
178 False); }
179 // </group>
180
181 // Find field number of the region group to which a region belongs
182 // (i.e. the field number of the "regions" or "masks" field).
183 // <0 is returned if the region does not exist.
184 // <br>Optionally an exception is thrown if the region does not exist.
185 virtual Int findRegionGroup (const String& regionName,
187 Bool throwIfUnknown = True) const;
188
189
192};
193
194
195
196
197} //# NAMESPACE CASACORE - END
198
199#endif
virtual Bool renameRegion(const String &newName, const String &oldName, RegionHandler::GroupType=Any, Bool overwrite=False)
Rename a region.
virtual void setDefaultMask(const String &maskName)
Set the default mask to the mask with the given name.
virtual ImageRegion * getRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
Get a region belonging to the table.
RegionHandlerTable(GetCallback *callback, void *objectPtr)
virtual void setObjectPtr(void *objectPtr)
Set the object pointer (for RegionHandlerTable's callback).
virtual RegionHandlerTable * clone() const
Make a copy of the object.
virtual Int findRegionGroup(const String &regionName, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
virtual String getDefaultMask() const
Get the name of the default mask.
virtual Bool canDefineRegion() const
Can the class indeed define and handle regions? The default implementation returns False.
RegionHandlerTable & operator=(const RegionHandlerTable &)
RegionHandlerTable(const RegionHandlerTable &)
virtual Bool removeRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True)
Remove a region belonging to the table.
virtual Bool defineRegion(const String &name, const ImageRegion &region, RegionHandler::GroupType, Bool overwrite=False)
Define a region belonging to the table.
virtual Vector< String > regionNames(RegionHandler::GroupType=Any) const
Get the names of all regions/masks.
virtual Bool hasRegion(const String &name, RegionHandler::GroupType=RegionHandler::Any) const
Does the table have a region with the given name?
virtual ImageRegion makeMask(const LatticeBase &lattice, const String &name)
Make a mask for a lattice (e.g.
Table & GetCallback(void *objectPtr, Bool writable)
GroupType
Define the possible group types (regions or masks).
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41