Epetra_Object.cpp

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright (2001) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ************************************************************************
00028 //@HEADER
00029 
00030 #include "Epetra_Object.h"
00031 
00032 #ifdef HAVE_EPETRA_TEUCHOS
00033 #include "Teuchos_VerboseObject.hpp"
00034 #endif
00035 
00036 //=============================================================================
00037 Epetra_Object::Epetra_Object(int TracebackModeIn, bool set_label) 
00038   : Label_(0)
00039 {
00040   if (set_label) {
00041     SetLabel("Epetra::Object");
00042   }
00043   TracebackMode = (TracebackModeIn != -1) ? TracebackModeIn : TracebackMode;
00044 }
00045 
00046 //=============================================================================
00047 Epetra_Object::Epetra_Object(const char * const Label_in, 
00048            int TracebackModeIn) 
00049   : Label_(0)
00050 {
00051   SetLabel(Label_in);
00052   TracebackMode = (TracebackModeIn != -1) ? TracebackModeIn : TracebackMode;
00053 }
00054 //=============================================================================
00055 Epetra_Object::Epetra_Object(const Epetra_Object& Object)
00056   : Label_(0)
00057 {
00058   SetLabel(Object.Label_);
00059 }
00060 
00061 // Set TracebackMode value to default
00062 int Epetra_Object::TracebackMode(-1);
00063 
00064 void Epetra_Object::SetTracebackMode(int TracebackModeValue) {
00065   if (TracebackModeValue < 0) TracebackModeValue = 0;
00066   Epetra_Object TempObject(TracebackModeValue);
00067 }
00068 
00069 int Epetra_Object::GetTracebackMode() {
00070   int temp = Epetra_Object::TracebackMode;
00071   if (temp==-1) temp = DefaultTracebackMode;
00072   return(temp);
00073 }
00074 
00075 std::ostream& Epetra_Object::GetTracebackStream() {
00076 #ifdef HAVE_EPETRA_TEUCHOS
00077   return (*Teuchos::VerboseObjectBase::getDefaultOStream());
00078 #else
00079   return cerr;
00080 #endif
00081 }
00082 
00083 //=============================================================================
00084 void Epetra_Object::Print(ostream & os) const {
00085   (void)os;//prevents unused variable compiler-warning
00086   // os << Label_; // No need to print label, since ostream does it already
00087   return;
00088 }
00089 //=============================================================================
00090 int Epetra_Object::ReportError(const string Message, int ErrorCode) const {
00091 #ifndef EPETRA_NO_ERROR_REPORTS
00092   // NOTE:  We are extracting a C-style string from Message because
00093   //        the SGI compiler does not have a real string class with 
00094   //        the << operator.  Some day we should get rid of ".c_str()"
00095   if (
00096     ( ErrorCode < 0 && Epetra_Object::GetTracebackMode() > 0 )
00097     ||
00098     ( ErrorCode > 0 && Epetra_Object::GetTracebackMode() > 1 )
00099     )
00100   {
00101     GetTracebackStream()
00102       << endl << "Error in Epetra Object with label:  " << Label_ << endl
00103       << "Epetra Error:  " << Message.c_str() << "  Error Code:  " << ErrorCode << endl;
00104   }
00105 #endif
00106   return(ErrorCode);
00107 }
00108 //=============================================================================
00109 Epetra_Object::~Epetra_Object()  
00110 {
00111   if (Label_!=0) {
00112     delete [] Label_;
00113     Label_ = 0;
00114   }
00115 }
00116 //=============================================================================
00117 const char * Epetra_Object::Label() const {
00118   return(Label_);
00119 }
00120 //=============================================================================
00121 void Epetra_Object::SetLabel(const char * const Label_in)
00122 { 
00123   if (Label_!=0) {
00124     delete [] Label_;
00125     Label_ = 0;
00126   }
00127   if (Label_in==0) return;
00128   Label_ = new char[strlen(Label_in)+1];
00129   strcpy(Label_,Label_in);
00130   return;
00131 }

Generated on Wed May 12 21:41:05 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7