share/Errors.hxx

00001 // Copyright (C) 2001-2009 Vivien Mallet
00002 //
00003 // This file is part of the linear-algebra library Seldon,
00004 // http://seldon.sourceforge.net/.
00005 //
00006 // Seldon is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU Lesser General Public License as published by the Free
00008 // Software Foundation; either version 2.1 of the License, or (at your option)
00009 // any later version.
00010 //
00011 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
00014 // more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public License
00017 // along with Seldon. If not, see http://www.gnu.org/licenses/.
00018 
00019 
00020 #ifndef SELDON_FILE_ERRORS_HXX
00021 
00022 #include <string>
00023 #include <iostream>
00024 #include "Common.hxx"
00025 
00026 
00027 namespace Seldon
00028 {
00029 
00030 
00031   using namespace std;
00032 
00033 
00035   // ERROR //
00037 
00038   class Error
00039   {
00040   protected:
00042     string description_;
00044     string function_;
00046     string comment_;
00047 
00048   public:
00049     Error(string function = "", string comment = "");
00050     Error(string description, string function, string comment);
00051     virtual ~Error();
00052 
00053     virtual string What();
00054     void CoutWhat();
00055   };
00056 
00057 
00059   // UNDEFINED //
00061 
00062   class Undefined: public Error
00063   {
00064   public:
00065     Undefined(string function = "", string comment = "");
00066 
00067     virtual string What();
00068   };
00069 
00070 
00072   // WRONGARGUMENT //
00074 
00075   class WrongArgument: public Error
00076   {
00077   public:
00078     WrongArgument(string function = "", string comment = "");
00079 
00080     virtual string What();
00081   };
00082 
00083 
00085   // NOMEMORY //
00087 
00088   class NoMemory: public Error
00089   {
00090   public:
00091     NoMemory(string function = "", string comment = "");
00092   };
00093 
00094 
00096   // WRONGDIM //
00098 
00099   class WrongDim: public Error
00100   {
00101   public:
00102     WrongDim(string function = "", string comment = "");
00103   };
00104 
00105 
00107   // WRONGINDEX //
00109 
00110   class WrongIndex: public Error
00111   {
00112   public:
00113     WrongIndex(string function = "", string comment = "");
00114   };
00115 
00116 
00118   // WRONGROW //
00120 
00121   class WrongRow: public Error
00122   {
00123   public:
00124     WrongRow(string function = "", string comment = "");
00125   };
00126 
00127 
00129   // WRONGCOL //
00131 
00132   class WrongCol: public Error
00133   {
00134   public:
00135     WrongCol(string function = "", string comment = "");
00136   };
00137 
00138 
00140   // IOERROR //
00142 
00143   class IOError: public Error
00144   {
00145   public:
00146     IOError(string function = "", string comment = "");
00147   };
00148 
00149 
00151   // LAPACKERROR //
00153 
00154   class LapackError: public Error
00155   {
00156   protected:
00157     int info_;
00158 
00159   public:
00160     LapackError(int info, string function, string comment);
00161 
00162     virtual string What();
00163   };
00164 
00165 
00167   // LAPACKINFO //
00169 
00170 
00171   class LapackInfo
00172   {
00173   private:
00174     int info_;
00175 
00176   public:
00177     LapackInfo(int info);
00178 
00179 #ifndef SWIG
00180     operator int ();
00181 #endif
00182 
00183     int GetInfo();
00184     int& GetInfoRef();
00185   };
00186 
00187 
00188   extern LapackInfo lapack_info;
00189 
00190 
00191 } // namespace Seldon.
00192 
00193 #define SELDON_FILE_ERRORS_HXX
00194 #endif