casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
36 #include <vector>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40  //# This header file defines the error handler class for the
41  //# MSSelection module
42 
43 
44  // <summary>
45  // </summary>
46  // <use visibility=export>
47  // <reviewed reviewer="UNKNOWN" date="" tests="">
48  // </reviewed>
49 
50  // <synopsis>
51  //
52  // The top-level generic MSSelection error handler class. The
53  // handleError() overloadable method takes the action of reporting
54  // the error. The handleError() method of this defualt handler
55  // constructs a message string and throws an exception of the type
56  // supplied. This operation has been factored out into this object
57  // to allow more control on the error handler mechanism from
58  // outside.
59  //
60  //</synopsis>
61 
63  {
64  public:
65  // The default constructor generates the message "Table error".
69 
71  virtual ~MSSelectionErrorHandler ();
72 
73  virtual void reportError(const char *token,const String source=String(""));
74  virtual String constructMessage();
75 
76  virtual void reset();
77  virtual void handleError(MSSelectionError&);
78 
79  const std::vector<String>& getMessages() const
80  { return messageList; }
81  Int nMessages() const
82  { return messageList.size(); }
83 
84  protected:
85  std::vector<String> tokenList, messageList;
86  };
87 
88  // <synopsis>
89  //
90  // The handleError() method is overloaded to send the accumulated
91  // error messages to the LogIO object as warning messages.
92  //
93  //</synopsis>
94 
96  {
97  public:
99  virtual MSSelectionLogError* clone() {return new MSSelectionLogError();};
100  virtual ~MSSelectionLogError() {}
101  virtual void handleError(MSSelectionError& mssErrorType)
102  {
103  if (messageList.size() > 0)
104  {
105  String mesg(constructMessage());
106  mssErrorType.addMessage(mesg);
107  LogIO logIO;
108  logIO << mssErrorType.getMesg() << LogIO::WARN;
109  }
110  }
111  };
112 } //# NAMESPACE CASACORE - END
113 
114 
115 #endif
int Int
Definition: aipstype.h:50
virtual void reportError(const char *token, const String source=String(""))
ostream-like interface to creating log messages.
Definition: LogIO.h:167
Change the message priority to WARN.
Definition: LogIO.h:181
const String & getMesg() const
Definition: Error.h:148
virtual void handleError(MSSelectionError &)
virtual MSSelectionErrorHandler * clone()
const std::vector< String > & getMessages() const
MSSelectionErrorHandler()
The default constructor generates the message &quot;Table error&quot;.
virtual MSSelectionLogError * clone()
void addMessage(String &message)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
MSSelectionErrorHandler & operator=(const MSSelectionErrorHandler &that)
virtual void handleError(MSSelectionError &mssErrorType)