casacore
MSSelectionErrorHandler.h
Go to the documentation of this file.
1 //# MSSelectionErrorHandler.h: MSSelection error handler class
2 //# Copyright (C) 1994,1995,1996,1997,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 MS_MSSELECTIONERRORHANDLER_H
29 #define MS_MSSELECTIONERRORHANDLER_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/Logging/LogIO.h>
34 #include <casacore/casa/Exceptions/Error.h>
35 #include <casacore/ms/MSSel/MSSelectionError.h>
36 #include <vector>
37 using namespace std;
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41  //# This header file defines the error handler class for the
42  //# MSSelection module
43 
44 
45  // <summary>
46  // </summary>
47  // <use visibility=export>
48  // <reviewed reviewer="UNKNOWN" date="" tests="">
49  // </reviewed>
50 
51  // <synopsis>
52  //
53  // The top-level generic MSSelection error handler class. The
54  // handleError() overloadable method takes the action of reporting
55  // the error. The handleError() method of this defualt handler
56  // constructs a message string and throws an exception of the type
57  // supplied. This operation has been factored out into this object
58  // to allow more control on the error handler mechanism from
59  // outside.
60  //
61  //</synopsis>
62 
64  {
65  public:
66  // The default constructor generates the message "Table error".
70 
72  virtual ~MSSelectionErrorHandler ();
73 
74  virtual void reportError(const char *token,const String source=String(""));
75  virtual String constructMessage();
76 
77  virtual void reset();
78  virtual void handleError(MSSelectionError&);
79 
80  const vector<String>& getMessages() const
81  { return messageList; }
82  Int nMessages() const
83  { return messageList.size(); }
84 
85  protected:
86  vector<String> tokenList, messageList;
87  };
88 
89  // <synopsis>
90  //
91  // The handleError() method is overloaded to send the accumulated
92  // error messages to the LogIO object as warning messages.
93  //
94  //</synopsis>
95 
97  {
98  public:
100  virtual MSSelectionLogError* clone() {return new MSSelectionLogError();};
101  virtual ~MSSelectionLogError() {}
102  virtual void handleError(MSSelectionError& mssErrorType)
103  {
104  if (messageList.size() > 0)
105  {
106  String mesg(constructMessage());
107  mssErrorType.addMessage(mesg);
108  LogIO logIO;
109  logIO << mssErrorType.getMesg() << LogIO::WARN;
110  }
111  }
112  };
113 } //# NAMESPACE CASACORE - END
114 
115 
116 #endif
int Int
Definition: aipstype.h:50
String constructMessage(const Int pos, const String &command)
const String & getMesg() const
Definition: Error.h:148
PtrHolder< T > & operator=(const PtrHolder< T > &other)
Define real & complex conjugation for non-complex types and put comparisons into std namespace...
Definition: Complex.h:360
ostream-like interface to creating log messages.
Definition: LogIO.h:167
virtual MSSelectionErrorHandler * clone()
const vector< String > & getMessages() const
virtual MSSelectionLogError * clone()
void addMessage(String &message)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
this file contains all the compiler specific defines
Definition: mainpage.dox:28
virtual void handleError(MSSelectionError &mssErrorType)