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 
00033 //=============================================================================
00034 Epetra_Object::Epetra_Object(int TracebackModeIn, bool set_label) 
00035   : Label_(0)
00036 {
00037   if (set_label) {
00038     SetLabel("Epetra::Object");
00039   }
00040   TracebackMode = (TracebackModeIn != -1) ? TracebackModeIn : TracebackMode;
00041 }
00042 
00043 //=============================================================================
00044 Epetra_Object::Epetra_Object(const char * const Label, 
00045            int TracebackModeIn) 
00046   : Label_(0)
00047 {
00048   SetLabel(Label);
00049   TracebackMode = (TracebackModeIn != -1) ? TracebackModeIn : TracebackMode;
00050 }
00051 //=============================================================================
00052 Epetra_Object::Epetra_Object(const Epetra_Object& Object)
00053   : Label_(0)
00054 {
00055   SetLabel(Object.Label_);
00056 }
00057 
00058 // Set TracebackMode value to default
00059 int Epetra_Object::TracebackMode(-1);
00060 
00061 void Epetra_Object::SetTracebackMode(int TracebackModeValue) {
00062   if (TracebackModeValue < 0) TracebackModeValue = 0;
00063   Epetra_Object TempObject(TracebackModeValue);
00064 }
00065 
00066 int Epetra_Object::GetTracebackMode() {
00067   int temp = Epetra_Object::TracebackMode;
00068   if (temp==-1) temp = DefaultTracebackMode;
00069   return(temp);
00070 }
00071 
00072 //=============================================================================
00073 void Epetra_Object::Print(ostream & os) const {
00074   (void)os;//prevents unused variable compiler-warning
00075   // os << Label_; // No need to print label, since ostream does it already
00076   return;
00077 }
00078 //=============================================================================
00079 int Epetra_Object::ReportError(const string Message, int ErrorCode) const {
00080 
00081 #ifndef EPETRA_NO_ERROR_REPORTS
00082   // NOTE:  We are extracting a C-style string from Message because
00083   //        the SGI compiler does not have a real string class with 
00084   //        the << operator.  Some day we should get rid of ".c_str()"
00085                               if ((ErrorCode < 0 && Epetra_Object::GetTracebackMode() > 0) || \
00086                                   (ErrorCode > 0 && Epetra_Object::GetTracebackMode() > 1)) { \
00087   cerr << endl << "Error in Epetra Object with label:  " << Label_ << endl
00088        << "Epetra Error:  " << Message.c_str() << "  Error Code:  " << ErrorCode << endl;
00089 }
00090 #endif
00091   return(ErrorCode);
00092 }
00093 //=============================================================================
00094 Epetra_Object::~Epetra_Object()  
00095 {
00096   if (Label_!=0) {
00097     delete [] Label_;
00098     Label_ = 0;
00099   }
00100 }
00101 //=============================================================================
00102 const char * Epetra_Object::Label() const {
00103   return(Label_);
00104 }
00105 //=============================================================================
00106 void Epetra_Object::SetLabel(const char * const Label)
00107 { 
00108   if (Label_!=0) {
00109     delete [] Label_;
00110     Label_ = 0;
00111   }
00112   if (Label==0) return;
00113   Label_ = new char[strlen(Label)+1];
00114   strcpy(Label_,Label);
00115   return;
00116 }

Generated on Thu Sep 18 12:37:58 2008 for Epetra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1