casacore
Loading...
Searching...
No Matches
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: 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_IMAGEOPENER_H
27#define IMAGES_IMAGEOPENER_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/images/Images/MaskSpecifier.h>
31#include <casacore/casa/Containers/Block.h>
32#include <map>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37class LatticeBase;
38class LatticeExprNode;
39class JsonKVMap;
40
41// <summary>
42// Definition of image types and handlers
43// </summary>
44//
45// <use visibility=local>
46//
47// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
48// </reviewed>
49//
50// <synopsis>
51// The class contains defines the possible image types.
52// It contains a registry containing functions to construct an image
53// based on its type. In this way any image can be used in the image package
54// without the need that the code must reside in the images package.
55// </synopsis>
56//
57// <motivation>
58// FITS and MIRIAD needed to be moved out of the images package.
59// </motivation>
60
62 public:
63 // Define the possible image types.
65 // Casacore (former AIPS++)
67 // FITS
69 // Miriad
71 // Gipsy
73 // Classic AIPS
75 // Newstar
77 // HDF5
79 // ImageConcat
81 // ImageExpr
83 // ComponentListImage, CASA
85 // Unknown
87 };
88
89 // Return the type of an image with the given name. Will throw an
90 // exception if file does not exist.
91 static ImageTypes imageType(const String& fileName);
92
93 // Define the signature of a function opening an image.
94 // Each basic image class (like FITSImage) must have a static open function
95 // with this signature.
96 // They can be registered using registerOpenImageFunction.
97 // In this way a function like openImage can create any image object
98 // without the need that all image classes are in the images package.
99 // The LogIO object can be used for possible error reporting or logging.
100 typedef LatticeBase* OpenImageFunction(const String& fileName, const MaskSpecifier&);
101
102 // Register an openImageFunction.
104
105 // Open an image in the file/table with the given name.
106 // The specified mask will be applied (default is default mask).
107 // A null pointer is returned for an unknown image type.
108 // Non-Casacore image types must have been registered to be known.
109 // Note that class ImageProxy has a function to open an image from a file
110 // or from an image expression.
111 static LatticeBase* openImage(const String& fileName, const MaskSpecifier& = MaskSpecifier());
112
113 // Open a Casacore paged image of any data type.
114 static LatticeBase* openPagedImage(const String& fileName,
115 const MaskSpecifier& = MaskSpecifier());
116
117 // Open an HDF5 paged image of any data type.
118 static LatticeBase* openHDF5Image(const String& fileName, const MaskSpecifier& = MaskSpecifier());
119
120 // Open a persistent image concatenation of any type.
121 static LatticeBase* openImageConcat(const String& fileName);
122
123 // Open a persistent image expression of any type.
124 // It reads the file written by ImageExpr::save.
125 static LatticeBase* openImageExpr(const String& fileName);
126
127 // Parse an image expression and return the ImageExpr<T> object for it.
128 // The block of nodes represents optional $i arguments in the expression.
129 // The JsonKVMap gives the keys found in a persistent image.expr file.
130 static LatticeBase* openExpr(const String& expr, const Block<LatticeExprNode>& nodes,
131 const String& fileName = String());
132 static LatticeBase* openExpr(const String& expr, const Block<LatticeExprNode>& nodes,
133 const String& fileName, const JsonKVMap&);
134
135 private:
136 // Mapping of the image type to an openImage function.
137 static std::map<ImageTypes, OpenImageFunction*> theirOpenFuncMap;
138};
139
140} // namespace casacore
141
142#endif
static LatticeBase * openExpr(const String &expr, const Block< LatticeExprNode > &nodes, const String &fileName, const JsonKVMap &)
static LatticeBase * openHDF5Image(const String &fileName, const MaskSpecifier &=MaskSpecifier())
Open an HDF5 paged image of any data type.
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 * openImageExpr(const String &fileName)
Open a persistent image expression of any type.
static LatticeBase * openImage(const String &fileName, const MaskSpecifier &=MaskSpecifier())
Open an image in the file/table with the given name.
static std::map< ImageTypes, OpenImageFunction * > theirOpenFuncMap
Mapping of the image type to an openImage function.
static LatticeBase * openImageConcat(const String &fileName)
Open a persistent image concatenation of any type.
static ImageTypes imageType(const String &fileName)
Return the type of an image with the given name.
LatticeBase * OpenImageFunction(const String &fileName, const MaskSpecifier &)
Define the signature of a function opening an image.
static LatticeBase * openPagedImage(const String &fileName, const MaskSpecifier &=MaskSpecifier())
Open a Casacore paged image of any data type.
ImageTypes
Define the possible image types.
Definition ImageOpener.h:64
@ AIPSPP
Casacore (former AIPS++).
Definition ImageOpener.h:66
@ IMAGECONCAT
ImageConcat.
Definition ImageOpener.h:80
@ CAIPS
Classic AIPS.
Definition ImageOpener.h:74
@ IMAGEEXPR
ImageExpr.
Definition ImageOpener.h:82
@ COMPLISTIMAGE
ComponentListImage, CASA.
Definition ImageOpener.h:84
static void registerOpenImageFunction(ImageTypes, OpenImageFunction *)
Register an openImageFunction.
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