Epetra_Object.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 /*
00004 ************************************************************************
00005 
00006               Epetra: Linear Algebra Services Package 
00007                 Copyright (2001) Sandia Corporation
00008 
00009 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 license for use of this work by or on behalf of the U.S. Government.
00011 
00012 This library is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation; either version 2.1 of the
00015 License, or (at your option) any later version.
00016  
00017 This library is distributed in the hope that it will be useful, but
00018 WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Lesser General Public License for more details.
00021  
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 USA
00026 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00027 
00028 ************************************************************************
00029 */
00030 //@HEADER
00031 
00032 #ifndef EPETRA_OBJECT_H
00033 #define EPETRA_OBJECT_H
00034 
00035 #include "Epetra_CombineMode.h"
00036 #include "Epetra_DataAccess.h"
00037 #include "Epetra_ConfigDefs.h"
00038 
00040 
00045 class Epetra_Object {
00046     
00047   public:
00049 
00050 
00051 
00055   Epetra_Object(int TracebackModeIn = -1, bool set_label = true);
00056 
00058 
00060   Epetra_Object(const char * const Label, int TracebackModeIn = -1);
00061 
00063 
00065   Epetra_Object(const Epetra_Object& Object);
00066 
00068 
00070   virtual ~Epetra_Object();
00072   
00074 
00075 
00077 
00079   virtual void SetLabel(const char * const Label);
00080 
00082 
00084   virtual const char * Label() const;
00085 
00087 
00099   static void SetTracebackMode(int TracebackModeValue);
00100 
00102   static int GetTracebackMode();
00104 
00106 
00107 
00110   virtual void Print(ostream & os) const;
00111 
00113   virtual int ReportError(const string Message, int ErrorCode) const;
00115 
00116   
00117 // TracebackMode controls how much traceback information is printed when run time 
00118 // integer errors are detected:
00119 // = 0 - No information report
00120 // = 1 - Fatal (negative) values are reported
00121 // = 2 - All values (except zero) reported.
00122 
00123 // Default is set to 1.  Can be set to different value using SetTracebackMode() method in
00124 // Epetra_Object class
00125   static int TracebackMode;
00126 
00127 
00128  protected:
00129   string toString(const int& x) const {
00130      char s[100];
00131      sprintf(s, "%d", x);
00132      return string(s);
00133 }
00134 
00135   string toString(const double& x) const {
00136      char s[100];
00137      sprintf(s, "%g", x);
00138      return string(s);
00139 }
00140   
00141 
00142  private:
00143   Epetra_Object& operator=(const Epetra_Object& src) {
00144     SetLabel(src.Label());
00145     return *this;
00146   }
00147 
00148   char * Label_;
00149 
00150 };
00151 inline ostream& operator<<(ostream& os, const Epetra_Object& obj)
00152 {
00153   if (Epetra_FormatStdout) {
00154 /*    const Epetra_fmtflags  olda = os.setf(ios::right,ios::adjustfield);
00155     const Epetra_fmtflags  oldf = os.setf(ios::scientific,ios::floatfield);
00156     const int              oldp = os.precision(12); */
00157 
00158     os << obj.Label() << endl;
00159     obj.Print(os);
00160 
00161 /*    os.setf(olda,ios::adjustfield);
00162     os.setf(oldf,ios::floatfield);
00163     os.precision(oldp); */
00164   }
00165   else {
00166 
00167     os << obj.Label();
00168     obj.Print(os);
00169   }
00170   
00171   return os;
00172 }
00173 
00174 
00175 #endif /* EPETRA_OBJECT_H */

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