OMKTracer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 *   Copyright (C) 2006 by Benoit Chanclou,bunraku   *
00003 *   bchanclo@irisa.fr   *
00004 *                                                                         *
00005 *   This program is free software; you can redistribute it and/or modify  *
00006 *   it under the terms of the GNU General Public License as published by  *
00007 *   the Free Software Foundation; either version 2 of the License, or     *
00008 *   (at your option) any later version.                                   *
00009 *                                                                         *
00010 *   This program is distributed in the hope that it will be useful,       *
00011 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013 *   GNU General Public License for more details.                          *
00014 *                                                                         *
00015 *   You should have received a copy of the GNU General Public License     *
00016 *   along with this program; if not, write to the                         *
00017 *   Free Software Foundation, Inc.,                                       *
00018 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019 ***************************************************************************/
00020 
00021 #ifndef OMK_TRACER_H
00022 #define OMK_TRACER_H
00023 
00024 #include "OBTTrace.h"
00025 #include "OMKOpenMASK.h"
00026 #include "OMKException.h"
00027 
00029 
00030 // We use defines instead of static constants because, those ones are defined 
00031 // after some other static variables which use trace. So they are not defined 
00032 // when the trace are made, thus there is a crash.
00036 #define OMK_DEBUG_WARNING "WARNING"
00041 #define OMK_DEBUG_FATAL_ERROR "FATAL ERROR"
00045 #define OMK_DEBUG_ERROR "ERROR"
00050 #define OMK_DEBUG_MESSAGE "MESSAGE"
00054 #define OMK_DEBUG_OMK "Kernel"
00058 #define OMK_DEBUG_OMK_EXEC "Kernel:Stack"
00062 #define OMK_DEBUG_OMK_OBJ "Kernel:Object"
00066 #define OMK_DEBUG_OMK_POL "Kernel:Polator"
00070 #define OMK_DEBUG_OMK_NAME "Kernel:Name"
00074 #define OMK_DEBUG_OMK_EVENT "Kernel:Event"
00078 #define OMK_DEBUG_OMK_MULTI "Kernel:Multi"
00082 #define OMK_DEBUG_OMK_EXT "Kernel:Extension"
00086 #define OMK_DEBUG_OMK_ATTR "Kernel:Attribute"
00090 #define OMK_DEBUG_OMK_TYPE "Kernel:Type"
00094 #define OMK_DEBUG_INP_EXT "Input:Extension"
00098 #define OMK_DEBUG_VIS "Vis"
00102 #define OMK_DEBUG_VIS_EXEC "Vis:Stack"
00106 #define OMK_DEBUG_III "Iii"
00110 #define OMK_DEBUG_INP "Inp"
00114 #define OMK_DEBUG_PVM "PVM"
00115 
00116 
00117 
00118 
00119 namespace OMK
00120 {
00121   class SimulatedObject ;
00122         class Extension ;
00123         class IAttribute ;
00124         class ExtensibleSimulatedObject ;
00125 
00126         //=============================================================================
00141         class OMK_API TracerIdTmp 
00142         {
00143         public:
00144                 TracerIdTmp( const char* id ) ;
00145                 ~TracerIdTmp() ;
00146         private:
00147                 bool _unregisterId ;
00148                 std::string _id ;
00149         };
00150 
00151 
00152         std::string OMK_API getAttrOwnerMsg( const IAttribute* attr ) ;
00153 
00156 
00157 
00158 
00159 
00160 
00161         std::string OMK_API debugMsg( const SimulatedObject* obj ) ;
00166         std::string OMK_API debugMsg( const Extension* ext, ExtensibleSimulatedObject* obj = 0 ) ;
00172         std::string OMK_API debugMsg( const IAttribute* attr ) ;
00174 }
00175 
00190 // Undefined the previous definition of OMERROR
00191 # ifdef OMERROR
00192 # undef OMERROR
00193 # endif
00194 // Define the OMERROR macro
00195 # define OMERROR(X) TRACE( OMK_DEBUG_ERROR, X )
00196 
00211 // Undefined the previous definition of OMMESSAGE
00212 # ifdef OMMESSAGE
00213 # undef OMMESSAGE
00214 # endif
00215 // Define the TRACE macro
00216 # define OMMESSAGE(X) TRACE( OMK_DEBUG_MESSAGE, X )
00217 
00222 # ifdef OMFATALERROR
00223 # undef OMFATALERROR
00224 # endif
00225 # define OMFATALERROR(X) \
00226 std::ostringstream msgForDebugTrace ; \
00227 msgForDebugTrace << X ; \
00228 TRACE( OMK_DEBUG_FATAL_ERROR, msgForDebugTrace.str() ) ; \
00229   throw OMK::Exception( msgForDebugTrace.str().c_str() ) ;
00230 
00247 // Undefined the previous definition of TRACE
00248 # ifdef OMTRACE
00249 # undef OMTRACE
00250 # endif
00251 // Define the TRACE macro
00252 # define OMTRACE(X) TRACE( OMK_DEBUG_WARNING, X )
00253 
00274 // Undefined the previous definition of TRACE
00275 # ifdef OMTRACEID
00276 # undef OMTRACEID
00277 # endif
00278 // Define the TRACE macro
00279 # define OMTRACEID(ID,X) TRACE( ID, X )
00280 
00281 #if defined NDEBUG
00282 // in non debug mode, nothing to do 
00283 # ifndef OMASSERT
00284 #   define OMASSERT(X) void()
00285 # endif
00286 # ifndef OMASSERTM
00287 #   define OMASSERTM(TEST,X) void()
00288 # endif
00289 
00290 #else // !NDEBUG
00291 // In debug mode
00292 
00315 // Undefined the previous definition of OMASSERT
00316 # ifdef OMASSERT
00317 #   undef OMASSERT
00318 # endif
00319 // Define the OMASSERT macro
00320 #   define OMASSERT(X) \
00321         if( !(X) ) \
00322 { \
00323         std::ostringstream msgForDebugASSERT ; \
00324         msgForDebugASSERT << #X ; \
00325         OMTRACEID( OMK_DEBUG_FATAL_ERROR, msgForDebugASSERT.str() ) ; \
00326   throw OMK::Exception( msgForDebugASSERT.str().c_str() ) ; \
00327 }
00328 
00350 #   define OMASSERTM(TEST, X) \
00351         if( !(TEST) ) \
00352 { \
00353         std::ostringstream msgForDebugASSERTM ; \
00354         msgForDebugASSERTM << #TEST << std::endl << X ; \
00355         OMTRACEID( OMK_DEBUG_FATAL_ERROR, msgForDebugASSERTM.str() ) ; \
00356   throw OMK::Exception( msgForDebugASSERTM.str().c_str() ) ; \
00357 }
00358 
00359 #endif // !NDEBUG
00360 
00361 #endif // !OMK_TRACER_H

logo OpenMask

Documentation generated on Mon Jun 9 11:45:57 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007