casacore
ImageOpener.h
Go to the documentation of this file.
1 //# ImageOpener.h: A class with static functions to open an image of any type
2 //# Copyright (C) 2005
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 //#
27 //# $Id$
28 
29 #ifndef IMAGES_IMAGEOPENER_H
30 #define IMAGES_IMAGEOPENER_H
31 
32 
33 #include <casacore/casa/aips.h>
34 #include <casacore/images/Images/MaskSpecifier.h>
35 #include <casacore/casa/Containers/SimOrdMap.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class LatticeBase;
41 class LatticeExprNode;
42 class JsonKVMap;
43 
44 // <summary>
45 // Definition of image types and handlers
46 // </summary>
47 //
48 // <use visibility=local>
49 //
50 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
51 // </reviewed>
52 //
53 // <synopsis>
54 // The class contains defines the possible image types.
55 // It contains a registry containing functions to construct an image
56 // based on its type. In this way any image can be used in the image package
57 // without the need that the code must reside in the images package.
58 // </synopsis>
59 //
60 // <motivation>
61 // FITS and MIRIAD needed to be moved out of the images package.
62 // </motivation>
63 
64 
66 {
67 public:
68 // Define the possible image types.
69  enum ImageTypes {
70  // Casacore (former AIPS++)
72  // FITS
74  // Miriad
76  // Gipsy
78  // Classic AIPS
80  // Newstar
82  // HDF5
84  // ImageConcat
86  // ImageExpr
88  // ComponentListImage, CASA
90  // Unknown
92  };
93 
94  // Return the type of an image with the given name. Will throw an
95  // exception if file does not exist.
96  static ImageTypes imageType (const String& fileName);
97 
98  // Define the signature of a function opening an image.
99  // Each basic image class (like FITSImage) must have a static open function
100  // with this signature.
101  // They can be registered using registerOpenImageFunction.
102  // In this way a function like openImage can create any image object
103  // without the need that all image classes are in the images package.
104  // The LogIO object can be used for possible error reporting or logging.
105  typedef LatticeBase* OpenImageFunction (const String& fileName,
106  const MaskSpecifier&);
107 
108  // Register an openImageFunction.
110 
111  // Open an image in the file/table with the given name.
112  // The specified mask will be applied (default is default mask).
113  // A null pointer is returned for an unknown image type.
114  // Non-Casacore image types must have been registered to be known.
115  // Note that class ImageProxy has a function to open an image from a file
116  // or from an image expression.
117  static LatticeBase* openImage (const String& fileName,
118  const MaskSpecifier& = MaskSpecifier());
119 
120  // Open a Casacore paged image of any data type.
121  static LatticeBase* openPagedImage (const String& fileName,
122  const MaskSpecifier& = MaskSpecifier());
123 
124  // Open an HDF5 paged image of any data type.
125  static LatticeBase* openHDF5Image (const String& fileName,
126  const MaskSpecifier& = MaskSpecifier());
127 
128  // Open a persistent image concatenation of any type.
129  static LatticeBase* openImageConcat (const String& fileName);
130 
131  // Open a persistent image expression of any type.
132  // It reads the file written by ImageExpr::save.
133  static LatticeBase* openImageExpr (const String& fileName);
134 
135  // Parse an image expression and return the ImageExpr<T> object for it.
136  // The block of nodes represents optional $i arguments in the expression.
137  // The JsonKVMap gives the keys found in a persistent image.expr file.
138  static LatticeBase* openExpr (const String& expr,
139  const Block<LatticeExprNode>& nodes,
140  const String& fileName = String());
141  static LatticeBase* openExpr (const String& expr,
142  const Block<LatticeExprNode>& nodes,
143  const String& fileName,
144  const JsonKVMap&);
145 
146 private:
147  // The default openImage function for an unknown image type.
148  // It returns a null pointer.
149  static LatticeBase* unknownImageOpen (const String& name,
150  const MaskSpecifier&);
151 
152  // Mapping of the image type to an openImage function.
154 };
155 
156 
157 } //# NAMESPACE CASACORE - END
158 
159 #endif
LatticeBase * OpenImageFunction(const String &fileName, const MaskSpecifier &)
Define the signature of a function opening an image.
Definition: ImageOpener.h:105
static LatticeBase * openImage(const String &fileName, const MaskSpecifier &=MaskSpecifier())
Open an image in the file/table with the given name.
static ImageTypes imageType(const String &fileName)
Return the type of an image with the given name.
static LatticeBase * openExpr(const String &expr, const Block< LatticeExprNode > &nodes, const String &fileName=String())
Parse an image expression and return the ImageExpr<T> object for it.
static LatticeBase * openImageConcat(const String &fileName)
Open a persistent image concatenation of any type.
A non-templated, abstract base class for array-like objects.
Definition: LatticeBase.h:80
ComponentListImage, CASA.
Definition: ImageOpener.h:89
static LatticeBase * unknownImageOpen(const String &name, const MaskSpecifier &)
The default openImage function for an unknown image type.
Simple map with keys ordered.
Definition: SimOrdMap.h:69
Class to specify which mask to use in an image.
Definition: MaskSpecifier.h:69
Class to hold a collection of JSON key:value pairs.
Definition: JsonKVMap.h:72
ImageTypes
Define the possible image types.
Definition: ImageOpener.h:69
Definition of image types and handlers.
Definition: ImageOpener.h:65
static void registerOpenImageFunction(ImageTypes, OpenImageFunction *)
Register an openImageFunction.
simple 1-D array
Definition: ArrayIO.h:47
Casacore (former AIPS++)
Definition: ImageOpener.h:71
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static LatticeBase * openHDF5Image(const String &fileName, const MaskSpecifier &=MaskSpecifier())
Open an HDF5 paged image of any data type.
static LatticeBase * openImageExpr(const String &fileName)
Open a persistent image expression of any type.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
static LatticeBase * openPagedImage(const String &fileName, const MaskSpecifier &=MaskSpecifier())
Open a Casacore paged image of any data type.
static SimpleOrderedMap< ImageTypes, OpenImageFunction * > theirOpenFuncMap
Mapping of the image type to an openImage function.
Definition: ImageOpener.h:153