|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 // Kris 00030 // 07.08.03 -- Move into Teuchos package/namespace 00031 00032 #ifndef _TEUCHOS_OBJECT_HPP_ 00033 #define _TEUCHOS_OBJECT_HPP_ 00034 00039 #include "Teuchos_ConfigDefs.hpp" 00040 #include "Teuchos_DataAccess.hpp" 00041 00042 // 2007/11/26: rabartl: This class has to change from using 'char*' to 00043 // std::string! 00044 00053 namespace Teuchos 00054 { 00055 00056 class TEUCHOS_LIB_DLL_EXPORT 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 // NOTE: We are extracting a C-style std::string from Message because 00137 // the SGI compiler does not have a real std::string class with 00138 // the << operator. Some day we should get rid of ".c_str()" 00139 if ( (tracebackMode==1) && (errorCode < 0) ) 00140 { // Report fatal error 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 }; // class Object 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 } // namespace Teuchos 00178 00179 // #include "Teuchos_Object.cpp" 00180 00181 00182 #endif /* _TEUCHOS_OBJECT_HPP_ */
1.7.4