PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 29/* ---  Definition macros file to print informations if _DEBUG_ or _DEBUG is defined --- */
 30
 31#ifndef UTILITIES_H
 32#define UTILITIES_H
 33
 34#include <iostream>
 35#include <sstream>
 36#include <cstdlib>
 37
 38//Can be redefined to reflect another buffer such as log, cerr or a custom one
 39#define DEF_MSG_BUFFER std::cout
 40
 41/*!
 42 * For each message to put in the trace, a specific ostingstream object is
 43 * created and destroyed automatically at the end of the message macro.
 44 * This message is automatically passed to std::cout
 45 */
 46
 47#define MESS_INIT(deb) std::ostringstream os; os<<deb
 48#define MESS_BEGIN(deb) MESS_INIT(deb)<<__FILE__<<" ["<<__LINE__<<"] : "
 49
 50#define MESS_END std::endl; \
 51DEF_MSG_BUFFER << os.str() << std::endl;
 52
 53#define MESS_ABORT std::endl; \
 54DEF_MSG_BUFFER << os.str() << std::endl;
 55
 56// --- Some macros are always defined (without _DEBUG_): for use with release version
 57
 58#define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
 59#define PYSCRIPT(msg) {MESS_INIT("---PYSCRIPT--- ") << msg << MESS_END}
 60#define INTERRUPTION(msg) {MESS_BEGIN("- INTERRUPTION: ")<< msg << MESS_ABORT}
 61#ifdef WNT
 62#define IMMEDIATE_ABORT(code) {std::cout <<std::flush; \
 63                               std::cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
 64                               std::cerr << "ABORT return code= "<< code << std::endl; \
 65                               exit(code);}
 66#else
 67#define IMMEDIATE_ABORT(code) {std::cout <<std::flush; \
 68                               std::cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
 69                               std::cerr << "ABORT return code= "<< code << std::endl; \
 70                               std::exit(code);}
 71#endif
 72
 73/* --- To print date and time of compilation of current source --- */
 74
 75#if defined ( __GNUC__ )
 76#define COMPILER		"g++" 
 77#elif defined ( __sun )
 78#define COMPILER		"CC" 
 79#elif defined ( __KCC )
 80#define COMPILER		"KCC" 
 81#elif defined ( __PGI )
 82#define COMPILER		"pgCC" 
 83#elif defined ( __alpha )
 84#define COMPILER		"cxx"
 85#elif defined ( __BORLAND__ )
 86#define COMPILER		"bcc32"
 87#else
 88#define COMPILER		"undefined" 
 89#endif
 90
 91#ifdef INFOS_COMPILATION
 92#error INFOS_COMPILATION already defined
 93#endif
 94
 95#if defined(_DEBUG_) || defined (_DEBUG)
 96
 97// --- the following MACROS are useful at debug time
 98
 99#define INFOS_COMPILATION { MESS_BEGIN("COMPILED with ") << COMPILER \
100				       << ", " << __DATE__ \
101				       << " at " << __TIME__ << MESS_END }
102
103#define MESSAGE(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
104#define SCRUTE(var)  {MESS_BEGIN("- Trace ") << #var << "=" << var <<MESS_END}
105
106#define REPERE ("------- ")
107#define BEGIN_OF(msg) {MESS_BEGIN(REPERE) << "Begin of: "      << msg << MESS_END} 
108#define END_OF(msg)   {MESS_BEGIN(REPERE) << "Normal end of: " << msg << MESS_END} 
109
110#ifndef ASSERT
111#define ASSERT(condition) \
112        if (!(condition)){INTERRUPTION("CONDITION "<<#condition<<" NOT VERIFIED")}
113#endif /* ASSERT */
114
115
116#else /* ifdef _DEBUG_*/
117
118#define INFOS_COMPILATION
119#define MESSAGE(msg) {MESS_BEGIN("MSG:") << msg << MESS_END}
120#define SCRUTE(var)  {MESS_BEGIN("SCRUTE:") << #var << " = " << var << MESS_END}
121#define REPERE ("-------")
122#define BEGIN_OF(msg) {MESS_BEGIN("MSG BEGIN:") << msg << MESS_END}
123#define END_OF(msg) {MESS_BEGIN("MSG END:") << msg << MESS_END}
124
125#ifndef ASSERT
126#define ASSERT(condition) {}
127#endif /* ASSERT */
128
129#endif /* ifdef _DEBUG_*/
130
131#endif /* ifndef UTILITIES_H */