]> SALOME platform Git repositories - modules/yacs.git/blob - src/Utils/utilities.h
Salome HOME
sources v1.2
[modules/yacs.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 <stdlib.h>
35 # include <iostream>
36
37
38
39 //VRV: T2.4 - replacement macro for using special CORBA server
40 #include "SALOME_Trace.hxx"
41 //VRV: T2.4 - replacement macro for using special CORBA server
42
43 /* ---  INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
44
45 //VRV: T2.4 - replacement of these macros for using special CORBA server
46
47 #define INFOS(msg) { GLogger.putMessage(GLogger << __FILE__<< " [" << __LINE__ << "] : " << msg<< endl << ends ); }
48 #define PYSCRIPT(msg) { GLogger.putMessage(GLogger<<"---PYSCRIPT--- "<<msg<<endl<<ends ); }
49
50 //# define HEREWEARE {cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;}
51 //# define INFOS(chain) {HEREWEARE ; cerr << chain << endl ;}
52 //# define PYSCRIPT(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
53
54 //VRV: T2.4 - replacement of these macros for using special CORBA server
55
56
57 /* --- To print date and time of compilation of current source on stdout --- */
58
59 # if defined ( __GNUC__ )
60 # define COMPILER               "g++" 
61 # elif defined ( __sun )
62 # define COMPILER               "CC" 
63 # elif defined ( __KCC )
64 # define COMPILER               "KCC" 
65 # elif defined ( __PGI )
66 # define COMPILER               "pgCC" 
67 # else
68 # define COMPILER               "undefined" 
69 # endif
70
71 # ifdef INFOS_COMPILATION
72 # error INFOS_COMPILATION already defined
73 # endif
74
75 //VRV: T2.4 - replacement macro for using special CORBA server
76 #define INFOS_COMPILATION { \
77                               GLogger.putMessage(\
78                                                  GLogger << __FILE__ << " [" << __LINE__ << "] : "\
79                                                  << "COMPILED with " << COMPILER \
80                                                  << ", " << __DATE__ \
81                                                  << " at " << __TIME__ << endl << endl <<endl<<ends); }
82 /* # define INFOS_COMPILATION   {\ */
83 /*                                      cerr << flush;\ */
84 /*                                      cout << __FILE__ ;\ */
85 /*                                      cout << " [" << __LINE__ << "] : " ;\ */
86 /*                                      cout << "COMPILED with " << COMPILER ;\ */
87 /*                                      cout << ", " << __DATE__ ; \ */
88 /*                                      cout << " at " << __TIME__ << endl ;\ */
89 /*                                      cout << "\n\n" ;\ */
90 /*                                      cout << flush ;\ */
91 /*                              } */
92 //VRV: T2.4 - replacement macro for using special CORBA server
93
94 # ifdef _DEBUG_
95
96 /* --- the following MACROS are useful at debug time --- */
97
98 //VRV: T2.4 - replacement of these macros for using special CORBA server
99
100 #define MYTRACE GLogger << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " 
101
102 #define MESSAGE(msg) { GLogger.putMessage( MYTRACE <<msg<<endl<<ends); }
103 #define SCRUTE(var) { GLogger.putMessage( MYTRACE << #var << "=" << var <<endl<<ends); }
104
105 #define REPERE GLogger << "   --------------" << endl 
106 #define BEGIN_OF(msg) {REPERE ; MYTRACE << "Begin of: " << msg << endl ; REPERE ; GLogger.putMessage(GLogger<<ends); } 
107 #define END_OF(msg) {REPERE ; MYTRACE << "Normal end of: " << msg << endl ; REPERE ; GLogger.putMessage(GLogger<<ends); } 
108
109 # define HERE {cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;}
110
111 //VRV: T2.4 - replacement of these macros for using special CORBA server
112
113 # define INTERRUPTION(code) {HERE ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;}
114
115 # ifndef ASSERT
116 # define ASSERT(condition) if (!(condition)){ HERE ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION(1) ;}
117 # endif /* ASSERT */
118
119
120
121
122
123
124
125 # else /* ifdef _DEBUG_*/
126
127 #define HERE 
128 #define SCRUTE(var) {}
129 #define MESSAGE(msg) {}
130 #define REPERE
131 #define BEGIN_OF(msg) {}
132 #define END_OF(msg) {}
133
134 # define INTERRUPTION(code) {}
135
136 # ifndef ASSERT
137 # define ASSERT(condition) {}
138 # endif /* ASSERT */
139
140
141 # endif /* ifdef _DEBUG_*/
142
143 # endif /* ifndef UTILITIES_H */