casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ATMError.h
Go to the documentation of this file.
1 #ifndef _ATM_ERROR_H
2 #define _ATM_ERROR_H
3 /*******************************************************************************
4  * ALMA - Atacama Large Millimiter Array
5  * (c) Instituto de Estructura de la Materia, 2009
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * "@(#) $Id: ATMError.h Exp $"
22  *
23  * who when what
24  * -------- -------- ----------------------------------------------
25  * pardo 24/03/09 created
26  */
27 
28 #ifndef __cplusplus
29 #error "This is a C++ include file and cannot be used from plain C"
30 #endif
31 
32 #include "ATMCommon.h"
33 #include <string>
34 #include <stdarg.h>
35 
36 
37 
39 
43 {
44  NOERROR = 0,
49 };
50 
56 class Error
57 {
58 public:
59  Error();
60  Error(ErrorLevel errlev);
69  Error(ErrorLevel errlev, const std::string &message);
70 
80  Error(ErrorLevel errlev, char* fmt, ...);
81 
83  virtual ~Error();
84 
85  void notify(ErrorLevel errlev, const std::string &message);
86  void notify(const std::string &message);
87 
92  static void setAcceptableLevel(ErrorLevel criticalErrlev);
93 
97 
100  static std::string getAcceptableLevelToString();
101 
104  static ErrorLevel getLevel();
105 
108  static std::string getLevelToString();
109 
112  static std::string getErrorMessage();
113 
117  static void clearMessage();
118 
122  static void clearErrLev();
123 
124 private:
125  void printMessage(const std::string &message);
126 
127 private:
129  static std::string errorMessage_;
131  std::string errorLog;
132 }; // class Error
133 
135 
184 #endif
#define ATM_NAMESPACE_END
Definition: ATMCommon.h:38
The Error class represents a list of exceptions that may happen when errors occur.
Definition: ATMError.h:56
static void clearMessage()
Clear the stack of all the error messages which passed up to the last declaration which has finally t...
static std::string getAcceptableLevelToString()
Accessor to the current limit in the form of a std::string.
virtual ~Error()
Destructor.
ErrorLevel
Definition of the sequence of error levels sorted by ascending severity.
Definition: ATMError.h:42
static ErrorLevel getLevel()
Accessor to the severity level of the error which has just been declared.
static ErrorLevel getAcceptableLevel()
Accessor to the current limit below wich error are not thrown.
static ErrorLevel acceptableErrorLevel
Current acceptable level of severity.
Definition: ATMError.h:128
static void setAcceptableLevel(ErrorLevel criticalErrlev)
Setter to modify the critical current level of severity below which errors are tolerated.
Definition: ATMError.h:48
static ErrorLevel errlev_
Error level.
Definition: ATMError.h:130
#define ATM_NAMESPACE_BEGIN
Definition: ATMCommon.h:37
std::string errorLog
Error log (TBD)
Definition: ATMError.h:131
void notify(ErrorLevel errlev, const std::string &message)
static std::string getLevelToString()
Accessor to the severity level, in the form of a std::string, of the error which has just been declar...
static std::string getErrorMessage()
Accessor to the error message for the error which has just been declared.
static std::string errorMessage_
Error message.
Definition: ATMError.h:129
static void clearErrLev()
Clear the stack of all the error levels which passed up to the last declaration which has finally tri...
void printMessage(const std::string &message)
Print utility.
Definition: ATMError.h:46