casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: 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 CASA_ARRAYERROR_H
29 #define CASA_ARRAYERROR_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary> The base class for all Array exception classes. </summary>
40 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
41 // </reviewed>
42 //
43 // ArrayError is the base class for all the Array-specific exception classes,
44 // i.e. if it is caught you will catch (through inheritance) all Array-specific
45 // exceptions. Note that (presently, anyway) the Array classes will throw
46 // a few non-Array exceptions.
47 // <srcblock>
48 // try {
49 // // Some lines, functions, ...
50 // } catch (ArrayError x) {
51 // // Array specific errors
52 // } catch (AipsError x) {
53 // // All other errors caught here.
54 // }
55 // </srcblock>
56 //
57 //# There are too many Array related error classes. Some should be deleted.
58 
59 class ArrayError : public AipsError
60 {
61 public:
62  // Initialize with the message "ArrayError."
64  // Initialize with the supplied message.
65  ArrayError(const Char *m,Category c=GENERAL);
66  // Initialize with the supplied message.
68  ~ArrayError() noexcept;
69 };
70 
71 
72 // <summary> An error thrown when an index is out of range </summary>
73 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
74 // </reviewed>
75 //
76 // The ArrayIndexError class, which is derived from ArrayError, is intended
77 // to be thrown when an index is out-of-bounds. It contains within it
78 // the offending index, as well as the shape of the array which
79 // is being indexed. This should be multiply-derived from
80 // indexError<T> defined in Error.h.
82 {
83 public:
84  // Initialize with the message "ArrayIndexError".
86  // Initialize with the supplied message, the index and shape are null.
88  // Initialize with the supplied message, the index and shape are null.
90  // Initialize with a given out-of-bounds index, as well as the shape
91  // of the array and a supplied message.
93  const Char *m="ArrayIndexError",Category c=BOUNDARY);
94  ~ArrayIndexError() noexcept;
95  // The out-of-bounds index.
96  IPosition index() const;
97  // The shape of the violated array.
98  IPosition shape() const;
99 private:
100  //# index, offset, length
102 };
103 
104 
105 // <summary> An error thrown when two arrays do not conform </summary>
106 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
107 // </reviewed>
108 //
109 // The ArrayConformanceError class is the base class for all errors thrown
110 // because two arrays are not conformant. See also the ArrayShapeError and
111 // ArrayNDimError classes which are derived from it. This error, or one derived
112 // from it, os normally thrown from a binary operation (arithmetic, logical,
113 // assignment, etc).
115 {
116 public:
117  // Initialize the message with "ArrayConformanceError".
119  // Initialize with a supplied message.
121  // Initialize with a supplied message.
123  ~ArrayConformanceError() noexcept;
124 };
125 
126 
127 // <summary> Thrown when two arrays have different dimensionality </summary>
128 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
129 // </reviewed>
130 //
131 // An ArrayNDimError is derived from ArrayConformanceError. It is thrown when
132 // two arrays are non-conformant by virtue of having different dimensionality.
133 // It holds within it the two dimensions.
135 {
136 public:
137  // Define the two (presumably different) messages and optionally
138  // supply a message.
139  ArrayNDimError(Int dim1, Int dim2, const Char *m="ArrayNDimError",Category c=CONFORMANCE);
140  ~ArrayNDimError() noexcept;
141  // Return the stored dimensions. NB modifies arguments.
142  void ndims(Int &dim1, Int &dim2) const; // modifies arguments
143 private:
145 };
146 
147 
148 // <summary> An error thrown when two arrays have different shapes </summary>
149 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
150 // </reviewed>
151 //
152 // An ArrayShapeError is derived from ArrayConformanceError. It is thrown when
153 // two arrays are non-conformant by virtue of having different shapes.
154 // It holds within it the two different two shapes.
156 {
157 public:
158  // Define an ArrayShapeError with the two (presumably different) shapes
159  // and an optional supplied message.
160  ArrayShapeError(const IPosition &shape1, const IPosition &shape2,
161  const Char *m="ArrayShapeError",Category c=CONFORMANCE);
162  ~ArrayShapeError() noexcept;
163  // Get back the stored shapes. NB modifies arguments.
164  void shapes(IPosition &, IPosition &) const; // modifies arguments
165 private:
167 };
168 
169 
170 // <summary> An error thrown by an ArrayIterator </summary>
171 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
172 // </reviewed>
173 //
174 // An ArrayIteratorError is thrown by an array iterator or related class
175 // (e.g. VectorIterator).
177 {
178 public:
179  // Initialize with the message "ArrayIteratorError.
181  // Initialize with the supplied message
183  // Initialize with the supplied message
185  ~ArrayIteratorError() noexcept;
186 };
187 
188 
189 // <summary> An error thrown by an Slicer member function </summary>
190 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
191 // </reviewed>
192 //
193 // An ArraySlicerError is thrown by an Slicer member function.
195 {
196 public:
197  // Initialize with the message "Slicer error."
199  // Initialize with ArraySlicerError plus the supplied message
201  ~ArraySlicerError() noexcept;
202 };
203 
204 
205 } //# NAMESPACE CASACORE - END
206 
207 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
ArrayIndexError(Category c=BOUNDARY)
Initialize with the message &quot;ArrayIndexError&quot;.
~ArrayError() noexcept
The base class for all Array exception classes.
Definition: ArrayError.h:59
char Char
Definition: aipstype.h:46
ArrayIteratorError(Category c=BOUNDARY)
Initialize with the message "ArrayIteratorError.
IPosition index() const
The out-of-bounds index.
void shapes(IPosition &, IPosition &) const
Get back the stored shapes.
ArrayNDimError(Int dim1, Int dim2, const Char *m="ArrayNDimError", Category c=CONFORMANCE)
Define the two (presumably different) messages and optionally supply a message.
An error thrown when two arrays do not conform.
Definition: ArrayError.h:114
IPosition shape() const
The shape of the violated array.
An error thrown by an ArrayIterator.
Definition: ArrayError.h:176
An error thrown when an index is out of range.
Definition: ArrayError.h:81
An error thrown when two arrays have different shapes.
Definition: ArrayError.h:155
ArraySlicerError(Category c=GENERAL)
Initialize with the message &quot;Slicer error.&quot;.
Base class for all Casacore library errors.
Definition: Error.h:134
const Double c
Fundamental physical constants (SI units):
An error thrown by an Slicer member function.
Definition: ArrayError.h:194
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void ndims(Int &dim1, Int &dim2) const
Return the stored dimensions.
Thrown when two arrays have different dimensionality.
Definition: ArrayError.h:134
ArrayError(Category c=GENERAL)
Initialize with the message &quot;ArrayError.&quot;.
ArrayConformanceError(Category c=CONFORMANCE)
Initialize the message with &quot;ArrayConformanceError&quot;.
ArrayShapeError(const IPosition &shape1, const IPosition &shape2, const Char *m="ArrayShapeError", Category c=CONFORMANCE)
Define an ArrayShapeError with the two (presumably different) shapes and an optional supplied message...
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42