Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Debugging/Debugging.h

Go to the documentation of this file.
00001 /**
00002 * @file Tools/Debugging/Debugging.h
00003 *
00004 * Macros and functions for debugging
00005 * 
00006 * @author Martin Lötzsch
00007 */ 
00008 #ifndef __Debugging_h_
00009 #define __Debugging_h_
00010 
00011 // Please don't include GTAssert.h here. GTAssert.h includes afx.h in the Win32 version,
00012 // which makes it a bit slow and is not needed in the most files where Debugging.h is used.
00013 // M.L.
00014 //#include "Platform/GTAssert.h"
00015 
00016 #include "Tools/Debugging/DebugKeyTable.h"
00017 #include "Tools/MessageQueue/OutMessage.h"
00018 
00019 /**
00020 * Sets a pointer to an OutMessage and to a DebugKeyTable to be used by the macros.
00021 *
00022 * @param queue A pointer to an OutMessage.
00023 * @param table A pointer to a DebugKeyTable.
00024 */
00025 void initDebugging(OutMessage* queue, DebugKeyTable* table);
00026 
00027 /**
00028 * Returns a reference to a process wide OutMessage.
00029 */
00030 OutMessage& getDebugOut();
00031 
00032 /**
00033 * Returns a reference to a process wide debug key table
00034 */
00035 DebugKeyTable& getDebugKeyTable();
00036 
00037 
00038 #ifdef NDEBUG
00039 
00040 #define INFO(key,type,format,expression) /**/
00041 #define OUTPUT(type,format,expression) /**/
00042 #define WATCH(key,type,format,expression) /**/
00043 
00044 #else //NDEBUG
00045 
00046 /**
00047 * A macro for sending debug messages depending on a debug key.
00048 *
00049 * @param key A key from the DebugKeyTable::debugKeyID enum.
00050 * @param type The type of the message from the MessageID enum in MessageIDs.h
00051 * @param format The message format of the message (bin or text)
00052 * @param expression A streamable expression
00053 *
00054 * Examples:
00055 * <pre>
00056 * INFO(sendImages,idImage,bin,myImage);
00057 * INFO(sendInterestingValue,idInterestingValue,text,"value: " << value);
00058 * INFO(sendWorldState,idWorldState,bin,worldState);
00059 * </pre>
00060 */
00061 #define INFO(key,type,format,expression) \
00062   if (getDebugKeyTable().isActive(DebugKeyTable::key)) {\
00063     getDebugOut().format << expression;\
00064     getDebugOut().finishMessage(type);\
00065   }\
00066 
00067 /**
00068 * A macro for sending debug messages.
00069 *
00070 * @param type The type of the message from the MessageID enum in MessageIDs.h
00071 * @param format The message format of the message (bin or text)
00072 * @param expression A streamable expression
00073 *
00074 * Examples:
00075 * <pre>
00076 * OUTPUT(idImage, bin, *pMyImage);
00077 * OUTPUT(idText, text, "MyObject::myFunction() invoked");
00078 * OUTPUT(idText, text, "i: " << i << ", j:" << j);
00079 * </pre>
00080 */
00081 #define OUTPUT(type,format,expression) \
00082   { getDebugOut().format << expression;\
00083   getDebugOut().finishMessage(type); }
00084 
00085 #if defined(_WIN32) && !defined(SIMROBOT)
00086 
00087 /**
00088 * A macro for sending debug messages that differs between Windows and Aperios.
00089 * The parameters equal to the parameters if the INFO macro.
00090 * Different from INFO, the output is sent automatically on the WIN32 platform
00091 */
00092 #define WATCH(key,type,format,expression) \
00093   OUTPUT(type,format,expression);
00094 
00095 
00096 #else
00097 
00098 /**
00099 * A macro for sending debug messages that differs between Windows and Aperios.
00100 * The parameters equal to the parameters if the INFO macro.
00101 * Different from INFO, the output is sent automatically on the WIN32 platform
00102 */
00103 #define WATCH(key,type,format,expression) \
00104   INFO(key,type,format,expression);
00105 
00106 #endif
00107 
00108 #endif //NDEBUG
00109 
00110 #endif //__Debugging_h_
00111 
00112 /*
00113  * Change log :
00114  * 
00115  * $Log: Debugging.h,v $
00116  * Revision 1.1.1.1  2004/05/22 17:36:03  cvsadm
00117  * created new repository GT2004_WM
00118  *
00119  * Revision 1.2  2004/03/28 12:02:47  roefer
00120  * All drawings can be switched on and off in simulator
00121  *
00122  * Revision 1.1  2003/10/07 10:13:22  cvsadm
00123  * Created GT2004 (M.J.)
00124  *
00125  * Revision 1.2  2003/09/26 15:28:10  juengel
00126  * Renamed DataTypes to representations.
00127  *
00128  * Revision 1.1.1.1  2003/07/02 09:40:28  cvsadm
00129  * created new repository for the competitions in Padova from the 
00130  * tamara CVS (Tuesday 2:00 pm)
00131  *
00132  * removed unused solutions
00133  *
00134  * Revision 1.6  2003/06/05 12:15:59  dueffert
00135  * if () OUTPUT() is allowed now
00136  *
00137  * Revision 1.5  2002/10/01 11:14:34  loetzsch
00138  * Redesigned DebugKey and DebugKeyTable
00139  *
00140  * Revision 1.4  2002/09/29 18:02:51  loetzsch
00141  * removed the INIT_DEBUG_KEY_TABLE macro from debugging.h
00142  *
00143  * Revision 1.3  2002/09/29 12:32:37  juengel
00144  * Changed semantics of "debug key is active".
00145  * If a debug key is active changes only before the execution of a process.
00146  *
00147  * Revision 1.2  2002/09/17 23:55:23  loetzsch
00148  * - unraveled several datatypes
00149  * - changed the WATCH macro
00150  * - completed the process restructuring
00151  *
00152  * Revision 1.1  2002/09/10 15:53:58  cvsadm
00153  * Created new project GT2003 (M.L.)
00154  * - Cleaned up the /Src/DataTypes directory
00155  * - Removed challenge related source code
00156  * - Removed processing of incoming audio data
00157  * - Renamed AcousticMessage to SoundRequest
00158  *
00159  * Revision 1.2  2002/07/23 13:48:28  loetzsch
00160  * - new streaming classes
00161  * - removed many #include statements
00162  * - exchanged StaticQueue by MessageQueue
00163  * - new debug message handling
00164  * - general clean up
00165  *
00166  * Revision 1.1.1.1  2002/05/10 12:40:32  cvsadm
00167  * Moved GT2002 Project from ute to tamara.
00168  *
00169  * Revision 1.11  2002/05/06 11:50:21  risler
00170  * removed test for debugOut
00171  *
00172  * Revision 1.10  2002/05/05 13:51:51  risler
00173  * test if debugOut exists in OUTPUT,INFO
00174  *
00175  * Revision 1.9  2002/04/20 15:52:23  roefer
00176  * Project simpified, WATCH and WATCH_PART added
00177  *
00178  * Revision 1.8  2002/01/22 00:08:00  loetzsch
00179  * Warnings for meaningless static const int ....() functions fixed
00180  *
00181  * Revision 1.7  2001/12/12 18:55:23  loetzsch
00182  * Representations/DebugKeyTable.h entfernt
00183  *
00184  * Revision 1.6  2001/12/12 18:08:56  loetzsch
00185  * Streaming- Operatoren für Bilder eingebaut, DebugKeyTable nicht- statisch gemacht, Debuggin Mechanismen weitergemacht, Bilder aus Logfiles in RobotControl anzeigen, Logfiles in HU1/Debug auf den Stick schreiben
00186  *
00187  * Revision 1.5  2001/12/10 17:47:10  risler
00188  * change log added
00189  *
00190  */

Generated on Thu Sep 23 19:57:37 2004 for GT2004 by doxygen 1.3.6