casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef IMAGES_REGIONHANDLERMEMORY_H
29 #define IMAGES_REGIONHANDLERMEMORY_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 #include <map>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
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 // <p>
68 // The class consists of static functions only.
69 // </synopsis>
70 
71 // <example>
72 // </example>
73 
74 // <motivation>
75 // This class has 2 purposes:
76 // <ol>
77 // <li> This untemplated code can be factored out from the templated
78 // Image classes.
79 // <li> The functions can easily be used by other code.
80 // </ol>
81 // </motivation>
82 
83 //# <todo asof="1999/02/16">
84 //# <li>
85 //# </todo>
86 
87 
89 {
90 public:
92 
93  // Copy constructor (copy semantics).
95 
96  virtual ~RegionHandlerMemory();
97 
98  // Assignment (copy semantics).
100 
101  // Make a copy of the object.
102  virtual RegionHandlerMemory* clone() const;
103 
104  // This class can define and handle regions.
105  virtual Bool canDefineRegion() const;
106 
107  // Set the default mask to the mask with the given name.
108  // If the given maskName is the empty string, the default mask is unset.
109  virtual void setDefaultMask (const String& maskName);
110 
111  // Get the name of the default mask.
112  // An empty string is returned if no default mask.
113  virtual String getDefaultMask() const;
114 
115  // Define a region.
116  // The group type determines if it is kept as a region or a mask.
117  // If overwrite=False, an exception will be thrown if the region
118  // already exists in the "regions" or "masks" group.
119  // Otherwise the region will be removed first.
120  // <br>It always returns a True status.
121  virtual Bool defineRegion (const String& name,
122  const ImageRegion& region,
124  Bool overwrite = False);
125 
126  // Is there a region with the given name?
127  virtual Bool hasRegion (const String& name,
129 
130  // Get a region with the given name from the given group.
131  // A zero pointer is returned if the region does not exist.
132  // The caller has to delete the <src>ImageRegion</src> object created.
133  // <br>No exception is thrown if the region does not exist.
134  virtual ImageRegion* getRegion (const String& name,
136  Bool throwIfUnknown = True) const;
137 
138  // Rename a region.
139  // If a region with the new name already exists, it is deleted or
140  // an exception is thrown (depending on <src>overwrite</src>).
141  // The region name is looked up in the given group(s).
142  // <br>An exception is thrown if the old region name does not exist.
143  // <br>It always returns a True status.
144  virtual Bool renameRegion (const String& newName,
145  const String& oldName,
147  Bool overwrite = False);
148 
149  // Remove a region from the given group.
150  // <br>Optionally an exception is thrown if the region does not exist.
151  // <br>It always returns a True status.
152  virtual Bool removeRegion (const String& name,
154  Bool throwIfUnknown = True);
155 
156  // Get the names of all regions/masks.
158 
159  // Make a mask (an LCMask) for a temporary lattice (a TempImage).
160  // It creates it with the shape and tile shape of the lattice.
161  virtual ImageRegion makeMask (const LatticeBase& lattice,
162  const String& name);
163 
164 private:
165  // Find group number of the region group to which a region belongs
166  // (i.e. the field number of the "regions" or "masks" field).
167  // -1 is returned if the region does not exist.
168  // <br>Optionally an exception is thrown if the region does not exist.
169  Int findRegionGroup (const String& regionName,
171  Bool throwIfUnknown = True) const;
172 
173  // Find a region..
174  // It is used by getRegion (which makes a clone of the object).
175  // A zero pointer is returned if the region does not exist.
176  virtual ImageRegion* findRegion (const String& name,
178  Bool throwIfUnknown = True) const;
179 
180  // Remove all regions from the maps.
181  void clear();
182 
183 
185  std::map<String, void*> itsMaps[2];
186 };
187 
188 
189 
190 
191 } //# NAMESPACE CASACORE - END
192 
193 #endif
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
virtual ImageRegion * getRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
Get a region belonging to the table.
virtual Bool hasRegion(const String &name, RegionHandler::GroupType=RegionHandler::Any) const
Does the table have a region with the given name?
RegionHandlerMemory & operator=(const RegionHandlerMemory &)
A non-templated, abstract base class for array-like objects.
Definition: LatticeBase.h:80
virtual Bool removeRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True)
Remove a region belonging to the table.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
virtual String getDefaultMask() const
Get the name of the default mask.
Base class for handling regions in images.
Definition: RegionHandler.h:93
Int findRegionGroup(const String &regionName, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
virtual ImageRegion makeMask(const LatticeBase &lattice, const String &name)
Make a mask for a lattice (e.g.
Class for keeping regions in memory.
virtual Bool defineRegion(const String &name, const ImageRegion &region, RegionHandler::GroupType, Bool overwrite=False)
Define a region belonging to the table.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool renameRegion(const String &newName, const String &oldName, RegionHandler::GroupType=Any, Bool overwrite=False)
Rename a region.
const Bool False
Definition: aipstype.h:44
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
virtual void setDefaultMask(const String &maskName)
Set the default mask to the mask with the given name.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual ImageRegion * findRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
std::map< String, void * > itsMaps[2]
virtual Vector< String > regionNames(RegionHandler::GroupType=Any) const
Get the names of all regions/masks.
const Bool True
Definition: aipstype.h:43
GroupType
Define the possible group types (regions or masks).
Definition: RegionHandler.h:99
virtual Bool canDefineRegion() const
Can the class indeed define and handle regions? The default implementation returns False...
virtual RegionHandlerMemory * clone() const
Make a copy of the object.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42