Teuchos_Object.hpp
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
00027
00028
00029
00030
00031
00032 #ifndef _TEUCHOS_OBJECT_HPP_
00033 #define _TEUCHOS_OBJECT_HPP_
00034
00039 #include "Teuchos_ConfigDefs.hpp"
00040 #include "Teuchos_DataAccess.hpp"
00041
00042
00043
00044
00053 namespace Teuchos
00054 {
00055
00056 class Object
00057 {
00058 public:
00060
00061
00062
00066 Object(int tracebackModeIn = -1);
00067
00069
00071 Object(const char* label, int tracebackModeIn = -1);
00072
00074
00076 Object(const Object& obj);
00077
00079
00081 virtual ~Object();
00082
00084
00086
00087
00089
00091 virtual void setLabel(const char* label);
00092
00094
00106 static void setTracebackMode(int tracebackModeValue);
00107
00109
00111
00112
00114
00116 virtual char* label() const;
00117
00119 static int getTracebackMode();
00120
00122
00124
00125
00127 virtual void print(std::ostream& os) const;
00129
00131
00132
00134 virtual int reportError(const std::string message, int errorCode) const
00135 {
00136
00137
00138
00139 if ( (tracebackMode==1) && (errorCode < 0) )
00140 {
00141 std::cerr << std::endl << "Error in Teuchos Object with label: " << label_ << std::endl
00142 << "Teuchos Error: " << message.c_str() << " Error Code: " << errorCode << std::endl;
00143 return(errorCode);
00144 }
00145 if ( (tracebackMode==2) && (errorCode != 0 ) )
00146 {
00147 std::cerr << std::endl << "Error in Teuchos Object with label: " << label_ << std::endl
00148 << "Teuchos Error: " << message.c_str() << " Error Code: " << errorCode << std::endl;
00149 return(errorCode);
00150 }
00151 return(errorCode);
00152 }
00153
00155
00156 static int tracebackMode;
00157
00158 protected:
00159
00160 private:
00161
00162 char* label_;
00163
00164 };
00165
00169 inline std::ostream& operator<<(std::ostream& os, const Teuchos::Object& Obj)
00170 {
00171 os << Obj.label() << std::endl;
00172 Obj.print(os);
00173
00174 return os;
00175 }
00176
00177 }
00178
00179
00180
00181
00182 #endif