Main Page   Class Hierarchy   Compound List   File List   Compound Members  

error.hh

00001 /*=============================================================================
00002         File: error.hh
00003      Purpose:       
00004     Revision: $Id: error.hh,v 1.1.1.1 1999/08/05 01:49:16 lavoie Exp $
00005   Created by: Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1998 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 #ifndef _ERROR_REP_HH_
00026 #define _ERROR_REP_HH_
00027 
00028 #include <stdlib.h>
00029 #include "matrix_global.hh"
00030 
00031 #if (defined USING_VCC || (defined __GNUC__ && (__GNUC__ == 3)))
00032 #include <sstream>
00033 typedef std::ostringstream ErrorStream;
00034 #else
00035 #include <strstream>
00036 typedef ostrstream ErrorStream;
00037 #endif
00038 
00041 namespace PLib {
00042 
00043   struct MatrixErr { 
00044     MatrixErr() { print_debug(); }
00045     void print_debug() { 
00046 #ifdef VERBOSE_EXCEPTION
00047       print();
00048 #else
00049       ;
00050 #endif
00051     }
00052     virtual void print() { cerr << "Matrix error.\n" ; }
00053   };
00054   
00055   struct MatrixInputError : public MatrixErr {
00056     MatrixInputError() { print_debug();}
00057     virtual void print(){
00058       cerr << "One of the input value is not in appropriate.\n";
00059     }
00060   };
00061 
00062   struct OutOfBound : public MatrixInputError {
00063     int i ;
00064     int s,e ;
00065     OutOfBound(int index, int from, int to): i(index), s(from), e(to) { print_debug(); }
00066     virtual void print() { 
00067       cerr << "Out of bound error, trying to access " << i << 
00068         " but the valid range is [ " << s << "," << e << "]\n" ; 
00069     }
00070   };
00071   
00072   struct OutOfBound2D : public MatrixInputError {
00073     int i,j ;
00074     int s_i,e_i ;
00075     int s_j,e_j ;
00076     OutOfBound2D(int I, int J, int fI, int tI, int fJ, int tJ): i(I), j(J), s_i(fI), e_i(tI), s_j(fJ), e_j(tJ) { print_debug(); } 
00077     virtual void print() { 
00078       cerr << "Out of bound error, trying to access (" << i << ',' << j <<
00079         ") but the valid range is ([ " << s_i << "," << e_i << "], [" <<
00080         s_j << ',' << e_j << "])\n" ;
00081     }
00082     
00083   };
00084   
00085   struct WrongSize : public MatrixInputError {
00086     int s1,s2 ;
00087     WrongSize(int a, int b) : s1(a), s2(b) { print_debug();}
00088     virtual void print(){
00089       cerr << "The vector sizes  " << s1 << " and " << s2 << " are incompatible.\n" ;
00090     }
00091   }; 
00092   
00093   struct WrongSize2D : public MatrixInputError {
00094     int rows,cols ;
00095     int bad_rows, bad_cols ;
00096     WrongSize2D(int r, int c, int br, int bc) : rows(r), cols(c), bad_rows(br), bad_cols(bc) { print_debug();}
00097     virtual void print(){
00098       cerr << "The matrix sizes  (" << rows << " x " << cols << ") and (" << bad_rows << " x " << bad_cols << ") are incompatible.\n" ;
00099     }
00100   }; 
00101   
00109  class Error : public ErrorStream
00110  {
00111  private:
00112    char* prog;
00113    void report(const char *msg = NULL);
00114  public:
00115    Error(): ErrorStream(), prog(0) {}
00116    Error(const char *s);
00117    ~Error(){ if (prog) delete []prog ; }
00118    
00119    void warning(const char *msg = 0);
00120    void nonfatal(const char *msg = 0) { warning(msg); }
00121    void fatal(const char * = 0 );
00122    void memory(const void * = 0 );
00123    
00124  };
00125 
00126 } // end namespace
00127 
00128 #ifdef INCLUDE_TEMPLATE_SOURCE
00129 #if !(defined USING_VCC || (defined __GNUC__ && (__GNUC__ == 3)))
00130 //#ifndef USING_VCC
00131 #include "error.cc"
00132 #endif
00133 #endif
00134 
00135 
00136 
00137 #endif
00138 

Generated on Sun Jan 27 18:56:40 2002 for NURBS++ by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001