Back to index

salome-med  6.5.0
MED_Utilities.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 
00023 //  File   : 
00024 //  Author : 
00025 //  Module : 
00026 //  $Header: /home/server/cvs/MED/MED_SRC/src/MEDWrapper/Base/MED_Utilities.hxx,v 1.6.2.2.6.2.10.1 2012-04-13 08:48:43 vsr Exp $
00027 //
00028 #ifndef MED_Utilities_HeaderFile
00029 #define MED_Utilities_HeaderFile
00030 
00031 #include "MED_WrapperBase.hxx"
00032 
00033 #include <iostream>     
00034 #include <sstream>      
00035 #include <string>
00036 #include <string.h>
00037 #include <stdexcept>
00038 
00039 
00040 namespace MED
00041 {
00042   class MEDWRAPPER_EXPORT PrefixPrinter
00043   {
00044     static int myCounter;
00045     bool myIsActive;
00046   public:
00047     PrefixPrinter(bool theIsActive = true);
00048     ~PrefixPrinter();
00049 
00050     static std::string GetPrefix();
00051   };
00052 }
00053 
00054 #ifdef _DEBUG_
00055   #define MSG(deb,msg) if(deb) std::cout<<MED::PrefixPrinter::GetPrefix()<<msg<<" ("<<__FILE__<<" ["<<__LINE__<<"])\n"
00056   #define BEGMSG(deb,msg) if(deb) std::cout<<MED::PrefixPrinter::GetPrefix()<<msg
00057   #define INITMSGA(deb,lev,msg) MED::PrefixPrinter aPrefixPrinter_##lev(deb); BEGMSG(deb,msg)
00058   #define INITMSG(deb,msg) INITMSGA(deb,,msg)
00059   #define ADDMSG(deb,msg) if(deb) std::cout<<msg
00060 #else
00061   #define MSG(deb,msg)
00062   #define BEGMSG(deb,msg)
00063   #define INITMSGA(deb,lev,msg)
00064   #define INITMSG(deb,msg)
00065   #define ADDMSG(deb,msg)
00066 #endif
00067 
00068 
00069 #ifndef EXCEPTION
00070 
00071 #define EXCEPTION(TYPE, MSG) {\
00072   std::ostringstream aStream;\
00073   aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
00074   throw TYPE(aStream.str().c_str());\
00075 }
00076 
00077 #endif
00078 
00079 #endif