|
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 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 // Kris 00043 // 07.08.03 -- Move into Teuchos package/namespace 00044 00045 #ifndef _TEUCHOS_OBJECT_HPP_ 00046 #define _TEUCHOS_OBJECT_HPP_ 00047 00052 #include "Teuchos_ConfigDefs.hpp" 00053 #include "Teuchos_DataAccess.hpp" 00054 00055 // 2007/11/26: rabartl: This class has to change from using 'char*' to 00056 // std::string! 00057 00066 namespace Teuchos 00067 { 00068 00069 class TEUCHOSNUMERICS_LIB_DLL_EXPORT Object 00070 { 00071 public: 00073 00074 00075 00079 Object(int tracebackModeIn = -1); 00080 00082 00084 Object(const char* label, int tracebackModeIn = -1); 00085 00087 00089 Object(const Object& obj); 00090 00092 00094 virtual ~Object(); 00095 00097 00099 00100 00102 00104 virtual void setLabel(const char* label); 00105 00107 00119 static void setTracebackMode(int tracebackModeValue); 00120 00122 00124 00125 00127 00129 virtual char* label() const; 00130 00132 static int getTracebackMode(); 00133 00135 00137 00138 00140 virtual void print(std::ostream& os) const; 00142 00144 00145 00147 virtual int reportError(const std::string message, int errorCode) const 00148 { 00149 // NOTE: We are extracting a C-style std::string from Message because 00150 // the SGI compiler does not have a real std::string class with 00151 // the << operator. Some day we should get rid of ".c_str()" 00152 if ( (tracebackMode==1) && (errorCode < 0) ) 00153 { // Report fatal error 00154 std::cerr << std::endl << "Error in Teuchos Object with label: " << label_ << std::endl 00155 << "Teuchos Error: " << message.c_str() << " Error Code: " << errorCode << std::endl; 00156 return(errorCode); 00157 } 00158 if ( (tracebackMode==2) && (errorCode != 0 ) ) 00159 { 00160 std::cerr << std::endl << "Error in Teuchos Object with label: " << label_ << std::endl 00161 << "Teuchos Error: " << message.c_str() << " Error Code: " << errorCode << std::endl; 00162 return(errorCode); 00163 } 00164 return(errorCode); 00165 } 00166 00168 00169 static int tracebackMode; 00170 00171 protected: 00172 00173 private: 00174 00175 char* label_; 00176 00177 }; // class Object 00178 00182 inline std::ostream& operator<<(std::ostream& os, const Teuchos::Object& Obj) 00183 { 00184 os << Obj.label() << std::endl; 00185 Obj.print(os); 00186 00187 return os; 00188 } 00189 00190 } // namespace Teuchos 00191 00192 // #include "Teuchos_Object.cpp" 00193 00194 00195 #endif /* _TEUCHOS_OBJECT_HPP_ */
1.7.6.1