/src/contrib/geom-5.1.2.7/inc/utilities.h

http://pythonocc.googlecode.com/ · C++ Header · 131 lines · 69 code · 25 blank · 37 comment · 2 complexity · afe8e6773cd02c7d9ff78a283da0b342 MD5 · raw file

  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
  21. //
  22. //
  23. //
  24. // File : utilities.h
  25. // Author : Antoine YESSAYAN, Paul RASCLE, EDF
  26. // Module : SALOME
  27. // $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/SALOMELocalTrace/utilities.h,v 1.6.2.1 2007/01/22 13:51:27 prascle Exp $
  28. /* --- Definition macros file to print informations if _DEBUG_ or _DEBUG is defined --- */
  29. #ifndef UTILITIES_H
  30. #define UTILITIES_H
  31. #include <iostream>
  32. #include <sstream>
  33. #include <cstdlib>
  34. //Can be redefined to reflect another buffer such as log, cerr or a custom one
  35. #define DEF_MSG_BUFFER std::cout
  36. /*!
  37. * For each message to put in the trace, a specific ostingstream object is
  38. * created and destroyed automatically at the end of the message macro.
  39. * This message is automatically passed to std::cout
  40. */
  41. #define MESS_INIT(deb) std::ostringstream os; os<<deb
  42. #define MESS_BEGIN(deb) MESS_INIT(deb)<<__FILE__<<" ["<<__LINE__<<"] : "
  43. #define MESS_END std::endl; \
  44. DEF_MSG_BUFFER << os.str() << std::endl;
  45. #define MESS_ABORT std::endl; \
  46. DEF_MSG_BUFFER << os.str() << std::endl;
  47. // --- Some macros are always defined (without _DEBUG_): for use with release version
  48. #define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
  49. #define PYSCRIPT(msg) {MESS_INIT("---PYSCRIPT--- ") << msg << MESS_END}
  50. #define INTERRUPTION(msg) {MESS_BEGIN("- INTERRUPTION: ")<< msg << MESS_ABORT}
  51. #ifdef WNT
  52. #define IMMEDIATE_ABORT(code) {std::cout <<std::flush; \
  53. std::cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
  54. std::cerr << "ABORT return code= "<< code << std::endl; \
  55. exit(code);}
  56. #else
  57. #define IMMEDIATE_ABORT(code) {std::cout <<std::flush; \
  58. std::cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
  59. std::cerr << "ABORT return code= "<< code << std::endl; \
  60. std::exit(code);}
  61. #endif
  62. /* --- To print date and time of compilation of current source --- */
  63. #if defined ( __GNUC__ )
  64. #define COMPILER "g++"
  65. #elif defined ( __sun )
  66. #define COMPILER "CC"
  67. #elif defined ( __KCC )
  68. #define COMPILER "KCC"
  69. #elif defined ( __PGI )
  70. #define COMPILER "pgCC"
  71. #elif defined ( __alpha )
  72. #define COMPILER "cxx"
  73. #elif defined ( __BORLAND__ )
  74. #define COMPILER "bcc32"
  75. #else
  76. #define COMPILER "undefined"
  77. #endif
  78. #ifdef INFOS_COMPILATION
  79. #error INFOS_COMPILATION already defined
  80. #endif
  81. #if defined(_DEBUG_) || defined (_DEBUG)
  82. // --- the following MACROS are useful at debug time
  83. #define INFOS_COMPILATION { MESS_BEGIN("COMPILED with ") << COMPILER \
  84. << ", " << __DATE__ \
  85. << " at " << __TIME__ << MESS_END }
  86. #define MESSAGE(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
  87. #define SCRUTE(var) {MESS_BEGIN("- Trace ") << #var << "=" << var <<MESS_END}
  88. #define REPERE ("------- ")
  89. #define BEGIN_OF(msg) {MESS_BEGIN(REPERE) << "Begin of: " << msg << MESS_END}
  90. #define END_OF(msg) {MESS_BEGIN(REPERE) << "Normal end of: " << msg << MESS_END}
  91. #ifndef ASSERT
  92. #define ASSERT(condition) \
  93. if (!(condition)){INTERRUPTION("CONDITION "<<#condition<<" NOT VERIFIED")}
  94. #endif /* ASSERT */
  95. #else /* ifdef _DEBUG_*/
  96. #define INFOS_COMPILATION
  97. #define MESSAGE(msg) {MESS_BEGIN("MSG:") << msg << MESS_END}
  98. #define SCRUTE(var) {MESS_BEGIN("SCRUTE:") << #var << " = " << var << MESS_END}
  99. #define REPERE ("-------")
  100. #define BEGIN_OF(msg) {MESS_BEGIN("MSG BEGIN:") << msg << MESS_END}
  101. #define END_OF(msg) {MESS_BEGIN("MSG END:") << msg << MESS_END}
  102. #ifndef ASSERT
  103. #define ASSERT(condition) {}
  104. #endif /* ASSERT */
  105. #endif /* ifdef _DEBUG_*/
  106. #endif /* ifndef UTILITIES_H */