Main Page | User's guide | Class Hierarchy | Class List | File List | Class Members

errors.hxx

00001 // Copyright (C) 2002-2004 Vivien Mallet
00002 //
00003 // This file is part of Multivac library.
00004 // Multivac library provides front-tracking algorithms.
00005 // 
00006 // Multivac is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // Multivac is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License (file "license") for more details.
00015 //
00016 // For more information, please see the Multivac home page:
00017 //     http://spacetown.free.fr/fronts/
00018 
00019 
00020 #ifndef FILE_MULTIVAC_ERRORS_HXX
00021 
00022 
00023 #include <iostream>
00024 using std::cout;
00025 using std::endl;
00026 #include <string>
00027 
00028 
00029 namespace Multivac
00030 {
00031 
00032 
00034   // CERROR //
00036 
00038   class CError
00039   {
00040   protected:
00041     char* function;
00042     char* comment;
00043 
00044   public:
00045     CError()
00046     {
00047       cout << "ERROR!" << endl;
00048       function=new char[1];
00049       function[0]='\0';
00050       comment=new char[1];
00051       comment[0]='\0';
00052     }
00053     CError(const char* f)
00054     {
00055       cout << "ERROR!" << endl;
00056       function=new char[strlen(f)+1];
00057       strcpy(function, f);
00058       function[strlen(f)] = '\0';
00059       comment=new char[1];
00060       comment[0]='\0';
00061     }
00062     CError(const char* f, const char* c)
00063     {
00064       cout << "ERROR!" << endl;
00065       function=new char[strlen(f)+1];
00066       strcpy(function, f);
00067       function[strlen(f)] = '\0';
00068       comment=new char[strlen(c)+1];
00069       strcpy(comment, c);
00070       comment[strlen(c)] = '\0';
00071     }
00072     virtual void What()
00073     {
00074       cout << "An undefined error occured";
00075       if (strlen(function)!=0)
00076         cout << " in " << function;
00077       cout << "." << endl;
00078       if (strlen(comment)!=0)
00079         cout << "   " << comment << "." << endl;
00080       cout << endl;
00081     }
00082   };
00083 
00084   
00086   // FILEIO //
00088 
00091   class CError_FileIO: public CError
00092   {
00093   public:
00094     CError_FileIO(const char* f): CError(f)
00095     {
00096     }
00097     CError_FileIO(const char* f, const char* c): CError(f, c)
00098     {
00099     }
00100     virtual void What()
00101     {
00102       cout << "Error while performing an I/O operation (with files)";
00103       if (this->function!="")
00104         cout << " in " << this->function;
00105       cout << "." << endl;
00106       if (this->comment!="")
00107         cout << "   " << this->comment << "." << endl;
00108       cout << endl;
00109     }
00110   };
00111 
00112 
00114   // OUTOFDOMAIN //
00116 
00118   class CError_OutOfDomain: public CError
00119   {
00120   public:
00121     CError_OutOfDomain(const char* f): CError(f)
00122     {
00123     }
00124     CError_OutOfDomain(const char* f, const char* c): CError(f, c)
00125     {
00126     }
00127     virtual void What()
00128     {
00129       cout << "Computation outside the domain";
00130       if (this->function!="")
00131         cout << " in " << this->function;
00132       cout << "." << endl;
00133       if (this->comment!="")
00134         cout << "   " << this->comment << "." << endl;
00135       cout << endl;
00136     }
00137   };
00138 
00139 
00141   // INSTABILITY //
00143 
00145   class CError_Instability: public CError
00146   {
00147   public:
00148     CError_Instability(const char* f): CError(f)
00149     {
00150     }
00151     CError_Instability(const char* f, const char* c): CError(f, c)
00152     {
00153     }
00154     virtual void What()
00155     {
00156       cout << "Computations stopped because of an instability";
00157       if (this->function!="")
00158         cout << " in " << this->function;
00159       cout << "." << endl;
00160       if (this->comment!="")
00161         cout << "   " << this->comment << "." << endl;
00162       cout << endl;
00163     }
00164   };
00165 
00166 
00168   // INCOMPATIBILITY //
00170 
00172   class CError_Incompatibility: public CError
00173   {
00174   public:
00175     CError_Incompatibility(const char* f): CError(f)
00176     {
00177     }
00178     CError_Incompatibility(const char* f, const char* c): CError(f, c)
00179     {
00180     }
00181     virtual void What()
00182     {
00183       cout << "An incompatibility has been detected in your choices";
00184       if (this->function!="")
00185         cout << " in " << this->function;
00186       cout << "." << endl;
00187       if (this->comment!="")
00188         cout << "   " << this->comment << "." << endl;
00189       cout << endl;
00190     }
00191   };
00192 
00193 
00195   // UNDEFINED FUNCTION //
00197 
00199   class CError_Undefined: public CError
00200   {
00201   public:
00202     CError_Undefined(const char* f): CError(f)
00203     {
00204     }
00205     CError_Undefined(const char* f, const char* c): CError(f, c)
00206     {
00207     }
00208     virtual void What()
00209     {
00210       cout << "Function ";
00211       if (this->function!="")
00212         cout << this->function;
00213       cout << " is not defined." << endl;
00214       if (this->comment!="")
00215         cout << "   " << this->comment << "." << endl;
00216       cout << endl;
00217     }
00218   };
00219   
00220 
00221 }  // namespace Multivac.
00222 
00223 
00224 #define FILE_MULTIVAC_ERROR_HXX
00225 #endif

Generated on Mon Apr 19 01:59:14 2004 for Multivac by doxygen 1.3.6-20040222