casacore
Loading...
Searching...
No Matches
RegionHandlerMemory.h
Go to the documentation of this file.
1// # RegionHandlerMemory.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_REGIONHANDLERMEMORY_H
27#define IMAGES_REGIONHANDLERMEMORY_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Regions/RegionHandler.h>
32#include <casacore/casa/BasicSL/String.h>
33#include <map>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Class for keeping regions in memory.
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="" date="" tests="tPagedImage2.cc" demos="">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class=PagedImage>PagedImage</linkto>
48// <li> <linkto class=ImageRegion>ImageRegion</linkto>
49// </prerequisite>
50
51// <synopsis>
52// Persistent regions are stored as subrecords of the table keywords
53// "regions" and "masks". The user can choose one of both keywords.
54// Keyword "masks" is meant for true image masks, i.e. telling for
55// each pixel if it is good or bad. Keyword "regions" is meant for
56// true regions in an image.
57// <p>
58// This class handles defining, getting and removing such regions.
59// It is used by class <linkto class=PagedImage</linkto>, but it can also
60// be used by other code to handle regions in other tables.
61// <p>
62// Another function performed by this class for PagedImage is the
63// definition of the default region to be used with an image.
64// <p>
65// The class consists of static functions only.
66// </synopsis>
67
68// <example>
69// </example>
70
71// <motivation>
72// This class has 2 purposes:
73// <ol>
74// <li> This untemplated code can be factored out from the templated
75// Image classes.
76// <li> The functions can easily be used by other code.
77// </ol>
78// </motivation>
79
80// # <todo asof="1999/02/16">
81// # <li>
82// # </todo>
83
85 public:
87
88 // Copy constructor (copy semantics).
90
92
93 // Assignment (copy semantics).
95
96 // Make a copy of the object.
97 virtual RegionHandlerMemory* clone() const;
98
99 // This class can define and handle regions.
100 virtual Bool canDefineRegion() const;
101
102 // Set the default mask to the mask with the given name.
103 // If the given maskName is the empty string, the default mask is unset.
104 virtual void setDefaultMask(const String& maskName);
105
106 // Get the name of the default mask.
107 // An empty string is returned if no default mask.
108 virtual String getDefaultMask() const;
109
110 // Define a region.
111 // The group type determines if it is kept as a region or a mask.
112 // If overwrite=False, an exception will be thrown if the region
113 // already exists in the "regions" or "masks" group.
114 // Otherwise the region will be removed first.
115 // <br>It always returns a True status.
117 Bool overwrite = False);
118
119 // Is there a region with the given name?
121
122 // Get a region with the given name from the given group.
123 // A zero pointer is returned if the region does not exist.
124 // The caller has to delete the <src>ImageRegion</src> object created.
125 // <br>No exception is thrown if the region does not exist.
127 Bool throwIfUnknown = True) const;
128
129 // Rename a region.
130 // If a region with the new name already exists, it is deleted or
131 // an exception is thrown (depending on <src>overwrite</src>).
132 // The region name is looked up in the given group(s).
133 // <br>An exception is thrown if the old region name does not exist.
134 // <br>It always returns a True status.
135 virtual Bool renameRegion(const String& newName, const String& oldName,
136 RegionHandler::GroupType = Any, Bool overwrite = False);
137
138 // Remove a region from the given group.
139 // <br>Optionally an exception is thrown if the region does not exist.
140 // <br>It always returns a True status.
142 Bool throwIfUnknown = True);
143
144 // Get the names of all regions/masks.
146
147 // Make a mask (an LCMask) for a temporary lattice (a TempImage).
148 // It creates it with the shape and tile shape of the lattice.
149 virtual ImageRegion makeMask(const LatticeBase& lattice, const String& name);
150
151 private:
152 // Find group number of the region group to which a region belongs
153 // (i.e. the field number of the "regions" or "masks" field).
154 // -1 is returned if the region does not exist.
155 // <br>Optionally an exception is thrown if the region does not exist.
157 Bool throwIfUnknown = True) const;
158
159 // Find a region..
160 // It is used by getRegion (which makes a clone of the object).
161 // A zero pointer is returned if the region does not exist.
163 Bool throwIfUnknown = True) const;
164
165 // Remove all regions from the maps.
166 void clear();
167
169 std::map<String, void*> itsMaps[2];
170};
171
172} // namespace casacore
173
174#endif
virtual RegionHandlerMemory * clone() const
Make a copy of the object.
Int findRegionGroup(const String &regionName, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
RegionHandlerMemory & operator=(const RegionHandlerMemory &)
RegionHandlerMemory(const RegionHandlerMemory &)
virtual void setDefaultMask(const String &maskName)
Set the default mask to the mask with the given name.
virtual ImageRegion * findRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
virtual ImageRegion makeMask(const LatticeBase &lattice, const String &name)
Make a mask for a lattice (e.g.
virtual String getDefaultMask() const
Get the name of the default mask.
virtual Bool canDefineRegion() const
Can the class indeed define and handle regions?
virtual Bool renameRegion(const String &newName, const String &oldName, RegionHandler::GroupType=Any, Bool overwrite=False)
Rename a region.
std::map< String, void * > itsMaps[2]
virtual Bool defineRegion(const String &name, const ImageRegion &region, RegionHandler::GroupType, Bool overwrite=False)
Define a region belonging to the table.
virtual ImageRegion * getRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
Get a region belonging to the table.
virtual Bool removeRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True)
Remove 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?
GroupType
Define the possible group types (regions or masks).
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
String name() const
Return the name of the field.
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