Salome HOME
This commit was generated by cvs2git to create tag 'V1_4_0b2'.
[modules/kernel.git] / src / Utils / utilities.h
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$
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 "SALOME_Log.hxx"
37
38 /* ---  INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
39
40 #define INFOS(msg)    {SLog->putMessage(*SLog<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<endl);}
41 #define PYSCRIPT(msg) {SLog->putMessage(*SLog<<"---PYSCRIPT--- "<<msg<<endl);}
42
43 /* --- To print date and time of compilation of current source --- */
44
45 #if defined ( __GNUC__ )
46 #define COMPILER                "g++" 
47 #elif defined ( __sun )
48 #define COMPILER                "CC" 
49 #elif defined ( __KCC )
50 #define COMPILER                "KCC" 
51 #elif defined ( __PGI )
52 #define COMPILER                "pgCC" 
53 #else
54 #define COMPILER                "undefined" 
55 #endif
56
57 #ifdef INFOS_COMPILATION
58 #error INFOS_COMPILATION already defined
59 #endif
60
61 #define INFOS_COMPILATION { \
62                            SLog->putMessage(\
63                                            *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\
64                                            << "COMPILED with " << COMPILER \
65                                            << ", " << __DATE__ \
66                                            << " at " << __TIME__ <<endl); }
67
68 #ifdef _DEBUG_
69
70 /* --- the following MACROS are useful at debug time --- */
71
72 #define MYTRACE *SLog << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " 
73
74 #define MESSAGE(msg) {SLog->putMessage( MYTRACE <<msg<<endl<<ends); }
75 #define SCRUTE(var)  {SLog->putMessage( MYTRACE << #var << "=" << var <<endl<<ends); }
76
77 #define REPERE *SLog << "   --------------" << endl 
78 #define BEGIN_OF(msg) {REPERE;MYTRACE<<"Begin of: "     <<msg<<endl;REPERE;} 
79 #define END_OF(msg)   {REPERE;MYTRACE<<"Normal end of: "<<msg<<endl;REPERE;} 
80
81 #define HERE {cout<<flush ;cerr<<"- Trace "<<__FILE__<<" ["<<__LINE__<<"] : "<<flush ;}
82
83 #define INTERRUPTION(code) {HERE;cerr<<"INTERRUPTION return code= "<<code<< endl;exit(code);}
84
85 #ifndef ASSERT
86 #define ASSERT(condition) \
87         if (!(condition)){HERE;cerr<<"CONDITION "<<#condition<<" NOT VERIFIED"<<endl;INTERRUPTION(1);}
88 #endif /* ASSERT */
89
90
91 #else /* ifdef _DEBUG_*/
92
93 #define HERE 
94 #define SCRUTE(var) {}
95 #define MESSAGE(msg) {}
96 #define REPERE
97 #define BEGIN_OF(msg) {}
98 #define END_OF(msg) {}
99
100 #define INTERRUPTION(code) {}
101
102 #ifndef ASSERT
103 #define ASSERT(condition) {}
104 #endif /* ASSERT */
105
106
107 #endif /* ifdef _DEBUG_*/
108
109 #endif /* ifndef UTILITIES_H */