00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _OUTPUT_H_
00033 #define _OUTPUT_H_
00034
00035 #if _MSC_VER > 1000
00036 #pragma once
00037 #endif // _MSC_VER > 1000
00038
00039 #include "monitors.h"
00040
00041 #ifdef NDEBUG
00042 #define LeaveRelease return;
00043
00044 #define debug ((void)0)
00045 #define unsafe_debug ((void)0)
00046
00047
00048 #pragma warning(disable: 4127)
00049 #pragma warning(disable: 4702) // unreachable code
00050
00051 #else
00052 #define debug Debug
00053 #define unsafe_debug UnsafeDebug
00054 #define LeaveRelease ((void)0)
00055
00057 extern ofstream traceOut;
00058
00059 #endif
00060
00061 template <class T>
00062 void Debug(const T& t)
00063 {
00064 LeaveRelease;
00065 Lock(output_lock);
00066 traceOut << t << endl;
00067 Unlock(output_lock);
00068 }
00069
00070 template <class T1, class T2>
00071 void Debug(const T1& t1, const T2& t2)
00072 {
00073 LeaveRelease;
00074 Lock(output_lock);
00075 traceOut << t1 << "\t" << t2 << endl;
00076 Unlock(output_lock);
00077 }
00078
00079 template <class T1, class T2>
00080 void UnsafeDebug(const T1& t1, const T2& t2)
00081 {
00082 LeaveRelease;
00083 traceOut << t1 << "\t" << t2 << endl;
00084 }
00085
00086 template <class T1, class T2, class T3>
00087 void UnsafeDebug(const T1& t1, const T2& t2, const T3& t3)
00088 {
00089 LeaveRelease;
00090 traceOut << t1 << "\t" << t2 << "\t" << t3 << endl;
00091 }
00092
00093 template <class T1, class T2, class T3>
00094 void Debug(const T1& t1, const T2& t2, const T3& t3)
00095 {
00096 LeaveRelease;
00097 Lock(output_lock);
00098 traceOut << t1 << "\t" << t2 << "\t" << t3 << endl;
00099 Unlock(output_lock);
00100 }
00101
00102
00103 template <class T1, class T2, class T3, class T4>
00104 void Debug(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
00105 {
00106 LeaveRelease;
00107 Lock(output_lock);
00108 traceOut << t1 << "\t" << t2 << "\t" << t3 << "\t" << t4 << endl;
00109 Unlock(output_lock);
00110 }
00111 #endif // _OUTPUT_H_