1 //  SALOME Utils : general SALOME's definitions and tools
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : utilities.h
25 //  Author : Antoine YESSAYAN, Paul RASCLE, EDF
26 //  Module : SALOME
27 //  $Header: /cvs/netgen/netgen/libsrc/occ/utilities.h,v 1.3 2008/03/31 14:20:28 wabro Exp $
28 
29 /* ---  Definition macros file to print informations if _DEBUG_ is defined --- */
30 
31 #ifndef UTILITIES_H
32 #define UTILITIES_H
33 
34 #include <string>
35 #include <iostream>
36 #include <cstdlib>
37 // #include "SALOME_Log.hxx"
38 
39 /* ---  INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
40 
41 #define INFOS(msg)    {SLog->putMessage(*SLog<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<endl);}
42 #define PYSCRIPT(msg) {SLog->putMessage(*SLog<<"---PYSCRIPT--- "<<msg<<endl);}
43 
44 /* --- To print date and time of compilation of current source --- */
45 
46 #if defined ( __GNUC__ )
47 #define COMPILER		"g++"
48 #elif defined ( __sun )
49 #define COMPILER		"CC"
50 #elif defined ( __KCC )
51 #define COMPILER		"KCC"
52 #elif defined ( __PGI )
53 #define COMPILER		"pgCC"
54 #elif defined ( __alpha )
55 #define COMPILER		"cxx"
56 #else
57 #define COMPILER		"undefined"
58 #endif
59 
60 #ifdef INFOS_COMPILATION
61 #error INFOS_COMPILATION already defined
62 #endif
63 
64 #define INFOS_COMPILATION { \
65 			   SLog->putMessage(\
66 					   *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\
67 					   << "COMPILED with " << COMPILER \
68 					   << ", " << __DATE__ \
69 					   << " at " << __TIME__ <<endl); }
70 
71 #ifdef _DEBUG_
72 
73 /* --- the following MACROS are useful at debug time --- */
74 
75 #define MYTRACE *SLog << "- Trace " << __FILE__ << " [" << __LINE__ << "] : "
76 
77 #define MESSAGE(msg) {SLog->putMessage( MYTRACE <<msg<<endl<<ends); }
78 #define SCRUTE(var)  {SLog->putMessage( MYTRACE << #var << "=" << var <<endl<<ends); }
79 
80 #define REPERE *SLog << "   --------------" << endl
81 #define BEGIN_OF(msg) {REPERE;MYTRACE<<"Begin of: "     <<msg<<endl;REPERE;}
82 #define END_OF(msg)   {REPERE;MYTRACE<<"Normal end of: "<<msg<<endl;REPERE;}
83 
84 #define HERE {cout<<flush ;cerr<<"- Trace "<<__FILE__<<" ["<<__LINE__<<"] : "<<flush ;}
85 
86 #define INTERRUPTION(code) {HERE;cerr<<"INTERRUPTION return code= "<<code<< endl;std::exit(code);}
87 
88 #ifndef ASSERT
89 #define ASSERT(condition) \
90         if (!(condition)){HERE;cerr<<"CONDITION "<<#condition<<" NOT VERIFIED"<<endl;INTERRUPTION(1);}
91 #endif /* ASSERT */
92 
93 
94 #else /* ifdef _DEBUG_*/
95 
96 #define HERE
97 #define SCRUTE(var) {}
98 #define MESSAGE(msg) {}
99 #define REPERE
100 #define BEGIN_OF(msg) {}
101 #define END_OF(msg) {}
102 
103 #define INTERRUPTION(code) {}
104 
105 #ifndef ASSERT
106 #define ASSERT(condition) {}
107 #endif /* ASSERT */
108 
109 
110 #endif /* ifdef _DEBUG_*/
111 
112 #endif /* ifndef UTILITIES_H */
113