Home | History | Annotate | Download | only in utils
      1 //=============================================================================
      2 // File      : utilities.h
      3 // Created   : mar jun 19 13:18:14 CEST 2001
      4 // Author    : Antoine YESSAYAN, Paul RASCLE, EDF
      5 // Project   : SALOME
      6 // Copyright : EDF 2001
      7 // $Header$
      8 //=============================================================================
      9 
     10 /* ---  Definition macros file to print information if _DEBUG_ is defined --- */
     11 
     12 # ifndef UTILITIES_H
     13 # define UTILITIES_H
     14 
     15 # include <stdlib.h>
     16 //# include <iostream> ok for gcc3.01
     17 # include <iostream>
     18 
     19 /* ---  INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
     20 
     21 # define HEREWEARE cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;
     22 # define INFOS(chain) {HEREWEARE ; cerr << chain << endl ;}
     23 # define PYSCRIPT(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
     24 
     25 /* --- To print date and time of compilation of current source on stdout --- */
     26 
     27 # if defined ( __GNUC__ )
     28 # define COMPILER		"g++" ;
     29 # elif defined ( __sun )
     30 # define COMPILER		"CC" ;
     31 # elif defined ( __KCC )
     32 # define COMPILER		"KCC" ;
     33 # elif defined ( __PGI )
     34 # define COMPILER		"pgCC" ;
     35 # else
     36 # define COMPILER		"undefined" ;
     37 # endif
     38 
     39 # ifdef INFOS_COMPILATION
     40 # error INFOS_COMPILATION already defined
     41 # endif
     42 # define INFOS_COMPILATION	{\
     43 					cerr << flush;\
     44 					cout << __FILE__ ;\
     45 					cout << " [" << __LINE__ << "] : " ;\
     46 					cout << "COMPILED with " << COMPILER ;\
     47 					cout << ", " << __DATE__ ; \
     48 					cout << " at " << __TIME__ << endl ;\
     49 					cout << "\n\n" ;\
     50 					cout << flush ;\
     51 				}
     52 
     53 # ifdef _DEBUG_
     54 
     55 /* --- the following MACROS are useful at debug time --- */
     56 
     57 # define HERE cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;
     58 # define SCRUTE(var) HERE ; cerr << #var << "=" << var << endl ;
     59 # define MESSAGE(chain) {HERE ; cerr << chain << endl ;}
     60 # define INTERRUPTION(code) HERE ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;
     61 
     62 # ifndef ASSERT
     63 # define ASSERT(condition) if (!(condition)){ HERE ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION(1) ;}
     64 # endif /* ASSERT */
     65 
     66 #define REPERE cout<<flush ; cerr << "   --------------" << endl << flush ;
     67 #define BEGIN_OF(chain) {REPERE ; HERE ; cerr << "Begin of: " << chain << endl ; REPERE ; }
     68 #define END_OF(chain) {REPERE ; HERE ; cerr << "Normal end of: " << chain << endl ; REPERE ; }
     69 
     70 
     71 
     72 # else /* ifdef _DEBUG_*/
     73 
     74 # define HERE
     75 # define SCRUTE(var)
     76 # define MESSAGE(chain)
     77 # define INTERRUPTION(code)
     78 
     79 # ifndef ASSERT
     80 # define ASSERT(condition)
     81 # endif /* ASSERT */
     82 
     83 #define REPERE
     84 #define BEGIN_OF(chain)
     85 #define END_OF(chain)
     86 
     87 
     88 # endif /* ifdef _DEBUG_*/
     89 
     90 # endif /* ifndef UTILITIES_H */
     91