Main Page   Class Hierarchy   Compound List   File List   Compound Members  

debug.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2002 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // 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 Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 #ifndef freecloth_base_debug_h
00020 #define freecloth_base_debug_h
00021 
00022 #ifndef freecloth_base_package_h
00023 #include <freecloth/base/package.h>
00024 #endif
00025 
00026 // Since the debug build will need this for tracing, we'll also include it
00027 // in the release build. We want the two to have similar levels of
00028 // knowledge of standard headers.
00029 #include <freecloth/base/iostream>
00030 
00031 #ifdef NDEBUG
00032 
00033 #define DGFX_ASSERT(x)
00034 #define DGFX_TRACE_ENTER(x)
00035 #define DGFX_TRACE(x)
00036 
00037 #else
00038 
00039 #include <assert.h>
00040 
00041 #ifndef freecloth_base_baTraceEntry_h
00042 #include <freecloth/base/baTraceEntry.h>
00043 #endif
00044 
00045 #ifndef freecloth_base_baTraceStream_h
00046 #include <freecloth/base/baTraceStream.h>
00047 #endif
00048 
00049 //! Custom assertion macro.
00050 #define DGFX_ASSERT(x) assert( x )
00051 
00052 //! Do a DGFX_TRACE of x at execution, and another one when the current
00053 //! scope ends. Useful for tracking function entry/exit. Indentation
00054 //! of trace output is increased from here to end of scope.
00055 #define DGFX_TRACE_ENTER(x)                             \
00056     BaTraceEntry theBaTraceEntry;                       \
00057     theBaTraceEntry.getStream() << x;                   \
00058     theBaTraceEntry.doneOutput();
00059 
00060 //! Dump \p x to tracing stream, typically debug_trace.txt. Only happens in
00061 //! debug builds with NDEBUG flag undefined.
00062 #define DGFX_TRACE(x)                                   \
00063     BaTraceStream::theTraceStream().getStream()         \
00064         << BaTraceStream::theTraceStream().startl()     \
00065         << x                                            \
00066         << std::endl
00067 
00068 #endif
00069 
00070 
00071 #endif

Generated on Wed Apr 23 15:58:46 2003 for Freecloth by doxygen1.3-rc3