SALOME documentation central

src/Utils/Utils_SALOME_Exception.hxx

00001 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 //  This library is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU Lesser General Public
00008 //  License as published by the Free Software Foundation; either
00009 //  version 2.1 of the License.
00010 //
00011 //  This library 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 GNU
00014 //  Lesser General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU Lesser General Public
00017 //  License along with this library; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  SALOME Utils : general SALOME's definitions and tools
00023 //  File   : Utils_SALOME_Exception.hxx
00024 //  Author : Antoine YESSAYAN, EDF
00025 //  Module : SALOME
00026 //  $Header$
00027 //
00028 #if !defined( __Utils_SALOME_Exception_hxx__ )
00029 #define __Utils_SALOME_Exception_hxx__
00030 
00031 //#include "SALOME_Utils.hxx"
00032 
00033 # include <exception>
00034 # include <iostream>
00035 
00036 #ifdef LOCALIZED
00037 #undef LOCALIZED
00038 #endif
00039 #if defined(_DEBUG_) || defined(_DEBUG)
00040 # define LOCALIZED(message) #message , __FILE__ , __LINE__
00041 #else
00042 # define LOCALIZED(message) #message
00043 #endif
00044 
00045 //swig tool on Linux doesn't pass defines from header SALOME_Utils.hxx
00046 //therefore (temporary solution) defines are placed below
00047 
00048 #ifdef WIN32
00049 # if defined UTILS_EXPORTS || defined OpUtil_EXPORTS
00050 #  define UTILS_EXPORT __declspec( dllexport )
00051 # else
00052 #  define UTILS_EXPORT __declspec( dllimport )
00053 #  define LOCALIZED(message) #message
00054 # endif
00055 #else
00056 # define UTILS_EXPORT
00057 #endif
00058 
00059 class SALOME_Exception;
00060 
00061 UTILS_EXPORT std::ostream& operator<<( std::ostream&, const SALOME_Exception& );
00062 
00063 UTILS_EXPORT const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber );
00064 
00065 class UTILS_EXPORT SALOME_Exception : public std::exception
00066 {
00067 
00068 private :
00069      SALOME_Exception( void );
00070 
00071 protected :
00072      const char* _text ; // non constant pointer but read only char variable
00073 
00074 public :
00075      SALOME_Exception( const char *text, const char *fileName=0, const unsigned int lineNumber=0 );
00076      SALOME_Exception( const SALOME_Exception &ex );
00077      virtual ~SALOME_Exception() throw ();
00078      friend std::ostream & operator<<( std::ostream &os , const SALOME_Exception &ex );
00079      virtual const char *what( void ) const throw () ;
00080 } ;
00081 
00082 
00083 #endif         /* #if !defined( __Utils_SALOME_Exception_hxx__ ) */