Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00032 #ifndef ACADO_TOOLKIT_ACADO_MESSAGE_HANDLING_HPP
00033 #define ACADO_TOOLKIT_ACADO_MESSAGE_HANDLING_HPP
00034
00035 #include <acado/utils/acado_namespace_macros.hpp>
00036 #include <acado/utils/acado_types.hpp>
00037
00038 #include <cstdlib>
00039 #include <iostream>
00040 #include <vector>
00041 #include <string>
00042
00043 BEGIN_NAMESPACE_ACADO
00044
00046 enum VisibilityStatus
00047 {
00048 VS_VISIBLE,
00049 VS_HIDDEN
00050 };
00051
00053 #ifndef __MATLAB__
00054
00055 #define COL_DEBUG "\033[1;34m"
00056 #define COL_FATAL "\033[0;31m"
00057 #define COL_ERROR "\033[1;31m"
00058 #define COL_WARNING "\033[1;33m"
00059 #define COL_INFO "\033[0m"
00060
00061 #else
00062
00063 #define COL_DEBUG ""
00064 #define COL_FATAL ""
00065 #define COL_ERROR ""
00066 #define COL_WARNING ""
00067 #define COL_INFO ""
00068
00069 #endif
00070
00072 enum returnValueStatus {
00073 STATUS_UNHANDLED,
00074 STATUS_HANDLED
00075 };
00076
00078 const char* returnValueLevelToString(returnValueLevel level);
00079
00081 const char* returnValueTypeToString(returnValueType type);
00082
00083
00084 #ifndef __FUNCTION__
00085 #define __FUNCTION__ 0
00086 #endif
00087
00088 #ifndef __FILE__
00089 #define __FILE__ 0
00090 #endif
00091
00092 #ifndef __LINE__
00093 #define __LINE__ 0
00094 #endif
00095
00097 #define QUOTE_(x) #x
00098 #define QUOTE(x) QUOTE_(x)
00099
00101 #define ACADOERROR(retval) \
00102 returnValue("Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_ERROR, retval)
00103
00105 #define ACADOERRORTEXT(retval, text) \
00106 returnValue("Message: "#text"\n Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_ERROR, retval)
00107
00109 #define ACADOFATAL(retval) \
00110 returnValue("Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_FATAL, retval)
00111
00113 #define ACADOFATALTEXT(retval, text) \
00114 returnValue("Message: "#text"\n Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_FATAL, retval)
00115
00117 #define ACADOWARNING(retval) \
00118 returnValue("Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_WARNING, retval)
00119
00121 #define ACADOWARNINGTEXT(retval,text) \
00122 returnValue("Message: "#text"\n Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_WARNING, retval)
00123
00125 #define ACADOINFO(retval) \
00126 returnValue("", LVL_INFO, retval)
00127
00129 #define ACADOINFOTEXT(retval,text) \
00130 returnValue("Message: "#text"\n Code: ("#retval") \n File: " __FILE__ "\n Line: " QUOTE(__LINE__), LVL_INFO, retval)
00131
00132
00139 #define ACADO_TRY(X) for(returnValue ACADO_R = X; !ACADO_R;) return ACADO_R
00140
00147 class Logger
00148 {
00149 public:
00151 static Logger& instance()
00152 {
00153 static Logger instance;
00154 return instance;
00155 }
00156
00158 Logger& setLogLevel(returnValueLevel level)
00159 {
00160 logLevel = level;
00161
00162 return *this;
00163 }
00164
00166 returnValueLevel getLogLevel()
00167 {
00168 return logLevel;
00169 }
00170
00172 std::ostream& get(returnValueLevel level);
00173
00174 private:
00175 returnValueLevel logLevel;
00176
00177 Logger()
00178 : logLevel( LVL_FATAL )
00179 {}
00180
00181 Logger(const Logger&);
00182 Logger& operator=(const Logger&);
00183 ~Logger()
00184 {}
00185 };
00186
00188 #define LOG( level ) \
00189 if (level < Logger::instance().getLogLevel()); \
00190 else Logger::instance().get( level )
00191
00192 CLOSE_NAMESPACE_ACADO
00193
00194
00195
00196 #endif // ACADO_TOOLKIT_ACADO_MESSAGE_HANDLING_HPP
00197
00198
00199
00200