Main Page   Class Hierarchy   Compound List   File List   Compound Members  

error.h

00001 /*=============================================================================
00002         File: error.h
00003      Purpose:       
00004     Revision: $Id: error.h,v 1.3 2002/05/17 18:24:21 philosophil 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.h"
00030 
00031 #include <sstream>
00032 typedef std::ostringstream ErrorStream;
00033 /* the standard is now sstream and not strstream
00034 #else
00035 #include <strstream>
00036 typedef std::ostrstream ErrorStream;
00037 #endif
00038 */
00039 
00040 
00043 namespace PLib {
00044 
00045   struct MatrixErr { 
00046     MatrixErr() { print_debug(); }
00047     void print_debug() { 
00048 #ifdef VERBOSE_EXCEPTION
00049       print();
00050 #else
00051       ;
00052 #endif
00053     }
00054     virtual void print() { cerr << "Matrix error.\n" ; }
00055   };
00056   
00057   struct MatrixInputError : public MatrixErr {
00058     MatrixInputError() { print_debug();}
00059     virtual void print(){
00060       cerr << "One of the input value is not in appropriate.\n";
00061     }
00062   };
00063 
00064   struct OutOfBound : public MatrixInputError {
00065     int i ;
00066     int s,e ;
00067     OutOfBound(int index, int from, int to): i(index), s(from), e(to) { print_debug(); }
00068     virtual void print() { 
00069       cerr << "Out of bound error, trying to access " << i << 
00070         " but the valid range is [ " << s << "," << e << "]\n" ; 
00071     }
00072   };
00073   
00074   struct OutOfBound2D : public MatrixInputError {
00075     int i,j ;
00076     int s_i,e_i ;
00077     int s_j,e_j ;
00078     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(); } 
00079     virtual void print() { 
00080       cerr << "Out of bound error, trying to access (" << i << ',' << j <<
00081         ") but the valid range is ([ " << s_i << "," << e_i << "], [" <<
00082         s_j << ',' << e_j << "])\n" ;
00083     }
00084     
00085   };
00086   
00087   struct WrongSize : public MatrixInputError {
00088     int s1,s2 ;
00089     WrongSize(int a, int b) : s1(a), s2(b) { print_debug();}
00090     virtual void print(){
00091       cerr << "The vector sizes  " << s1 << " and " << s2 << " are incompatible.\n" ;
00092     }
00093   }; 
00094   
00095   struct WrongSize2D : public MatrixInputError {
00096     int rows,cols ;
00097     int bad_rows, bad_cols ;
00098     WrongSize2D(int r, int c, int br, int bc) : rows(r), cols(c), bad_rows(br), bad_cols(bc) { print_debug();}
00099     virtual void print(){
00100       cerr << "The matrix sizes  (" << rows << " x " << cols << ") and (" << bad_rows << " x " << bad_cols << ") are incompatible.\n" ;
00101     }
00102   }; 
00103   
00111  class Error : public ErrorStream
00112  {
00113  private:
00114    char* prog;
00115    void report(const char *msg = NULL);
00116  public:
00117    Error(): ErrorStream(), prog(0) {}
00118    Error(const char *s);
00119    ~Error(){ if (prog) delete []prog ; }
00120    
00121    void warning(const char *msg = 0);
00122    void nonfatal(const char *msg = 0) { warning(msg); }
00123    void fatal(const char * = 0 );
00124    void memory(const void * = 0 );
00125    
00126  };
00127 
00128 } // end namespace
00129 
00130 #ifdef INCLUDE_TEMPLATE_SOURCE
00131 #ifndef USING_VCC
00132 #include "error.cpp"
00133 #endif
00134 #endif
00135 
00136 
00137 
00138 #endif
00139 

Generated on Tue Jun 24 13:26:55 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002