casacore
Loading...
Searching...
No Matches
ArrayError.h
Go to the documentation of this file.
1//# ArrayError.h: Exception classes thrown by Array and related classes/functions
2//# Copyright (C) 1993,1994,1995,1999,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 CASA_ARRAYERROR_2_H
27#define CASA_ARRAYERROR_2_H
28
29//# Includes
30#include <stdexcept>
31#include <string>
32
33#include "IPosition.h"
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37// <summary> The base class for all Array exception classes. </summary>
38// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
39// </reviewed>
40//
41// ArrayError is the base class for all the Array-specific exception classes,
42// i.e. if it is caught you will catch (through inheritance) all Array-specific
43// exceptions. Note that (presently, anyway) the Array classes will throw
44// a few non-Array exceptions.
45// <srcblock>
46// try {
47// // Some lines, functions, ...
48// } catch (ArrayError x) {
49// // Array specific errors
50// } catch (std::exception x) {
51// // All other errors caught here.
52// }
53// </srcblock>
54//
55//# There are too many Array related error classes. Some should be deleted.
56
57class ArrayError : public std::runtime_error
58{
59public:
60 // Initialize with the message "ArrayError"
62 // Initialize with the supplied message.
63 ArrayError(const char *m);
64 // Initialize with the supplied message.
65 ArrayError(const std::string& m);
66 ~ArrayError() noexcept;
67};
68
69
70// <summary> An error thrown when an index is out of range </summary>
71// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
72// </reviewed>
73//
74// The ArrayIndexError class, which is derived from ArrayError, is intended
75// to be thrown when an index is out-of-bounds. It contains within it
76// the offending index, as well as the shape of the array which
77// is being indexed. This should be multiply-derived from
78// indexError<T> defined in Error.h.
80{
81public:
82 // Initialize with the message "ArrayIndexError".
84 // Initialize with the supplied message, the index and shape are null.
85 ArrayIndexError(const char *m);
86 // Initialize with the supplied message, the index and shape are null.
87 ArrayIndexError(const std::string &m);
88 // Initialize with a given out-of-bounds index, as well as the shape
89 // of the array and a supplied message.
91 const char *m="ArrayIndexError");
92 ~ArrayIndexError() noexcept;
93 // The out-of-bounds index.
94 IPosition index() const;
95 // The shape of the violated array.
97private:
98 //# index, offset, length
100};
101
102
103// <summary> An error thrown when two arrays do not conform </summary>
104// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
105// </reviewed>
106//
107// The ArrayConformanceError class is the base class for all errors thrown
108// because two arrays are not conformant. See also the ArrayShapeError and
109// ArrayNDimError classes which are derived from it. This error, or one derived
110// from it, os normally thrown from a binary operation (arithmetic, logical,
111// assignment, etc).
113{
114public:
115 // Initialize the message with "ArrayConformanceError".
117 // Initialize with a supplied message.
118 ArrayConformanceError(const char *m);
119 // Initialize with a supplied message.
120 ArrayConformanceError(const std::string& m);
122};
123
124
125// <summary> Thrown when two arrays have different dimensionality </summary>
126// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
127// </reviewed>
128//
129// An ArrayNDimError is derived from ArrayConformanceError. It is thrown when
130// two arrays are non-conformant by virtue of having different dimensionality.
131// It holds within it the two dimensions.
133{
134public:
135 // Define the two (presumably different) messages and optionally
136 // supply a message.
137 ArrayNDimError(int dim1, int dim2, const char *m="ArrayNDimError");
138 ArrayNDimError(int dim1, int dim2, const std::string& m);
139 ~ArrayNDimError() noexcept;
140 // Return the stored dimensions. NB modifies arguments.
141 void ndims(int &dim1, int &dim2) const; // modifies arguments
142private:
143 int r1, r2;
144};
145
146
147// <summary> An error thrown when two arrays have different shapes </summary>
148// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
149// </reviewed>
150//
151// An ArrayShapeError is derived from ArrayConformanceError. It is thrown when
152// two arrays are non-conformant by virtue of having different shapes.
153// It holds within it the two different two shapes.
155{
156public:
157 // Define an ArrayShapeError with the two (presumably different) shapes
158 // and an optional supplied message.
159 ArrayShapeError(const IPosition &shape1, const IPosition &shape2,
160 const char *m="ArrayShapeError");
162 // Get back the stored shapes. NB modifies arguments.
163 void shapes(IPosition &, IPosition &) const; // modifies arguments
164private:
165 IPosition sh1, sh2;
166};
167
168
169// <summary> An error thrown by an ArrayIterator </summary>
170// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
171// </reviewed>
172//
173// An ArrayIteratorError is thrown by an array iterator or related class
174// (e.g. VectorIterator).
176{
177public:
178 // Initialize with the message "ArrayIteratorError.
180 // Initialize with the supplied message
181 ArrayIteratorError(const char *m);
182 // Initialize with the supplied message
183 ArrayIteratorError(const std::string &m);
185};
186
187
188// <summary> An error thrown by an Slicer member function </summary>
189// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
190// </reviewed>
191//
192// An ArraySlicerError is thrown by an Slicer member function.
194{
195public:
196 // Initialize with the message "Slicer error."
198 // Initialize with ArraySlicerError plus the supplied message
199 ArraySlicerError(const std::string &m);
201};
202
203
204} //# NAMESPACE CASACORE - END
205
206#endif
An error thrown when two arrays do not conform.
Definition ArrayError.h:113
ArrayConformanceError()
Initialize the message with "ArrayConformanceError".
ArrayConformanceError(const char *m)
Initialize with a supplied message.
ArrayConformanceError(const std::string &m)
Initialize with a supplied message.
ArrayError(const std::string &m)
Initialize with the supplied message.
ArrayError(const char *m)
Initialize with the supplied message.
ArrayError()
Initialize with the message "ArrayError".
~ArrayError() noexcept
An error thrown when an index is out of range.
Definition ArrayError.h:80
ArrayIndexError(const char *m)
Initialize with the supplied message, the index and shape are null.
ArrayIndexError(const IPosition &index, const IPosition &shape, const char *m="ArrayIndexError")
Initialize with a given out-of-bounds index, as well as the shape of the array and a supplied message...
ArrayIndexError()
Initialize with the message "ArrayIndexError".
ArrayIndexError(const std::string &m)
Initialize with the supplied message, the index and shape are null.
An error thrown by an ArrayIterator.
Definition ArrayError.h:176
ArrayIteratorError()
Initialize with the message "ArrayIteratorError.
ArrayIteratorError(const char *m)
Initialize with the supplied message.
ArrayIteratorError(const std::string &m)
Initialize with the supplied message.
Thrown when two arrays have different dimensionality.
Definition ArrayError.h:133
ArrayNDimError(int dim1, int dim2, const char *m="ArrayNDimError")
Define the two (presumably different) messages and optionally supply a message.
ArrayNDimError(int dim1, int dim2, const std::string &m)
An error thrown when two arrays have different shapes.
Definition ArrayError.h:155
ArrayShapeError(const IPosition &shape1, const IPosition &shape2, const char *m="ArrayShapeError")
Define an ArrayShapeError with the two (presumably different) shapes and an optional supplied message...
An error thrown by an Slicer member function.
Definition ArrayError.h:194
ArraySlicerError()
Initialize with the message "Slicer error.".
ArraySlicerError(const std::string &m)
Initialize with ArraySlicerError plus the supplied message.
this file contains all the compiler specific defines
Definition mainpage.dox:28
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991